{code} is about using LaTeX to format and display source code. For questions about TeX itself as a programming language, use the {programming} tag.
code is about using LaTeX to format and display source code. For questions about TeX itself as a programming language, use the programming tag.
Formatting source code in LaTeX can be done in several ways:
- The verbatim environment is the most basic.
- fancyvrb makes
verbatim
environments much more customizable, and allows pre-processing of its input. More information:fancyvrb
package documentation. - listings is probably the most popular choice: it offers syntax highlighting and other features, and is extensively customizable. More information:
listings
package documentation. - Another common choice is minted, which is also extremely powerful, using the pygments library, but requires
python-pygments
, which you will have to install yourself. However, it has the most expressive syntax highlighting out of all of these choices. More information:minted
on GitHub.
If your question concerns one of these packages specifically, please add the tag for that package as well. If your question concerns syntax highlighting specifically, you can also add the highlighting tag.