This example document:
\documentclass{article} \usepackage{tikz} \usetikzlibrary{external} \tikzexternalize% \begin{document} \begin{tikzpicture} \draw (0,0)--(1,1); \label{leg:test} \end{tikzpicture} \end{document}
write (in a current texlive 2015) this line to the aux-file:
\def \dpthimport {\newlabel {leg:test}{{}{\thepage }}}\dpthimport
As one can see \thepage is not expanded and so the label is useless.
After some thinking I realized that it is probably not a bug but a (difficult to implement) feature to get the pageref in this way. But I wonder why the external library goes to such length to move this useless commands to the main aux-file.
Thanks for the report.
You are right... and I have forgotten the issue. I remember that I was happy to report the references as such and accepted that page numbers failed to work.
In order to see that labels make sense even without page numbers, you should consider labels which have some value in themselfes like equation numbers or referenceable graphical material (pgfplots legends, colorbars, or plots).
A somewhat more sophisticated example would be
In this context,
\eqref
makes sense (and is correct) whereas\pageref
is broken.Last edit: Stefan Pinnow 2018-12-23
I believe that there are two choices to proceed:
1) ensure that no-one relies on the wrong page numbers (i.e. generate some error) or
2) fix it.
I believe that I could fix it if inject the page number into the read aux data at usage time, i.e. as soon as the graphics is reinserted into the main document. An early experiment resulted in correct page numbers.
Do you know if
\thepage
is the only macro related to page references? If so, I might be able to expand just this very macro and keep all other macros intact.Last edit: Stefan Pinnow 2018-12-23
The following snipped is just for me since I do not know if I can make this production ready.
My "early experiment" is to use
Last edit: Christian Feuersänger 2018-12-28