Typesetting with minted
macOS
app.
See other variants:
Windows

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


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}
\end{document}