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 \...
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 ...
38
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}
@...
35
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{...
34
votes
break lines in minted code
Version 2.1 of minted has breaklines and linenos:
\documentclass[a5paper]{article}
\usepackage[T1]{fontenc}
\usepackage[]{minted}
\begin{document}
\begin{minted}[linenos,tabsize=2,breaklines]{text}
...
31
votes
31
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
...
30
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. ...
27
votes
Red box drawn around question-mark operator in minted Erlang code
In my case, the solutions above does not work. I was trying to print the following Python 3 line, using minted 2.1:
>>> print("Instalação!")
Instalação!
I ended by disable the color boxes ...
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 ...
24
votes
Accepted
LaTeX Minted package using custom output-directory=build
You need \usepackage[outputdir=build]{minted} to tell minted where the files went.
23
votes
Accepted
Work-around for minted code highlighting in arXiv?
You know you really should provide an MWE:-)
So here's one:
\documentclass{report}
\usepackage{minted}
\begin{document}
zzz
\begin{minted}{html}
<!DOCTYPE html
<html>
<head>
<...
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 ...
20
votes
Accepted
How to highlight (color/draw attention to) a particular snippet in Minted
The minted documentation has an example using escapeinside. I’m just copying it here:
\begin{minted}[escapeinside=||]{py}
def f(x):
y = x|\colorbox{green}{**}|2
return y
\end{minted}
...
19
votes
Pygmentize not working properly with minted package in TexShop on OS X
I had the same problem and it took me a while until I realized it was TeXShop causing all the trouble. Like you already mentioned, you need a reference to pygmentize within /Library/TeX/texbin, but it'...
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 ...
17
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 ...
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}[...
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:
\...
16
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 ...
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 ...
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 ...
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,...
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{...
14
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 ...
14
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}
\...
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....
14
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-...
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=\...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
minted × 1000listings × 148
code × 78
tcolorbox × 75
pygments × 64
beamer × 57
python × 42
environments × 40
highlighting × 39
verbatim × 37
xetex × 36
captions × 35
pdftex × 27
tikz-pgf × 26
errors × 26
sourcecode × 26
syntax-highlighting × 26
color × 25
luatex × 22
floats × 21
macros × 20
fonts × 18
unicode × 18
fancyvrb × 18
page-breaking × 17