Skip to main content
73 votes
Accepted

Minted Error "Undefined control sequence. \PYG" with TeXmaker

I had a similar issue in Linux and removing _minted* directory solved the problem. Another option could be to include the minted package with the option cache=false. You can do this by using \...
JacintoCC's user avatar
  • 846
43 votes
Accepted

minted vs. listings: pros and cons

This is really further commentary on samcarter's answer. minted uses an external library to do the highlighting, listings does everything in TeX. Almost all the pros and cons are attributable to this ...
David Carlisle's user avatar
40 votes
Accepted

Change font size in minted

minted has a fontsize option. Here some examples: \documentclass{article} \usepackage{minted} \begin{document} \noindent This is \verb|\footnotesize|: \begin{minted}[fontsize=\footnotesize]{objc} @...
CarLaTeX's user avatar
  • 64.7k
36 votes
Accepted

Minted red box around greek characters

This seems to be an error in the Python lexer. If you don't need \fcolorbox inside the minted environment, here's a hack: \documentclass[12pt,a4paper]{article} \usepackage{fontspec} \setmainfont{...
egreg's user avatar
  • 1.1m
34 votes

How to highlight (color/draw attention to) a particular snippet in Minted

You can highlight certain lines with highlightlines={1,2-3,5-10}, e.g. \begin{minted}[highlightlines={1,3-4,6-10}]{python} def f(x): y = x ** 2 return y def f(x): y = x ** 2 return y ...
ComFreek's user avatar
  • 1,278
32 votes

Minted, setstretch and font size

\setminted{fontsize=\small,baselinestretch=1} Enjoy
Himura's user avatar
  • 913
32 votes
Accepted

Global settings for minted

Yes, there is the\setminted command for setting options for the whole document. From the package documentation: You may wish to set options for the document as a whole, or for an entire language. ...
siracusa's user avatar
  • 13.5k
25 votes

Work-around for minted code highlighting in arXiv?

As already pointed out by David Carlisle, minted provides a built-in workaround for environments that don't support -shell-escape/Pyhton/Pygments. As of minted version 2.2, you can use the package ...
beatngu13's user avatar
  • 897
24 votes
Accepted

LaTeX Minted package using custom output-directory=build

You need \usepackage[outputdir=build]{minted} to tell minted where the files went.
David Carlisle's user avatar
22 votes

minted vs. listings: pros and cons

(Disclaimer: I am a listings user, so maybe my opinion is biased) As far as I know minted needs to be run with -shell-escape. This can be a con in several situations: the tex system is set up to not ...
samcarter_is_at_topanswers.xyz's user avatar
18 votes

Minted in beamer overlays

The problem with using \only{...} is, that you cannot have such fragile content as argument for a macro (see e.g. https://tex.stackexchange.com/a/30006/36296 for more explanation). Luckily you can ...
samcarter_is_at_topanswers.xyz's user avatar
18 votes
Accepted

Warning when adding package minted?

The fvextra package is loaded by minted, so you should load minted before csquotes. Another thing you should do is loading hyperref last: very few packages should come later than this one and you are ...
egreg's user avatar
  • 1.1m
17 votes
Accepted

How to install pygments on windows 7

As stated on its website, pygments is a tool written in Python. So you have to do the following: Download and install a Python 3.X version from https://www.python.org/downloads/. Make sure it's in ...
TeXnician's user avatar
  • 33.7k
16 votes

Reference source code line in minted package

@Ant's answer is great, but requires that your \label go inside a comment that will appear in the rendered code. You can get around this by using escapeinside instead of mathescape: \begin{minted}[...
jme's user avatar
  • 333
16 votes
Accepted

TeX Live 2016: minted doesn't work with LuaLaTeX (bug fixed in June 2016)

Several packages using \write18 will need to be updated for compatibility with LuaLaTeX under LuaTeX 0.90; minted is among them. However, the shellesc package provides the necessary workaround: \...
egreg's user avatar
  • 1.1m
15 votes

Pagebreak for minted in figure

Welcome to TeX.SX! Yes, I would indeed say there is a better way of achieving this. Well, at least in my humble opinion. For starters, as has been mentioned by TeXnician, using a figure to contain a ...
alpenwasser's user avatar
  • 2,455
15 votes
Accepted

Minted Color Themes Display Improper Colors

You have to set the background color yourself. This is not the default because it is really printer unfriendly. \documentclass[a4paper]{article} \usepackage{minted,xcolor} \usemintedstyle{monokai} \...
Henri Menke's user avatar
15 votes
Accepted

Different fontsize for minted and mintinline

You can do even better, namely make \mintinline use the current font size. The package minted allows for \setmintinline, that takes precedence over \setminted for \mintinline; the only trick is to ...
egreg's user avatar
  • 1.1m
15 votes
Accepted

minted environment in frame causes error

minted is one of the many verbatim environments you will find when using source code in LaTeX. Those verbatim environments need special treatment (the fragile option) by design which is usually not ...
TeXnician's user avatar
  • 33.7k
15 votes
Accepted

Best unicode font to work with minted in xelatex/lualatex

You can fill in the gaps by making the characters active with a suitable definition % !TEX engine = xelatex \documentclass[12pt]{article} \usepackage[letterpaper]{geometry} \usepackage{fontspec,...
David Carlisle's user avatar
15 votes

Pygmentize not installed error on Visual Studio Code

You could try @David Carlisle's comment by adding --shell-escape to the compiling commands in the preference of LaTeX Workshop, like the following: // in USER SETTINGS add the following "latex-...
logstar's user avatar
  • 257
14 votes

Beamer vs. Minted: overlays

It seems that there's been some progress and this now works as expected: \documentclass{beamer} \usepackage{minted} \begin{document} \begin{frame}[fragile] \frametitle{Foo} \begin{minted}[...
Michaël's user avatar
  • 1,434
14 votes
Accepted

Is it possible to use tikzmark inside minted?

Yes, it appears to work, you just need to specify an escape character (? here) to minted so you can insert the \tikzmark. \documentclass{article} \usepackage{minted} \usepackage{tikz} \usetikzlibrary{...
David Carlisle's user avatar
14 votes
Accepted

How to solve the `Package inputenc Error: Unicode char not set up for use with LaTeX` problem?

You can declare these characters. For example, like this: \DeclareUnicodeCharacter{25CF}{$\bullet$} \DeclareUnicodeCharacter{251C}{\mbox{\kern.23em \vrule height2.2exdepth1exwidth.4pt\vrule height2....
wipet's user avatar
  • 75.7k
14 votes
Accepted

Unwanted space in inline code with minted in beamer

The frame option [fragile] is needed. See Section 12.9 of the beamer documentation. % arara: pdflatex: { shell : yes } \documentclass{beamer} \usepackage{minted} \newminted{latex}{fontsize=\...
CarLaTeX's user avatar
  • 64.7k
14 votes

minted environment not working in overleaf

(Tom from Overleaf Support Team speaking.) Unfortunately, this is a limitation of the current setup of Overleaf, sorry for this. The main file should preferably be always placed in the main directory;...
yo''s user avatar
  • 51.6k
13 votes

Add keyword to language in minted

Since I only needed highlighting for one word and couldn't find any quick solution (and didn't want to rewrite the entire highlighting), I came up with this (ashamingly) dirty workaround: Firstly, ...
cabeer's user avatar
  • 131
12 votes

How to change overall font size of minted?

With \setminted{fontsize=...} you can set the default font size for all your minted environments. If you explicitly indicate a font size in a single minted environment, it overrides the default. I ...
CarLaTeX's user avatar
  • 64.7k
12 votes
Accepted

Use minted for plain-text? (without syntax-highlighting)

Oh forget it, there is apparently a "language"/lexer called text. So stupid I could not find it as it is not listed on the pygments home page. I'll close this as a dupe.
rugk's user avatar
  • 1,160

Only top scored, non community-wiki answers of a minimum length are eligible