55

While I'm switching from minted to listings, I would like to ask you for this comparison.

The following is what it comes to my mind till now:

Eventually, which are the pros and cons of these two packages?

12
  • 1
    As far as I know, minted needs to be run with -shell-escape, depending on the situation this could be a con. Aug 31, 2017 at 12:47
  • I've never used `minted' but seen some of the output, which is rather hard to modify later on without running it throuygh the external stuff again.
    – daleif
    Aug 31, 2017 at 13:05
  • 1
    I found minted never really convincing, but that's a personal opinion.
    – user31729
    Aug 31, 2017 at 14:58
  • 6
    I suppose one benefit of Pygments, and therefore of minted, is, to quote pygments.org: "a wide range of over 300 languages and other text formats is supported" Aug 31, 2017 at 15:04
  • 1
    @TorbjørnT. You could write an answer in minted defence, since till now it seems people prefers listings, thank you!
    – CarLaTeX
    Aug 31, 2017 at 15:08

2 Answers 2

43

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 difference alone.

  • minted is more fiddly to set up (you need pygments and python to be installed and for tex to find them)

  • minted needs (at some point in the processing) -shell-escape to allow access to the shell. Note that recent versions do not require shell access in final versions of the document, so you can submit to journals etc a source that does not require -shell-escape but uses the previously generated files from an earlier cached run.

  • the pygmentize parsing library is far more extensive and expressive than the simple keyword detection in listings so the language specific support is much greater in minted.

  • pygmentize is used by many other systems and produces output in forms other than Tex (notably HTML/CSS). For example it is used by the trac svn/wiki system and so code can be typeset with minted using the same highlighting rules as used on the other systems.

  • as most of the real work in minted is in pygmentize (python) it is somewhat less easy to customize just from TeX, but on the other hand if you do customize the pygments lexer for a specific language it is usable in contexts other than TeX.

1
  • 2
    Great answer, thank you! The fact that the pygments lexer for a specific language is usable in contexts other than TeX is undoubtedly a plus of minted.
    – CarLaTeX
    Aug 31, 2017 at 15:43
22

(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 allow -shell-escape - so minted cannot be used at all.

  • even if -shell-escape is possible it may be undesirable to use it due to security concerns.

  • In my opinion -shell-escape should not be used by default and only activated for documents which need it - this creates additional hassle to compile minted documents.


Relying on external tools makes the document also less portable. If you sent it to a friend/colleague/... chances are that they cannot compile the document. With the exception of outdated package versions, listings documents should be portable.


Not sure how the following situation is to be interpreted: There are 2,288 listings vs. 467 minted questions on this site. This could either mean

  • listings is used by much more people, which means you can find much more resources in case of problems and more people able to help you

  • listings causes more problems - hence more questions asked

  • listings is just more customisable or has more possibilities, thus more possible questions to ask.

Please decide yourself if this point is a pro or a con.


Pro for minted: the maintainer is a user TeX.Stackexchange.

(I don't say this is not true for listings, I just don't know)

4
  • I ran into exactly the -shell-escape unavailability problem with minted when submitting papers to arXiv, so made a very small script which uses Pygments to pre-generate embeddable .tex files from sources, and a .sty file containing the formatting macros. Maybe useful: pastebin.com/7g9isfLr Sep 5, 2017 at 20:23
  • @andybuckley Would you like to convert your comment to an answer to tex.stackexchange.com/questions/372930/…? This will increase the visibility and might help future users with the same problem. Sep 5, 2017 at 20:39
  • Well it's not really an answer to the question! Will see if I can find a "how can I run minted without shell-escape?" question to post this as an answer to! Sep 5, 2017 at 20:44
  • 2
    @andybuckley if you don't find the question for your answer, just write it! It's not a problem: tex.stackexchange.com/help/self-answer
    – Ignasi
    Sep 6, 2017 at 7:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .