Template for code highlighting with minted in LaTeX beamer

Syntax highlighting can be achieved in LaTeX via listings or more recently with minted. The latter package uses Pygments to create beautiful code highlighting and includes fantastic additional features such as line numbering.

Minted’s compatibility with the Latex beamer class, however, is restricted and some workarounds (as laid out by Tristan Ravitch in his blog post) are needed to assure full functionality of both the beamer class and minted.

Here’s a template I created for anyone who wants to present code with the beamer class and the minted package. Slides created in such way can then, for example, look like this:

beamer_syntaxhighlight

Get the TeX source code!

Advertisements

2 Comments on “Template for code highlighting with minted in LaTeX beamer”

  1. michaelernstrose says:

    Thanks for the code! Do I have to define it as own command (exampleCode) or can I directly insert the code in the frame environment? And if so, how?


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s