Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Figure \label and \ref mismatch

277 views
Skip to first unread message

Arcady Genkin

unread,
Jan 30, 2001, 9:46:59 AM1/30/01
to
Given the following snippet of LaTeX code, I get a dissagreeing
numbers between the \ref and \label for the figure.

In particular, the subsection turns out to be numbered 2.2.1, and the
figure turns out to be numbered 1. However in the text in the end of
the paragraph I'm getting "... visualized in Figure 2.2.1." whereas it
should be "... Figure 1.". I have rerun LaTeX numerous times on the
file, so this is not a question of running it twice to get references
right.

,----
| \subsubsection{Combined Whitebox-Blackbox Approach}
| \label{sec:test_approach}
|
| [snip the paragraph text]
| This mechanism is visualized in Figure \ref{fig:tstrat}.
|
| \begin{figure}[htbp]
| \begin{center}
| \shadowbox{\resizebox{5cm}{!}{\includegraphics{test_strategy.eps}}}
| \label{fig:tstrat}
| \caption{Combination of blackbox and whitebox testing strategies.}
| \end{center}
| \end{figure}
`----

So it seems that LaTeX thinks that by \label{fig:tstrat} I label
the current section, not the figure. How would I rectify this?

Many thanks for any ideas,
--
Arcady Genkin
Don't read everything you believe.

Frank Crawford

unread,
Jan 30, 2001, 9:57:59 AM1/30/01
to
go to any search engine, search for

label caption figure

you will find that this is one of the most asked latex questions ever. The
solution to your problem is:

you cannot put the \label line before the \caption line!

it's good habit then to write

\begin{figure}[options]
\caption{mycaption}\label{mylabel}
\etc...
or, some people like

\begin{figure}[options]
\caption{\label{mylabel} mycaption}
\etc...

Thomas Lotze

unread,
Jan 30, 2001, 10:01:49 AM1/30/01
to
Arcady Genkin wrote:
>
> So it seems that LaTeX thinks that by \label{fig:tstrat} I label
> the current section, not the figure. How would I rectify this?

Put the \label after the \caption.

Cheers, Thomas

--
Thomas Lotze - thomas.lotze@gmx.<CUT-IT>.net

http://www.thomas-lotze.de http://www.bannertausch-b150.de
http://thestories.cjb.net

Maurizio Loreti

unread,
Jan 30, 2001, 9:54:51 AM1/30/01
to Arcady Genkin
Arcady Genkin <a.ge...@utoronto.ca> writes:

> Given the following snippet of LaTeX code, I get a dissagreeing
> numbers between the \ref and \label for the figure.

> ...


> | \label{fig:tstrat}
> | \caption{Combination of blackbox and whitebox testing strategies.}
> | \end{center}

> ...

Put the \label AFTER the \caption and Read The Fine Manuals.

--
Maurizio Loreti http://www.pd.infn.it/~loreti/mlo.html
Univ. of Padova, Dept. of Physics - Padova, Italy lor...@pd.infn.it

The instructions said to use Windows 98 or better - so I installed FreeBSD.

0 new messages