{code} is about using LaTeX to format and display source code. For questions about TeX itself as a programming language, use the {programming} tag.

is about using LaTeX to format and display source code. For questions about TeX itself as a programming language, use the tag.

Formatting source code in LaTeX can be done in several ways:

  1. The environment is the most basic.
  2. makes verbatim environments much more customizable, and allows pre-processing of its input. More information: fancyvrb package documentation.
  3. is probably the most popular choice: it offers syntax highlighting and other features, and is extensively customizable. More information: listings package documentation.
  4. Another common choice is , which is also extremely powerful, using the 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 tag.