The minted package: Highlighted source code in LaTeX
The minted package: Highlighted source code in LATEX
Geoffrey M. Poore gpoore@ gpoore/minted
Originally created and maintained (2009?2013) by Konrad Rudolph
v2.9 from 2023/12/18
Abstract minted is a package that facilitates expressive syntax highlighting using the powerful Pygments library. The package also provides options to customize the highlighted source code output.
Development status: minted version 3.0 is now under development, thanks to a TEX Development Fund grant from the TEX Users Group. This will bring a new Python executable that replaces pygmentize. The new executable will be compatible with restricted shell escape, so no more -shell-escape with associated security vulnerabilities. The new executable will also make it possible to extend minted using Python, not just LATEX macros. This will bring official support for custom lexers, allow including snippets of external files based on regular expressions, and make possible a number of other improvements and bugfixes. For compatibility purposes, the final version of minted v2.x will be released as the compatibility package minted2. Initial beta versions of minted v3.0 are expected by early 2024. A final minted v3.x release including all planned features is expected before the end of summer 2024.
License
LaTeX Project Public License (LPPL) version 1.3. Additionally, the project may be distributed under the terms of the 3-Clause ("New") BSD license: .
1
Contents
1 Introduction
4
2 Installation
4
2.1 Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.2 Required packages . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.3 Installing minted . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3 Basic usage
6
3.1 Preliminary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.2 A minimal complete example . . . . . . . . . . . . . . . . . . . . . 6
3.3 Formatting source code . . . . . . . . . . . . . . . . . . . . . . . . 7
3.4 Using different styles . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.5 Supported languages . . . . . . . . . . . . . . . . . . . . . . . . . . 9
4 Floating listings
9
5 Options
11
5.1 Package options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
5.2 Macro option usage . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5.3 Available options . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
6 Defining shortcuts
28
7 FAQ and Troubleshooting
30
8 Acknowledgements
33
9 Changelog
34
10 Implementation
42
10.1 Required packages . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
10.2 Package options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
10.3 Input, caching, and temp files . . . . . . . . . . . . . . . . . . . . . 46
10.4 OS interaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
10.5 Option processing . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
10.6 Internal helpers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
2
10.7 Public API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 10.8 Command shortcuts . . . . . . . . . . . . . . . . . . . . . . . . . . 76 10.9 Float support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 10.10Epilogue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 10.11Final cleanup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
11 Implementation of compatibility package
80
3
1 Introduction
minted is a package that allows formatting source code in LATEX. For example:
\begin{minted}{}
\end{minted}
will highlight a piece of code in a chosen language. The appearance can be customized with a number of options and color schemes. Unlike some other packages, most notably listings, minted requires the installation of additional software, Pygments. This may seem like a disadvantage, but there are also significant advantages. Pygments provides superior syntax highlighting compared to conventional packages. For example, listings basically only highlights strings, comments and keywords. Pygments, on the other hand, can be completely customized to highlight any kind of token the source language might support. This might include special formatting sequences inside strings, numbers, different kinds of identifiers and exotic constructs such as HTML tags. Some languages make this especially desirable. Consider the following Ruby code as an extreme, but at the same time typical, example:
class Foo def init pi = Math::PI @var = "Pi is approx. #{pi}" end
end
Here we have four different colors for identifiers (five, if you count keywords) and escapes from inside strings, none of which pose a problem for Pygments. Additionally, installing Pygments is actually incredibly easy (see the next section).
2 Installation
2.1 Prerequisites
Pygments is written in Python, so make sure that you have Python 2.6 or later installed on your system. This may be easily checked from the command line:
$ python --version Python 2.7.5
4
If you don't have Python installed, you can download it from the Python website or use your operating system's package manager.
Some Python distributions include Pygments (see some of the options under "Alternative Implementations" on the Python site). Otherwise, you will need to install Pygments manually. This may be done by installing setuptools, which facilitates the distribution of Python applications. You can then install Pygments using the following command:
$ sudo easy_install Pygments
Under Windows, you will not need the sudo, but may need to run the command prompt as administrator. Pygments may also be installed with pip:
$ pip install Pygments
If you already have Pygments installed, be aware that the latest version is recommended (at least 1.4 or later). Some features, such as escapeinside, will only work with 2.0+. minted may work with versions as early as 1.2, but there are no guarantees.
2.2 Required packages
minted requires that the following packages be available and reasonably up to date on your system. All of these ship with recent TEX distributions.
? keyval
? ifthen
? xcolor
? kvoptions ? fancyvrb ? fvextra ? upquote ? float
? calc ? ifplatform ? pdftexcmds ? etoolbox ? xstring
? lineno
? framed ? shellesc (for
luatex 0.87+) ? catchfile
2.3 Installing minted
You can probably install minted with your TEX distribution's package manager. Otherwise, or if you want the absolute latest version, you can install it manually by following the directions below.
You may download minted.sty from the project's homepage. We have to install the file so that TEX is able to find it. In order to do that, please refer to the TEX FAQ. If you just want to experiment with the latest version, you could locate your current minted.sty in your TEX installation and replace it with the latest version. Or you could just put the latest minted.sty in the same directory as the file you wish to use it with.
5
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- the minted package highlighted source code in latex
- guide to numpy mit
- using python to solve partial differential equations
- introduction to python
- introduction to python harvard university
- python basics a practical introduction to python 3
- ii26 procesadores de lenguaje uji
- return to libc
- competitive programmer s handbook
- table of contents
Related searches
- java source code examples
- java source code sample
- java source code download
- source code sample
- sample source code license agreement
- open source code example
- source code access agreement
- source code license agreement
- array source code java
- unity games source code free
- c source code download
- java game source code examples