如果我在 中有一个 pfgplot \only
,那么所有引用都会因某种原因而中断。特别是在以下 MWE 中。行引用在 I have 中显示为 ??,\only
但如果我将其注释掉,则会正常显示。
这是正常的吗?有办法解决吗?
\documentclass{beamer}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{frame}
This is the plot
\only<2> % If I comment this out, the reference apears correctly
{\begin{tikzpicture}
\begin{axis}
[xmin=-1,xmax=1] \addplot [mark=*, samples=100] { x^2 };
\label{line:tmp}
\end{axis}
\end{tikzpicture}%
My line is:~\ref{line:tmp}
}
\end{frame}
\end{document}
答案1
Bazinga :)\label<2>{line:tmp}
成功了!
\documentclass{beamer}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{frame}
This is the plot
\begin{onlyenv}<2>
\begin{tikzpicture}
\begin{axis}
[xmin=-1,xmax=1] \addplot [mark=*, samples=100] { x^2 };
\label<2>{line:tmp}
\end{axis}
\end{tikzpicture}%
My line is:~\ref{line:tmp}
\end{onlyenv}
\end{frame}
\end{document}