Saturday, November 5, 2011

Minted: Highlighted source code in LATEX

Minted is a LaTeX package that facilitates expressive syntax highlighting using the powerful Pygments library. The package provides options to customize the highlighted source code output.
The example below shows how C code is highlighted,  and the output is shown at right:

\documentclass{article}
\usepackage{minted}

\begin{document}

\begin{minted}{c}
int main()
{
  printf("hello, world");
  return 0;
}
\end{minted}

\end{document}

Pygments also provides a command line interface pygmentize, among the possible output formats there are HTML, RTF, LaTeX and ANSI sequences.
For command line highlighting a solid alternative to Pygments is GNU Source-highlight.



Source: http://mirrors.ircam.fr/pub/CTAN/macros/latex/contrib/minted/minted.pdf
A couple of on-line highlighters: http://www.hilite.me/http://quickhighlighter.com/

No comments:

Post a Comment