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 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.
(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
- sominted
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 he/she/it 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 my much more people, which means you can find much more resources in case of problems and more people able to help youlistings
causes more problems - hence more questions askedlistings
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)