1

Consider this MWE:

% to rebuild:
% rm test-testplot.pdf ; pdflatex -shell-escape test.tex

\RequirePackage{filecontents}
\begin{filecontents*}{testplot.tikz}
\begin{tikzpicture}
\begin{axis}[
  width=500pt,
  height=195pt,
  clip=true,
  axis x line=middle,
  axis y line=middle,
]
\end{axis}
\end{tikzpicture}
\end{filecontents*}

\documentclass[11pt]{book}

\usepackage[
  paperwidth=15cm,
  paperheight=20cm,
  outer=2.5cm,
  inner=2.5cm,
  top=2.5cm,
  bottom=2.5cm
]{geometry}
\usepackage[a4,cam,center]{crop}

\usepackage{tikz,pgfplots,adjustbox,lipsum}
\usetikzlibrary{external}
\tikzexternalize[] %activate!

\begin{document}
\lipsum[1]

\tikzsetnextfilename{\tikzexternalrealjob-testplot}
\begin{figure}[!ht]
\begin{adjustbox}{width=\textwidth}%
\input{./testplot.tikz}
\end{adjustbox}
\caption{Just trying to insert a plot picture here}
\label{fig:test}
\end{figure}

\end{document}

The result is a bit weird, since the cropmarks from the top of the actual page are captured on PDF of the tikz image containing pgfplots! At a closer look (by selecting around the area in a PDF viewer; click for full res):

test-sel-pdf.png test.png

... it turns out also the crop package signature is captured, though hidden. The entire page, including the externalized pdf, is shown on the right.

What did I do wrong this time, and how can I externalize this tikz pgfplot without capture the crop marks? (needless to say, I'd want the externalization done from the main document, so all page size, font etc changes are taken into account).

EDIT: I've been using tikz externalizing with several other tikz images in the same document (which however, didn't use pgfplots), and there was no problem with them, as far as I could see... but maybe I should re-check

1

Suppress the loading of crop when the images are created with \tikzifexternalizing: (Don't forget to delete the old pictures or to force the recreation)

\documentclass[11pt]{book}

\usepackage[
  paperwidth=15cm,
  paperheight=20cm,
  outer=2.5cm,
  inner=2.5cm,
  top=2.5cm,
  bottom=2.5cm
]{geometry}


\usepackage{tikz,pgfplots,adjustbox,lipsum}
\usetikzlibrary{external}
\tikzexternalize[] %activate!
\tikzifexternalizing{}{\usepackage[a4,cam,center]{crop}}
\begin{document}
\lipsum[1]

\tikzsetnextfilename{\tikzexternalrealjob-testplot}
\begin{figure}[!ht]
\begin{adjustbox}{width=\textwidth}%
\input{./testplot.tikz}
\end{adjustbox}
\caption{Just trying to insert a plot picture here}
\label{fig:test}
\end{figure}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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