Open Bebotron opened 4 years ago
In
Chapter5.tex
, there are examples showing how tables with\label{tab:name}
can be used with\ref{tab:name}
to reference. That seems to work perfectly fine, but there is no example of doing it with figures. If you include\label{fig:somefig}
and\label{fig:somefig2}
to both first figures, and try to useFigure~\ref{fig:somefig}
andFigure~\ref{fig:somefig2}
in the main text, both reference Figure 5.1, instead of the expected Figure 5.1 and Figure 5.2.
@Bebotron Did you put the \label{fig:name}
directly after \caption{The caption of the figure.}
?
I have tried the following piece of code:
Refer Figure~\ref{fig:first} and Figure~\ref{fig:second}
\begin{landscape} % Require pdflscape and everypage packadge
\begin{figure}[h]
\centering
% will generate blank page if use full \linewidth
\includegraphics[width=.9\linewidth]{fig3}
\caption{Continues figures in landscape mode. (first)}
\label{fig:first}
\end{figure}
\begin{figure}[h]
\centering
\includegraphics[width=\linewidth]{fig4}
\caption{Continues figures in landscape mode. (second)}
\label{fig:second}
\end{figure}
\end{landscape}
and it works properly.
Great that fixed it! Seems a bit like unexpected behavior, but it works like a charm! Thanks!
@Bebotron
Actually, to reference figure/table number, \lable
must occur after the \caption
.
When declared outside, it will give the section number. To be completely safe, the label for any picture or table can go within the \caption{} command, as follows:
\caption{Close-up of a gull\label{fig:gull}}
Source: https://en.wikibooks.org/wiki/LaTeX/Labels_and_Cross-referencing
I have met similar problems before. I'm glad I could help.
Ooohh gotcha, this will save a lot of headaches in the future. Thanks!
In
Chapter5.tex
, there are examples showing how tables with\label{tab:name}
can be used with\ref{tab:name}
to reference. That seems to work perfectly fine, but there is no example of doing it with figures. If you include\label{fig:somefig}
and\label{fig:somefig2}
to both first figures, and try to useFigure~\ref{fig:somefig}
andFigure~\ref{fig:somefig2}
in the main text, both reference Figure 5.1, instead of the expected Figure 5.1 and Figure 5.2.