\ref 不使用 tikz 和外部化 lib

\ref 不使用 tikz 和外部化 lib

可能的重複:
為什麼環境的標籤必須出現在標題之後?

我正在使用tikz它的外部化庫。我使用以下編碼風格創建圖形:

\begin{figure}
\centering
\begin{tikzpicture}
  code code code..
\end{tikzpicture}
\label{fig:label}
\caption{Blah blah blah text.}
\end{figure}

當我使用\ref{fig:label}它時,它不會顯示正確的數字。另一個值得注意且奇怪的行為是數字的格式為例如 5.2.1 而非 5.2;有人遇過這個嗎?

另外,透過嘗試創建一個 MWE,我甚至無法讓這個東西出現。我並不是想做複雜的事情,只是想說「在圖中xx......」。無論如何,這是不工作的 MWE:

\documentclass[a4paper,10pt]{report}
\usepackage{tikz} %pgf-tikz pakcage
\usepackage{pgfplots}
\usepackage{hyperref}

\hypersetup{
    colorlinks=true,linkcolor=blue,linktocpage,bookmarksopen=true
}

\begin{document}

\begin{figure}
\begin{tikzpicture}

\draw[fill = blue,fill opacity = 0.3](0,2) rectangle (1.5,3.5);
\draw[fill = yellow,fill opacity = 0.3](0.5,2.5) rectangle (1,3);

\draw[->] (0.75,0.75) -- (0.75,2.75);
\end{tikzpicture}
\label{fig:stuff}
\end{figure}

Hello \ref{fig:stuff} world
\end{document}

答案1

你應該在標題後面加上圖形標籤

相關內容