# Incompatibility of Tikz Externalize and Pdfpages [duplicate]

I am writing my final thesis and have come to an issue with Tikz an pdfpages. I had this issue before on an earlier work and hoped it would be fixed by using updated packages, but it did not.

My document compiles just fine before I include an external PDF file, in this case its an A4-PDF with my thesis task. Some images and plots in my work are build with Tikz and I use tikzexternalize to limit memory use. As long as all my Tikz images are compiled before I put

\includepdf[pages=-]{ThesisTask.pdf}


in the document, it works fine. However, if I change code in one of my externalized tikz images (and they need to be recompiled), I get an error that the corresponding file could not be compiled.

I know a MWE would be nice, but I wanted to go without, maybe someone knows a good way to work around or fix it right away. If not, I will add an MWE tomorrow.

My workaround in my earlier thesis was to include this pdf at the very last day as very last action. This would still be possible, but its annoying me big time. Thanks.

//edit, I hope this works as a MWE:

\documentclass{article}
\usepackage{standalone}
\usepackage{pgfplotstable}
\usepackage{tikz}
\usepackage{pdfpages}
\usepgfplotslibrary{external}
\newcommand{\externaldirectory}{ExtFigures/}%for externalisation
\tikzexternalize[prefix=\externaldirectory]
\begin{document}
Here comes my great diagram:
\begin{figure}[ht]
\centering
\input{diag-Releases}
\end{figure}
And there it is again, this time as PDF
%\includepdf[pages=-]{DiagramPDF.pdf}%include this after first compilation add a PDF file with this name to the current folder
\end{document}


The diagram looks like this

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis background/.style={draw=black,line width=0.95pt},
width=10cm, height=4.5cm,
ybar,
symbolic x coords = {1960er, 1970er, 1980er, 1990er, 2000er, 2010-},
xtick=data,
tick label style={font=\footnotesize},
nodes near coords,
ymin = -1,
ymax = 220,
tick align=inside,
ylabel={Anzahl},
ylabel near ticks]
(1990er,79)(2000er,128)(2010-,157)};
\end{axis}
\end{tikzpicture}
\end{document}


Add a folder called ExtFigures to your working directory. Then compile w/o the pdf include line, then with. Until here it should work. Then, delete content of the ExtFigures folder (which causes Tikz to recompile the image) and see the error.

• Add a MWE. One needs code to test the issue. Mar 14, 2018 at 18:34
• Added a MWE. I hope it works, pls excuse formatting.
– Atd
Mar 14, 2018 at 19:03
• Mar 14, 2018 at 19:05
• Wow. Perfect! Thank you ... Sry I didnt find that on my own! Can you add this as an answer so I can accept it as solved?
– Atd
Mar 14, 2018 at 19:10
• I marked it as duplicate. Mar 14, 2018 at 19:24