I'm using minted to display some Perl, however the "unmatched" '$' in it is breaking compilation. Escaping it with a '\' results in the \ being displayed with the rest of the code block.

Is there a way to do this?


  • As far as I know, \mintinline is only in the development version of minted. As such, this question is mostly off topic, because \mintinline is not an “official” feature. Why don't you try pythontex? – egreg Dec 4 '14 at 12:47
  • Yes, sorry, it seems i'm using v2.0-alpha3. I haven't heard of pythontex before, but i'll take a look – LordAro Dec 4 '14 at 12:55
  • I changed it so it's not about \mintinline, as that's not really relevant to the question – LordAro Dec 4 '14 at 14:16

You have to escape the special characters:




The character | stands for an arbitrary (nonspecial) character that doesn't appear in the text to be processed, like for \verb.

You might consider using pythontex:





This requires, instead of running pdflatex with the -shell-escape option, running the postprocessor pythontex:

pdflatex filename
pythontex filename
pdflatex filename

Running pythontex is necessary only if some new code is added or existing code has been modified.

In this particular case, also



enter image description here

The result is the same with both packages, because they both use pygmentize.

  • i cannot seem to use \pygment (with minted) - the command isn't recognised – LordAro Dec 4 '14 at 16:34
  • @LordAro No, \pygment is a command for pythontex. My last remark is about how the packages obtain the result. – egreg Dec 4 '14 at 16:35
  • ah, i see. however, i can't seem to use the || with mintinline, just results in the same error – LordAro Dec 4 '14 at 16:36
  • actually, the \pygments method doesn't seem to work either – LordAro Dec 4 '14 at 16:54

It's a disgusting way, but I got it to work:


I only need it in black and white, so it looks fine.

If there's another answer that works better, I will accept that one instead

  • \mintinline{perl}{$_[0]} works fine for me. What packages are you loading? There might be some sort of conflict. – G. Poore Dec 4 '14 at 21:17
  • \usepackage[style=ieee,backend=biber]{biblatex} \usepackage[T1]{fontenc} \usepackage[margin=3cm]{geometry} \usepackage{minted} – LordAro Dec 4 '14 at 23:32
  • That preamble works for me. You might add a complete minimal document that reproduces the error to your question, or open a new question specifically about the \mintinline. It would also be good to see the commands you are using for compiling, and the error message. – G. Poore Dec 5 '14 at 0:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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