How to use minted under MikTeX and Windows 7?

minted uses Python pygments library, so you need to:

  • Install Python, choose any version you like: x64 or x86, it better to choose 2.7.5 version.
  • Add Python to PATH:
    • Hold Win and press Pause.
    • Click Advanced System Settings.
    • Click Environment Variables.
    • Append ;C:\Python27 to the PATH variable.
  • Install python-pip.
  • Add ;C:\Python27\Scripts to the PATH variable.
  • pip install pygments to install Pygments (in case you have Perl installed, the full path to pip should be specified, because Perl also has a binary with the same name).

  • Сompile with -shell-escape option enabled:

    \documentclass{article}
    \usepackage{minted}
    
    \begin{document}
        \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}
    

The result should look like:

result


Install python for windows. Then install setuptools. This should add easy_install.exe file in the Scripts folder of your python directory (something like: C:\Python26\Scripts\ in my computer. It may be different for you.) Add C:\Python26\Scripts to your system path using user variables. You may wish to use a user friendly editor: path editor for this purpose.

Now with internet on, go to the command prompt and type easy_install pygments.

enter image description here

Now you may have to restart your computer. And there you go. Try this test file:

\documentclass{article}

\usepackage{amsmath}
\usepackage{minted} % loads fancyvrb

\newenvironment{eqnexample}
 {\VerbatimOut{\jobname.tmp}}
 {\endVerbatimOut
  \inputminted{latex}{\jobname.tmp}
  \input{\jobname.tmp}}

\begin{document}

\begin{eqnexample}
\begin{align}
  d &= \sqrt{ (x'-x)^2 }
  \\
  e &= 0
\end{align}
\end{eqnexample}

\begin{eqnexample}
\begin{multline}
  d = \sqrt{ (x'-x)^2 }  \\
  = f(x,x')
\end{multline}
\end{eqnexample}

\end{document}

enter image description here

Tags:

Miktex

Minted