TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use pgfplots with externalization. When I try to include a macro that uses \ifthenelse, always the 'else' statement is being executed. When I switch off externalization, it works again. See this example:



% my new command
    % different title depending on argument:
    \addplot {x};

% begin of externalization
\tikzset{external/force remake}
% end of externalization


% use either of those to switch \ifthenelse on and off 
\tikzexternalenable  % now \ifthenelse is off
%\tikzexternaldisable % now \ifthenelse is on

% test my new command
\plotcmd{true} % should be titled 'true'
\plotcmd{false} % should be titled 'false'


Whats going wrong here?

share|improve this question
Seems to work for me: could we see the \listfiles output in your log? – Joseph Wright Dec 7 '11 at 19:21
you are correct, my example was wrong, ill renew it. – Hendrik Dec 7 '11 at 19:38
Your example doesn't compile for me, but fails with Argument of \boolean has an extra }.. I would have been surprised if this had worked, since you're trying to run a macro in your axis options. The example works fine if I use \ifthenelse{\boolean{#1}}{\pgfplotsset{title=true}}{\pgfplotsset{title=false}} before \begin{axis} in your command instead. – Jake Dec 8 '11 at 2:35

Jake's comment is the answer: the compilation failed. This can be verified by inspection of the <filename>-figure0.log .

The immediate cause for the failure is that \ifthenelse cannot be used in a place where keys are evaluated (because that command is not "expandable").

There are two ways to solve the problem:

  1. either by moving the \ifthenelse in front of the axis and inserting \pgfplotset into its body (as shown by jake)


  1. by moving the \ifthenelse into the argument for title. This is what I would suggest; it seems more local:

    % different title depending on argument:
    \addplot {x};

This does not explain why your experiment worked without externalization. From my point of view, it should never have worked ... in fact, on my computer, it does not work if I switch to \tikzexternaldisable.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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