Yesterday I found my old thesis and found out that there is a new version of minted (2.0+) which somehow don't want to work with my old thesis since all the listings were not highlighted.

Unfortunately there is in my opinion a problem which depends on the location of the \tikzexternalize command. If this command is located before \usepackage{minted} my listings won't get highlighted at all. Putting \usepackage{minted} before the \tikzexternalize works though. Using the old \usepackage{minted1} also works fine. So it seems to be a problem with minted 2.0+ only.

Here is a MWE for the problem (see commented lines):


\tikzset{external/system call={pdflatex --shell-escape -halt-on-error -interaction=batchmode -jobname "\image" "\texsource"}}

% Loading minted here and everything is fine


% Loading minted here will result in no highlighting


    \draw (0,0) --(1,2) -- (2,3) -- (1,0);

int main(int argc, char*argv[])
    (void) printf("Hello World\n");

    return EXIT_SUCCESS;


So my question: Is this behaviour normal or intended?

Some information about the setup I am using:

MikTeX version:   miktex-2.9.5721
Minted version:   2015/09/09 v2.1 Yet another Pygments shim for LaTeX
Python version:   Python 3.5.0
Pygments version: Pygments version 2.0.2, (c) 2006-2014 by Georg Brandl.

And for building my thesis I use (under windows 8)

pdflatex --shell-escape --enable-write18 mwe
  • I narrowed the issue down to this addition of minted: github.com/gpoore/minted/issues/73. If I comment this lines for detecting the tikzexternalize job everything works again. The \tikzexternalrealjob is probably set directly after \tikzexternalize and not only when the figures are externalized? Oct 1, 2015 at 10:52
  • I think you should file this as a bug report for minted. Oct 1, 2015 at 17:48
  • Geoffrey already reopened the above issue and will have a look at it. A workaround is to set \tikzexternalize as last command in the preamble. I also tried to find a permanent fix by not just looking if \tikzexternalrealjob is defined but also look into its content. But I wasn't successful yet. I think at least it is good that this problem can be found by using google now very easy. Unfortunately it took me one to two hours to find the cause for the non-highlighting problem in my two year old thesis template. Oct 2, 2015 at 21:40
  • Related: Minted caching in tikz externalize job Oct 2, 2015 at 23:23

1 Answer 1


I think I found a fix for the issue:

Simply exchange (in the minted.sty-file)

\ifcsname tikzexternalrealjob\endcsname


\ifcsname tikzifexternalizing\endcsname 
    % if \tikzexternalize is set before \usepackage{minted} this branch is used
    % the true branch of the \tikzifexternalizing will only be used if the tikz externalizing job is running at the moment
    % else this old code will be used which will definitely work in all other cases (when \tikzexternalize is set after \usepackage{minted})
    \ifcsname tikzexternalrealjob\endcsname

\tikzifexternalizing will only process the true-branch if the externalization job runs (according to the package documentation).

Maybe a fix can be achived by a more beautiful and more elegant coding, but it does the trick for me at the moment.


You must log in to answer this question.

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