I want to use todonotes in a document that also uses pgfplots, tikz spy and tikz external. Unfortunately, todonotes breaks the layout of pgfplots figures as illustrated by the following example:



  mode=list and make,
  % Does not help
  optimize command away={\todo}{1},

% Disable externalization for \todo in order to avoid compilation errors.



      spy using outlines={%
        connect spies,

      \coordinate (spyat) at (292,223);
      \coordinate (magat) at (150,90);

    \spy[thick] on (spyat) in node at (magat);

% Adding todo does not work
% Works!


This is how the figure looks like: Wrong

And this is how the figure supposed to look: Correct

One way to avoid the broken layout is either not to use todonotes or to disable externalization altogether. The latter is however not an option.

Is there any other way to overcome the problem?

1 Answer 1


Answering my own question. \pgfsyspdfmark written to the .aux file seems to be responsible for the broken layout. Hence, disabling its usage in externalized documents as follows


solves the problem. This check requires the ifthen package.

Alternatively, one can use the \tikzifexternalizing command, as suggested in the comments by Max Snippe:

  • 1
    You could probably also use \tikzifexternalizing{<true code>}{<false code>}.
    – Max
    Jul 22, 2018 at 8:44
  • True, this seems to work as well.
    – caustic
    Jul 22, 2018 at 9:45

You must log in to answer this question.

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