I'm attempting to dynamically reference an Equation number in tikzpicture (via \eqref or \ref) using the following:
% Filename: Test.tex (say)
\documentclass{article}
\usepackage{latexsym,amsfonts,amsthm,amssymb,amsmath}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
% Due to a large number of Tikz plots
\usepgfplotslibrary{external}
\tikzexternalize
\begin{document}
Here is an equation:
\begin{equation}
\label{eqOne}
y = x^2
\end{equation}
that I'd like to appear in TikZ.
\begin{figure}[htbp]
\centering
\begin{tikzpicture}
\begin{axis}[%
xmajorgrids,
ymajorgrids
]
\addplot[const plot,color=red,solid,line width=0.5pt] plot table[row sep=crcr] {%
0 0\\
1 1\\
2 4\\
3 9\\
};
]
\node[right, align=left, inner sep=0mm] at (axis cs:2,4) {Equation \eqref{eqOne}};
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}
but this won't work via pdflatex -shell-escape Test.tex. The output generated shows 'Equation (??)'
By trial and error, dynamic referencing seems to only work without \usepgfplotslibrary{external} and \tikzexternalize, but I need these two lines due to the number of TikZ plots that I have.
Is there a way around this dynamic referencing problem; perhaps I'm going about this the wrong way?
Many thanks!
pdflatextwice? – Peter Grill Jun 08 '15 at 20:30