I'm trying to figure out why the externalization of tikzpictures does not work any more (used to).

I have the following in the preamble:

% \tikzexternalize[prefix=fig/ext/]

If I uncomment the second (to externalize all the plots and figures) line all the figures fail the externalization.

If the line is commented out (no externalization), the final pdf is generated without errors.

Unfortunately, I cannot recognize useful elements in the externalized log files.

Which is the best way to troubleshoot this? I suspect packages incompatibilities.

Can't post a MWE right away (will write one as soon as I am able to),

Here's a not-so-minimal non WE, reproducing the behavior described above:








        bibstyle     = ieee,
        citestyle    = numeric,
        isbn         = true,
        doi          = false,
        sorting      = nty,
        % sorting     = none,
        % sorting     = debug,
        url          = false,
        defernumbers = true,
        bibencoding  = utf8,
        backend      = biber

    % % do not externalize todonotes' graphics
    \usepackage{letltxmacro} % https://tex.stackexchange.com/a/115095/177


        % bookmarksopen=true
        % colorlinks,
            % Author={Alessandro Cuttin},
            Subject={PhD Thesis},
            % Title={Title to be defined},


    \hyphenation{a-chieved mil-li-me-ter-wave na-no-sat-el-lite}
    \newcolumntype{m}{>{$}c <{$}}
    % adapted from https://tex.stackexchange.com/a/36003/177
    \usepackage{ifmtarg}% http://ctan.org/pkg/ifmtarg
    \newcommand{\algtoprule}{\hrule height.8pt depth0pt \kern2pt} % Caption top horizontal rule+skip
    \newcommand{\algmidrule}{\kern2pt\hrule\kern2pt} % Caption bottom (or mid) horizontal rule+skip
    \newcommand{\algbottomrule}{\kern2pt\hrule\relax}% Algorithm bottom rule
        {\addcontentsline{loa}{figure}{\protect\numberline{\thealgorithm}{\ignorespaces #2}}}
        {\addcontentsline{loa}{figure}{\protect\numberline{\thealgorithm}{\ignorespaces #1}}}%
      \textbf{\fname@algorithm~\thealgorithm}\ #2\par % Caption
    % https://tex.stackexchange.com/a/68310/177 and https://tex.stackexchange.com/a/10131/177
    % \let\runauthor\@author

    \chapter{Modern random access methods}
        \subbottom[ \label{fig:aloha-max-thr}]{%
        \caption{The Aloha System: \subcaptionref{fig:aloha-pac-sch} schematic of the Aloha communication multiplexing \cite{Abramson1970}, and \subcaptionref{fig:aloha-max-thr} network throughput.}

                ymax = 0.2,
                ymin = 0,
                xmin = 0,
                xmax = 2,
                ytick distance = 0.1,
                grid                            = major
            % throughput upper bound of Aloha
            \addplot [
            {x * exp(-2*x};
% \input{set/tufte-like-plots}

% toggle the following lines to prevent tikz plots compilation every time - always use after loading pgfplots package

% memoir settings
\newsubfloat{figure}% Create subfloat in figure environment



% special things for a draft document
    \linespread{1.3}        % more linespread for showkeys
    \makeevenfoot{simple}{}{\texttt{Draft: \today}}{ }
    \makeoddfoot{simple}{}{\texttt{Draft: \today}}{}
    % \usepackage{showframe}
% perhaps special things for a non-draft document

% \includeonly{con/annotations,con/lit-rev,con/introduction,con/jsac}

It seems that externalized figures are not created. I suspect a package incompatibility, and will try to comment out the packages one by one.

  • 5
    It shouldn't be hard to make an MNWE if any figure at all causes the failure. What error do you get? I.e. exact message? This will direct you to a per-figure log file. What does that log say? Did you remember shell-escape? Does the appropriate directory hierarchy exist?
    – cfr
    Commented Dec 27, 2017 at 1:28
  • 4
    Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See minimal working example (MWE). Commented Dec 27, 2017 at 2:07
  • 1
    @HenriMenke Are you going to answer the question ?
    – percusse
    Commented Dec 27, 2017 at 9:06
  • 1
    @HenriMenke You are not the judge of that. If you are not going to answer the question don't engage and possibly annoy people with unnecessary policing.
    – percusse
    Commented Dec 27, 2017 at 9:11
  • 2
    You asked what is the best way to troubleshoot. Well in my opinion the most important this is no to waste too much time with random searches and speculation. You can google for 30 minutes hoping to find the red button but then you should stop and switch to a systematic debugging. And the first step of systematic debugging in tex is creating an mwe. Beside this I agree with Henri that your question as it is can't be answered, the Runaway argument? is certainly a problem and should be corrected but it is unclear if is also the source of your other problem. Commented Dec 27, 2017 at 15:59

2 Answers 2


It is not a pgfplots problem and also not directly cause by pdflscape. Imho it is a problem of tikzscale.

tikzexternalshared.code.tex calls at the end in \AtBeginDocument (after tikzscale has added all its code) if it detects pdflscape this here:

            optimize command away=\landscape,
            optimize command away=\endlandscape

The problem is that this code not only adds the new commands to the internal code of optimize command away but also reapplies older code and as \includegraphics is in the list it breaks.

This document reproduce the problem (\jobname-figure0.pdf shouldn't exist):

  \draw (0,0) rectangle (1,1);



           external/optimize command away=\blub,

%  work around, uncomment to avoid the error:
% \tikzset{%
%         external/optimize/install/.code={},
%         }




A work around is to disable the optimization or at least to remove \includegraphics from the list.

  • it is probably like you say, because I'm again at the starting point, even if removing pdflanscape seemed to work at first. How do I disable the optimization? Commented Dec 29, 2017 at 21:40
  • My example shows a work-around. Commented Dec 29, 2017 at 21:43
  • I tried it, but didn't work :( Commented Dec 29, 2017 at 21:52

Comment out \usepackage{pdflscape}. Sorry, I don't have an explanation.


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