Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Taking Norman’s advice to heart, I’ve hacked together a solution that used (a <a href="https://bitbucket.org/birkenfeld/pygments-main/changeset/0f61d8e9d1ce" rel="noreferrer">patched</a>) Pygments for highlighting and pushed in as many features as possible without bursting ;-)</p> <p>I’ve also created a LateX package, once my Pygments patch was released in <a href="http://pygments.org/download/" rel="noreferrer">version 1.2</a> …</p> <h1>Presenting <em>minted</em></h1> <p><strong><a href="http://tug.ctan.org/tex-archive/macros/latex/contrib/minted/" rel="noreferrer"><em>minted</em></a></strong> is a package that uses Pygments to provide top-notch syntax highlighting in LaTeX. For example, it allows the following output.</p> <p><img src="https://i.stack.imgur.com/OLUjl.png" alt="fancy LaTeX example"></p> <p>Here’s a minimal file to reproduce the above code (notice that including Unicode characters might require XeTeX)!</p> <pre><code>\documentclass[a4paper]{article} \usepackage{fontspec} \usepackage{minted} \setsansfont{Calibri} \setmonofont{Consolas} \begin{document} \renewcommand{\theFancyVerbLine}{ \sffamily\textcolor[rgb]{0.5,0.5,0.5}{\scriptsize\arabic{FancyVerbLine}}} \begin{minted}[mathescape, linenos, numbersep=5pt, gobble=2, frame=lines, framesep=2mm]{csharp} string title = "This is a Unicode π in the sky" /* Defined as $\pi=\lim_{n\to\infty}\frac{P_n}{d}$ where $P$ is the perimeter of an $n$-sided regular polygon circumscribing a circle of diameter $d$. */ const double pi = 3.1415926535 \end{minted} \end{document} </code></pre> <p>This can be typeset using the following command:</p> <pre><code>xelatex -shell-escape test.tex </code></pre> <p>(But <em>minted</em> also works with <code>latex</code> and <code>pdflatex</code> …)</p> <p><code>minted.sty</code> works similar to <code>texments.sty</code> but allows additional features.</p> <h2>How to get it</h2> <ul> <li><p><em>minted</em> is <a href="http://tug.ctan.org/tex-archive/macros/latex/contrib/minted/" rel="noreferrer">listed on CTAN</a> (<a href="http://tug.ctan.org/pkg/minted" rel="noreferrer">package info</a>)</p></li> <li><p><strong>documentation</strong> is of course included.</p></li> <li><p><em>minted</em> is now maintained by Geoffrey Poore. The development version, including the latest <a href="https://github.com/gpoore/minted/blob/master/source/minted.sty" rel="noreferrer"><code>.sty</code> file</a>, is available at <a href="https://github.com/gpoore/minted" rel="noreferrer">github.com/gpoore/minted</a>, and can be cloned from there.</p></li> </ul> <p>Once again, thanks to Norman for motivating me to produce this package.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload