TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to put some inline code using minted but when I try to typesent the empty string "" I get an "undefined control sequence" error.

Sample code:



The pdf is created anyway but I get this instead of the expected "":

\def {\futurelet \protect \let \relax }\def {\futurelet \protect \let \relax }

(Yes, I really mean that the above commands are printed in the footnote in the pdf).

Commenting out babel solves the problem, but I need babel in my real TeX file. Also I do not want to use `` and '', since they give an output that does not match with the code inserted using \inputminted. Is there a way to fix this? Eventually how can I put real a doublequote(a.k.a. ASCII 34)? Note that \mint is like \verb so normal LaTeX commands are ignored.

On a side note I'm using this answer to typeset inline code with minted, but it is not the cause of the problem.

share|improve this question
Just say \shorthandoff{"} after \begin{document}, if you don't need the shorthands. However, expect problems with \mint in footnotes. – egreg Nov 20 '12 at 18:44
@egreg That fixes the problem. Could you explain why using mint in footnotes could create problems? And, since I need to have some syntax highlighting of keywords in the footnotes how should I do it without using mint and being consistent with the rest of the document? (Also note that I cannot use custom commands otherwise Kile would screw up the highlightining due to a lot of $ inside code, so saying create a newcommand with an optional arg is not a solution). – Bakuriu Nov 20 '12 at 19:44
up vote 6 down vote accepted

If you don't have to use minted, you could try my pythontex package, which uses the same Pygments highlighting library. It provides a \pygment command for inline use, and this seems to work fine in footnotes, except that # and % characters don't work (the # and % work fine outside footnotes in normal text, and it wouldn't be hard to get around the footnote issue if these characters are needed). The package also provides a pygments environment and an \inputpygments command.


\footnote{Quotes: \pygment{bash}/""/.  More: \pygment{bash}/echo ${a[$i,$j]}/.}

enter image description here

More explanation and patch for minted

The ultimate issue is that minted uses verbatim content (ShortVerb from fancyvrb), and that's problematic in footnotes. My package uses a different approach, and also caches all highlighted content to increase speed.

Here's a rough patch for minted that should give you what you want. It makes \mint into an inline command. It's based on some things I did in my package, so it should work in footnotes as well as my package does. I had to make new versions of \minted@savecode and \minted@pygmentize to get rid of excess spaces (added lots of %), and to temporarily swap Verbatim for BVerbatim. It's very important to avoid any extra spaces hanging around for inline use; the examples show that regular text can be right up against highlighted content.

Comment on performance: If you are going to redefine \mint for inline use (or, perhaps better, define a new command for that purpose), you will presumably use inline code fairly frequently. On my system, compiling takes about 12 s when \mint{bash}/""/ is used 40 times; it's about 23 s for 80 times. pythontex takes about 3.5 s for 40 uses of \pygment{bash}/""/ (this involves running pdflatex, then the pythontex script, and then pdflatex again, to bring back highlighted results). It's about the same for 80 uses, about 5.5 s for 800 uses, and about 23 s for 8000. And all of those numbers are only when pythontex actually has to highlight everything; since results are saved, the pythontex script and second pdflatex run are only needed when code is modified. If you are recompiling after editing non-code text, you only need to run pdflatex, and should get more or less normal pdflatex speeds.

enter image description here


    \expandafter\edef\csname FV@SV@minted@verb\endcsname{\detokenize{##1}}%


  \def\minted@cmd{pygmentize -l #2 -f latex -F tokenmerge
    \minted@opt{gobble} \minted@opt{texcl} \minted@opt{mathescape}
    \minted@opt{startinline} \minted@opt{funcnamehighlighting}
    \minted@opt{linenos} -P "verboptions=\minted@opt{extra}"
    -o \jobname.out.pyg #1}%
  % For debugging, uncomment:


Before environment
After environment

Before inline\mint[]{bash}/""/After inline

Before note\footnote{Before\mint{bash}/""/After}


Edit 2013/07/30

I am now maintaining minted, and have incorporated code similar to the patch here to create a new inline command, \mintinline, in the development version on GitHub.

share|improve this answer
When you say "unless you need # or % characters" you mean only in the footnotes or in general? Because I do not think I need them in the footnotes, but I do need them in the text. Also can you provide some information about why footnotes interact badly with mint?(or some useful link?) – Bakuriu Nov 20 '12 at 21:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.