I'm currently writing a quite complex document with a lot of graphics created using TikZ. Hence I decided to put all graphics into one big file called tikz.tex creating a multiple page PDF with one tightly cropped page per graphic.
The tikz.tex (which I compile separately) generates a clean PDF and .aux file.
Here is a minimal version of it:
\documentclass{article}
\usepackage{tikz}
\usepackage[pdftex,active,tightpage]{preview}
\tikzset{
%... my tikzset ...
}
\begin{document}
\begin{preview}
\label{pic1}
\begin{tikzpicture}
%... tikz ...
\end{tikzpicture}
\end{preview}
\begin{preview}
\label{pic2}
\begin{tikzpicture}
%... tikz ...
\end{tikzpicture}
\end{preview}
\end{document}
the minimal version of my Master file
\documentclass[]{article}
\usepackage {xr}
\usepackage []{hyperref}
\externaldocument[tikz:]{../Bilder/tikz}
\begin{document}
\input{../Kapitel/Kapitel_1}
\end{document}
a minimal version of the actual chapter, which is included in the master file, would look similar to this
\chapter{name}
\begin{figure}[htb]
\includegraphics[page=\pageref{tikz:pic2}]{../Bilder/tikz.pdf}
\end{figure}
this returns:
! Missing number, treated as zero. <to be read again> \protect l.12
...KOS},width=\textwidth]{../Bilder/tikz.pdf} A number should have
been here; I inserted `0'.
The idea was to use the labels in my main document to refer to the correct page number. of course i could just hard code the page number but since I intend to use this tikz file for quite some time I'd prefer referencing the page number by \pageref or something similar. I do not want to split the PDF into single files.
It works if my chapter looks like this. in this case the \pageref is shown correct
\chapter{name}
\begin{figure}[htb]
\includegraphics[page=2]{../Bilder/tikz.pdf}
\end{figure}
correct page number of pic 2 is \pageref{tikz:pic2}
Any ideas how to get \includegraphics[page=\pageref{...}] working?
Thanks a lot in advance!
\includenot\input. See e.g. When should I use \input vs \include? for more details. – Martin Scharrer Oct 13 '11 at 18:16