LaTeX code highlighting is possible using the “minted” package, which uses Pygments as a backend. To install minted:
tlmgr install minted python -m pip install pygments
If using a GUI, the “–shell-escape” option may need to be added.
In TeXmaker / TeXstudio, under “Options → Configure → Commands” add
--shell-escape right after the compiler executable.