Questions tagged [minted]

{minted} is a package that facilitates expressive syntax highlighting in LaTeX using the powerful Pygments library. The package provides options to customize the highlighted source code output using {fancyvrb}.

You'll need to install the Python package Pygments (e.g using pip install Pygments).

If you want to run your file with pdflatex, then you need to do so with the -shell-escape flag, e.g. pdflatex -shell-escape myfile.tex

The minted package facilitates expressive syntax highlighting in LaTeX using the powerful Pygments library. This does mean that, unlike , minted requires the installation of additional software. This may seem like a disadvantage but it does mean that whilst basically only highlights strings, comments and keywords, minted and Pygments, on the other hand, can be completely customized to highlight any token kind 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.

The package provides options to customise the highlighted source code output using .

For minted to work properly you need to install Python and the Pygments package. With pip you would do pip install Pygments, on a Debian-based distro you could do sudo apt-get install python-pygments. Be sure to make Pygments available in your PATH.

Any document that uses minted has to be compiled with -shell-escape, e.g. pdflatex -shell-escape myfile.tex.

1025 questions
51
votes
1 answer

How do I import a source file using minted

Currently, I have something like this: \begin{minted}{csharp} public static void Main (string[] args) { Console.WriteLine ("Hello World!"); } \end{minted} Where the source code is copy/pasted from a source file. Is there any way to include the…
30
votes
5 answers

Minted red box around greek characters

When using Minted i get a red box around greek characters Can this behaviour be disabled or is there a specific line that needs to be changed in the python lexer? A minimal working…
Kim Petersen
  • 415
  • 4
  • 7
28
votes
2 answers

Can I print only some functions with minted?

I often have to print Source Code, but quite often only some parts of a project. Now I got a task to improve two functions and I have to print out what I change. I use minted for printing source code. How can I tell minted to print only a given…
Martin Thoma
  • 18,799
24
votes
1 answer

Change font size in minted

i'have this in my document \begin{minted}{objc} @property (retain, nonatomic) IBOutlet UIButton *playButton; \end{minted} But I would like to reduce the size of the text '@property ..' because it is very long and I do not want it to head.. I do not…
user147232
23
votes
5 answers

minted not working on mac

I am using texmaker on a Mac and I tired to use the minted package with this code \documentclass[12pt,A4]{article} \usepackage{minted} \begin{document} \begin{minted}{python} def __init__(self, x, y): self.x=x …
Zwähnia
  • 2,011
23
votes
1 answer

Set global options for \inputminted

I am using the minted package to highlight source code. How can I set the options parameter globally for \inputminted? I want to do this because I have a lot of php code files that I will include in my document and I do not want to lose time to…
Starlays
  • 353
  • 1
  • 2
  • 8
22
votes
1 answer

Minted mathescape

Please consider the following code: \documentclass{article} \usepackage{minted} \begin{document} \begin{minted}[mathescape=true]{text} $A\wedge B$ \end{minted} \end{document} When I try to compile this code using XeLaTeX (other engines not…
17
votes
1 answer

Global settings for minted

I'm working on a document where source code listings are largely in a single language, and where I would like to have a homogeneous listing style document-wide. Using an example from the docs, I would essentially like to make the following settings…
Jules
  • 573
16
votes
3 answers

Background colour with minted package: code misplaced

With the following example \listfiles \documentclass{article} \usepackage{minted} \definecolor{bg}{rgb}{0.95,0.95,0.95} \begin{document} Some text \begin{minted}{latex} A test \end{minted} Some text \begin{minted}[linenos=true]{latex} A…
Joseph Wright
  • 259,911
  • 34
  • 706
  • 1,036
13
votes
1 answer

minted and tabs

I can get a code block including tab characters in a minted environment to work with the obeytabs option, which results in a tab size of 8. The tabsize option, however, will mess up the tab…
cmz
  • 323
13
votes
1 answer

Problem in adding a background color in a minted environment

I want to add a background color to the minted environment in my LaTeX document. However, when I add the the background color the environment does not start in a new line. Could someone help me fix this…
12
votes
3 answers

How can I produce black and white source code using the minted package?

I just started using the minted package, to produce formatted source codes. I thought the style bw is a black and white style of pygmentize and it just uses italic and bold to format the code (I tried the code below), but I was wrong. Is there any…
grus
  • 121
11
votes
1 answer

Remove blank lines in minted

Is it possible to remove blank (empty) lines in minted, and gobble multiple blank lines to a specified amount, like the emptylines option in…
Juri Robl
  • 4,763
11
votes
1 answer

Pygmentize not installed error on Visual Studio Code

I have been using VS Code + Latex Workshop for the last year and so to write up my tex documents however today I tried using the minted package which I have installed in /usr/local/bin/pygmentize In my preamble I have used the line…
9
votes
4 answers

Break lines at any character in minted

Consider any snippet of minted code that contains a large string not containing any spaces like: \documentclass{article} \usepackage{minted} \setminted{breaklines} \begin{document} \begin{minted}{xml}
1
2 3
9 10