Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

In my document I use todonotes and TikZ/pgfplots. After activating the externalization in TikZ I realized that todonotes are all exported as well (because they are based on TikZ).

This behaviour is inconvenient, it would be much better for me to tell tikz-external to ignore all \todo.

I know I can generally disable the externalization with \tikzset{external/export=false} and turn it on only for selected plots, but the inverse would be more convenient.

share|improve this question
2  
At the start of the document say \tikzexternaldisable, and then wrap the normal figures in \tikzexternalenable {your tikz code} \tikzexternaldisable. I haven't tested it, but that should be possible, no? Or wrap the todo macros in a personal macro using the reverse. I don't use todonotes, so I can't say how that would look. –  Psirus Jan 27 '12 at 11:59
    
@Psirus: I'm not experienced in TikZ, but wrapping the todo macro sounds better because you only have to do it once in the preamble and can easily change it later. –  doncherry Jan 27 '12 at 12:08
    
I agree. Now that I read it again, my first suggestion is already covered in the question... –  Psirus Jan 27 '12 at 12:13
    
Would \newcommand{\xtodo}[1]{{\tikzexternaldisable\todo{#1}}} or similar not do the trick? –  Martin Scharrer Jan 27 '12 at 12:25
1  
The documentation of the package now mentions the same solutions suggested here, namely \newcommand{\ruggedtodo}[2][]{\tikzexternaldisable\todo[#1]{#2}\tikzexternalena‌​ble} –  papabravo Feb 15 '13 at 10:10
show 1 more comment

3 Answers

up vote 16 down vote accepted

I had this very problem a while ago, just for the \todo command (I never use \missingfigure). Here's how I fixed it (place this in your preamble, somewhere after todonotes and tikz/pgfplots is called):

\makeatletter
\renewcommand{\todo}[2][]{\tikzexternaldisable\@todo[#1]{#2}\tikzexternalenable}
\makeatother

Now, \todo will be ignored by the externalization process.

Hence, for the \missingfigure command you need

\makeatletter
\renewcommand{\missingfigure}[2][]{\tikzexternaldisable\@missingfigure[#1]{#2}\tikzexternalenable}
\makeatother
share|improve this answer
    
Your redefinition of the \missingfigure command does not work, as there is no \@missingfigure in the package. I am not sure though how to do it differently; trying to use \let\oldmissingfigure\missingfigure causes LaTeX to complain about TeX capacity being exceeded. –  mSSM Jul 18 '12 at 15:05
add comment

For me neither of the proposed solutions worked. Maybe it is platform-dependent, taking into consideration the significant number of up-votes in favor of the accepted answer.

However, mSSM's approach with \let was close. The reason for it not to work properly with \missingfigure is that the latter consumes an optional argument. The simple \let fails to copy all required information to a new macro. According to this piece, one should use the letltxmacro package. Eventually, my working version is:

\usepackage{letltxmacro}

\LetLtxMacro{\oldmissingfigure}{\missingfigure}
\renewcommand{\missingfigure}[2][]{\tikzexternaldisable\oldmissingfigure[{#1}]{#2}\tikzexternalenable}

\LetLtxMacro{\oldtodo}{\todo}
\renewcommand{\todo}[2][]{\tikzexternaldisable\oldtodo[#1]{#2}\tikzexternalenable}
share|improve this answer
add comment

I have played around with \missingfigure, but a simple \renewcommand{\missingfigure}... will not work, as given in the answer by @Frits.

The only solution I found was defining a new command:

\newcommand{\extmissingfigure}[2][]{\tikzexternaldisable\missingfigure[#1]{#2}\tikzexternalenable}

Working with \let, i.e.:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{external}
\usepackage{todonotes}

\tikzexternalize

\let\oldmissingfigure\missingfigure
\renewcommand{\missingfigure}[2][]{\tikzexternaldisable\oldmissingfigure[#1]{#2}\tikzexternalenable}

\begin{document}

\missingfigure{Ah!}

\end{document}

unfortunately raises an error:

! TeX capacity exceeded, sorry [input stack size=5000].
<to be read again> 
\tikzexternal@orig@tikzfadingfrompicture 
l.18 \missingfigure{Ah!}
share|improve this answer
    
Finally, I managed to overcome the issues you encountered. You may want to have a look at my answer. –  rook May 19 '13 at 15:30
add comment

Your Answer

 
discard

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.