Hot answers tagged

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
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} @...
CarLaTeX's user avatar
  • 61.3k
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{...
egreg's user avatar
  • 1.1m
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} ...
egreg's user avatar
  • 1.1m
31 votes

Minted, setstretch and font size

\setminted{fontsize=\small,baselinestretch=1} Enjoy
Himura's user avatar
  • 893
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 ...
ComFreek's user avatar
  • 1,238
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. ...
siracusa's user avatar
  • 13.3k
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 ...
Marcos Lourenço's user avatar
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
  • 867
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
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> <...
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
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} ...
Konrad Rudolph's user avatar
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'...
beatngu13's user avatar
  • 867
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.4k
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 ...
egreg's user avatar
  • 1.1m
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
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 ...
samcarter_is_at_topanswers.xyz'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.4k
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
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

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,445
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} \...
Henri Menke'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
  • 72.2k
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-...
logstar's user avatar
  • 247
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
  • 61.3k

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