8

This question already has an answer here:

I have a document with a lot of tikzpicture made with pgfplots, most of them take data from files so the compilation may be very long. In order to have only a draft I would like to have blank images with same dimension of the full ones.

Until now I used a trick of having a tikzpicture with an empty axis environment of the same dimensions of the original one and with some if statements I included the blank or the full image like this:

\newcommand{\img}{Y} % immages Y(es) or N(o)
...
\begin{figure}
  \centering
  \ifthenelse{\equal{\img}{Y}}{%
    \input{Immagini/full.tex}}{%
    \input{Immagini/empty.tex}}
  \caption{caption}
\end{figure}

file full.tex

\begin{tikzpicture}
  \begin{axis}[height=9cm, width=.8\textwidth]
    \addplot table [x index=0, y index=2] {dati.dat};
  \end{axis}
\end{tikzpicture}

file empty.tex

\begin{tikzpicture}
  \begin{axis}[height=9cm, width=.8\textwidth]
  \end{axis}
\end{tikzpicture}

But today I read this question How I can speed up the compilation of a document with multiple images? and now I would like to know if there is a similar way to the draft option of the package graphicx that does the same thing with tikzpicture.

marked as duplicate by cmhughes, Paul Gaborit, mafp, T. Verron, Qrrbrbirlbel Jun 28 '13 at 14:59

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • There are a few related questions about this on the site e.g. tex.stackexchange.com/questions/111566/… if you search for tikzpicture draft you can see more. – percusse Jun 28 '13 at 12:18
  • 2
    Just to make sure: Have you thought about using the external library, which compiles your tikzpictures into external PDFs that then only have to be included in your final document? – Jake Jun 28 '13 at 12:40
  • @Jake Ok, with your suggestions I got the solution, can I answer to my own question? – Red Jun 28 '13 at 13:03
  • @Red: Sure! You just have to wait a day (I think) before you can accept the answer, but you can (and should) post the answer – Jake Jun 28 '13 at 13:09
5

A part of the total solution is to use the external library as suggested and then put the option draft to \documentclass[draft]{whatever}. But doing so the image is replaced by a box of fixed dimensions, not equal to those of the real image.

\documentclass[a4paper,draft]{article}
\usepackage{pgfplots}
\usepackage{lipsum}
\usepackage{tikz}
\usetikzlibrary{external}

\tikzexternalize

\begin{document}

\begin{figure}[h]
  \centering
  \input{anderlini_10.tex}
  \caption{caption of this beautiful image}
\end{figure}

\lipsum[1-2]

\end{document}

enter image description here

This happens because the external image created is not imported with \includegraphics, to correct this it is sufficient to add this line (\pgfkeys{/pgf/images/include external/.code=\includegraphics{#1}}) before \tikzexternalize. In this way we obtain the desired result:

enter image description here

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