Support   //  Texpad OS X   //  Typesetting
Typesetting with minted

minted is a LaTeX package that allows syntax highlighting in your LaTeX source code using the Pygments library. You can read more about it and see some examples at https://github.com/gpoore/minted.

Installing dependencies:

You will need Pygments, the syntax highlighter used by minted. This can be done by running

sudo easy_install Pygments

in a Terminal window. Please see http://pygments.org/download/ for the up-to-date instructions on this.

Shell Escape

minted requires Shell Escape to be enabled. This is a potential security hole and is not enabled by default by Texpad. To enable Shell escape open Preferences, switch to the Typesetting pane and check the -shell-escape box. In Texpad macOS 1.8, minted will be detected by Texpad automatically and a suggestion dialogue will be presented to you to this effect.

Typesetting while hiding intermediate files

By default Texpad invokes LaTeX in such a way that all intermediate files are kept hidden out of sight in the .texpadtmp directory (a hidden directory at the same path as the root file). Unfortunately the minted package requires that this directory must be defined as an option to its \usepackage{minted} command. This may be done by modifying the command to

\usepackage[outputdir=.texpadtmp]{minted}

An alternative is to turn off .texpadtmp. This may be done by opening preferences, choosing the typesetting pane, and unchecking “Hide Intermediate Files”.

An example

This simple example will print the included C++ code with syntax highlighting in your PDF. Note the use of correct options in \usepackage[outputdir=.texpadtmp]{minted} to make minted work with Texpad’s .texpadtmp.

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[outputdir=.texpadtmp]{minted}

\begin{document}

\begin{figure}[h!tb]
\caption{helloworld.cpp}
\begin{minted}[linenos=true]{cpp}
#include <iostream>
int main() {
    std::cout << "Hello, world!\n";
}
\end{minted}
\end{figure}

\end{document}
News  ·   Blog  ·   About us  ·   Contact us
  Follow  ·     Tweet  ·     Like  ·     Tell a Friend
Valletta Ventures
Company  ·   Terms & Conditions  ·   Privacy & Security
© 2011-2019 Valletta Ventures (UK) Ltd. All rights reserved.