
這是我的 MWE:
\documentclass{book}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}
\usepackage{subfig}
\usepackage{titletoc}
\begin{document}
\begin{figure}[h!]
\begin{center}{
\begin{tikzpicture}
\begin{axis}
\addplot[domain=0:360]({cos(x)},{sin(x)});
\end{axis}
\end{tikzpicture}
\caption{This was generated with PGFPlots.}
}
\end{center}
\label{fig-circle}
\end{figure}
See figure~\ref{fig-circle}.
\begin{figure}[h!]
\begin{center}{
\includegraphics{header.png}
}
\end{center}
\caption{This was read from a PNG file.}
\label{fig-image}
\end{figure}
See also figure~\ref{fig-image}.
\end{document}
編譯如下:
使用article
文件類別也會導致「參見圖??」。正在列印。
我 100% 確定我已經使用 PGFPlots 建立了圖形,並在先前的文本中引用了它們。我不知道這次出了什麼問題。
這是怎麼回事?
titletoc
(為了獎勵積分,如果我刪除包和/或包,為什麼我的編譯器會導致錯誤subfig
?我很確定它不需要其中任何一個來編譯該 MWE。我也很確定我'以前我使用TeXShop 4.68 編譯過一些東西,如果這有什麼區別的話。
答案1
我不太明白你的問題,但顯然你對標籤參考 1有\label{fig-circle}
問題。不要忘記編譯兩次。\caption{This was generated with PGFPlots.}
\caption{This was generated with PGFPlots.}\label{fig-circle}
答案2
好吧,我正在嘗試放置\label{fig-circle}
,似乎將其放置在center
環境中(即在我的 MWE 中其位置上方兩行)可以解決問題。不知道為什麼這很重要。