What is the easiest way to control figure numbering?

6,871 views
Skip to first unread message

Caboose

unread,
Sep 7, 2009, 1:33:10 PM9/7/09
to LaTeX Users Group
Hello, I have a long document with several chapters with only a couple
of figures in it. Rather than having figure 1.1, figure 2.1 etc I
would like to just have figure 1, figure 2 and so on.

Is the chngctr package (mentioned here: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=running-nos)
really the easiest way to do this?

jon

unread,
Sep 7, 2009, 2:12:47 PM9/7/09
to LaTeX Users Group
how much easier could this get:

\usepackage{chngcntr}
\counterwithout{figure}{chapter}

..? (i guess if you used memoir, you wouldn't even have to load the
package.)

cheers,
jon.

dvd7587

unread,
Sep 10, 2009, 6:48:38 AM9/10/09
to LaTeX Users Group
think i can post here...
i've got a little problem with referring to figures...

i used a code like this:

\begin{figure}
\begin{tikzpicture}
...
\end{tikzpicture}
\caption{Some figure}
\label{figurelabel}
\end{figure}

and then when i want to refer to that figure, i used the

\ref{figurelabel}

to get the number of the figure and the link in the final document.

but after building, i faced this problem: the number reported is not
the figure number but the section (or subsection in other cases)
number. however, the link links me still to the right point of the
document, but i think it is normal cause it does not refer to the
figure but to the place where the label is...

i thought to manage this numbers manually once the document is ready-
to-print, but if anyone can suggest a method to do this automatically,
i will be grateful

thank you!

Seamus

unread,
Sep 10, 2009, 8:25:30 AM9/10/09
to LaTeX Users Group
Try swapping the \label and \caption commands around. That is, put
\caption BELOW \label. I had a similar problem and that simple
manipulation solved it...

Ariovaldo V Garcia

unread,
Sep 10, 2009, 8:28:03 AM9/10/09
to latexus...@googlegroups.com
Put the \label{} inside the \caption{} command..

That is:

...
 \end{tikzpicture}
 \caption{ Some figure \label{figurelabel} }
  \end{figure}

Ariovaldo

dvd7587

unread,
Sep 10, 2009, 10:33:00 AM9/10/09
to LaTeX Users Group
thanks man, this works! i had already tried to put the label above and
belw the caption, but didn't work... probably the numbering is made
during caption so...

thanks again to both of you...

Ariovaldo V Garcia

unread,
Sep 10, 2009, 10:48:04 AM9/10/09
to latexus...@googlegroups.com
Ok

I read in some place that this is an old bug of latex that never was fixed.  I really don't know if we can call it a bug. Sometimes the numbering is correct.  Putting the label inside the caption it always works!

Regards

Ariovaldo

Seamus

unread,
Sep 10, 2009, 11:51:38 AM9/10/09
to LaTeX Users Group
That's weird. I have my labels AFTER my captions and everything works
fine. I wonder why that didn't work for you?

On Sep 10, 3:48 pm, Ariovaldo V Garcia <garcia...@gmail.com> wrote:
> Ok
> I read in some place that this is an old bug of latex that never was fixed.
>  I really don't know if we can call it a bug. Sometimes the numbering is
> correct.  Putting the label inside the caption it always works!
>
> Regards
>
> Ariovaldo
>

Ariovaldo V Garcia

unread,
Sep 10, 2009, 1:08:51 PM9/10/09
to latexus...@googlegroups.com
Well, this is a known issue. A google search with the words "\label inside \caption"
(without the (") ) give many results. One of them:


where you have:

"Warning: If you want to label a figure so that you can reference it later, you have to add the label after the caption (inside seems to work in LaTeX 2e) but inside the floating environment. If it is declared outside, it will give the section number. If the label picks up the section or list number instead of the figure number, put the label inside the caption to ensure correct numbering."..

Ariovaldo

dvd7587

unread,
Sep 11, 2009, 3:47:15 AM9/11/09
to LaTeX Users Group
same thing with tables.... it's probably sort of a bug for all
floating objects....

On Sep 10, 7:08 pm, Ariovaldo V Garcia <garcia...@gmail.com> wrote:
> Well, this is a known issue. A google search with the words "\label inside
> \caption"
> (without the (") ) give many results. One of them:
>
> http://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions#Label...
>
> where you have:
>
> <http://dcwww.camd.dtu.dk/~schiotz/comp/LatexTips/LatexTips.html>*"Warning:* If
> you want to label a figure so that you can reference it later, you have to
> add the label *after the caption* (inside seems to work in LaTeX 2e)
> but *inside
> the floating environment*. If it is declared outside, it will give the
> section number. If the label picks up the section or list number instead of
> the figure number, put the label inside the caption to ensure correct
> numbering."..
>
> Ariovaldo
>

luis

unread,
Sep 12, 2009, 5:16:02 AM9/12/09
to LaTeX Users Group
I actually never place the \label{} inside the \caption{}. You just
need to tell LaTeX that it is a figure label, i.e. \label
{fig:figurelable} or \label{tab:tablelabel} for tables. That should
work outside of \caption{} (but inside \begin{figure} \end{figure} or
table).
HTH
Luis

Seamus

unread,
Sep 12, 2009, 6:50:43 AM9/12/09
to LaTeX Users Group
I don't think that is true. the "fig:" thing is purely conventional.
That's for your own convenience. LaTeX doesn't pick up on that
information at all.

dvd7587

unread,
Sep 12, 2009, 7:45:21 AM9/12/09
to LaTeX Users Group
me neither...it would be like a \label[fig]{something} otherwise....

dvd7587

unread,
Sep 13, 2009, 4:44:21 PM9/13/09
to LaTeX Users Group
i can confirm that the environment that generates numbers is the
caption. just try to insert more captions in the same figure: it will
generate more than one figure number...

James McElhannon

unread,
Sep 14, 2009, 4:17:22 PM9/14/09
to LaTeX Users Group
Hi,

I'm having trouble with the "newlistof" and memoir. Memoir documentation
says it emulates tocloft, but I can't get it to work.

Below is a minimal example. If I change the document class to article and
include tocloft, then it works as expected. If I change the document class
to memoir, whether or not I include tocloft, then it fails with "Undefined
control sequence \listofJamesA".

When I look in the log for the memoir version, it says "Package tocloft
[2008/07/23] emulated by memoir".

Ideas?
-----------
%%\documentclass{article}
%%\usepackage{tocloft}
\documentclass{memoir}
\newcommand{\jamesName}{List of James}
\newlistof{jamesA}{jamesB}{jamesC}
\begin{document}
\tableofcontents
\listofjamesA
\section{x}

\addcontentsline{jamesB}{section}{hi}
x

x

\end{document}
-----------

Thanks...
James

Reply all
Reply to author
Forward
0 new messages