Graphics, Figures & Tables\Ref and \label format

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
kees
Posts: 3
Joined: Wed May 27, 2009 2:43 pm

\Ref and \label format

Post by kees »

Hi all,

How can I change the numbering of my figures from "chapternr.sectionnr.figurenr" to simply "chapternr.figurenr"?
This cannot be very difficult. I have been googling for a while, but did not find a solution.
Thanks in advance!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Keta
Posts: 63
Joined: Tue Nov 25, 2008 1:00 pm

\Ref and \label format

Post by Keta »

What document class are you using? If I'm not mistaken, report and book classes both produce the numbering you want.

Anyway, check the following. It should renew the print format of the figure counter:

Code: Select all

\renewcommand{\thefigure}{\arabic{chapter}.\arabic{figure}}
If the figure counter is correctly defined, it will restart after each chapter.

For customizing figure and table captions, take a look at the caption package.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

\Ref and \label format

Post by localghost »

kees wrote:[...] How can I change the numbering of my figures from "chapternr.sectionnr.figurenr" to simply "chapternr.figurenr"? [...]
This is not the default setting of chapter based classes. Please provide a minimal working example (MWE) that reproduces this behaviour.

Best regards
Thorsten
aron.wahlberg
Posts: 2
Joined: Wed Jun 24, 2009 2:47 pm

Re: \Ref and \label format

Post by aron.wahlberg »

I have a similar problem with tables. The twist is that when I refer to my table in the text (using \ref{mytable}), I get the format chapternumber.sectionnumber, while the numbering by the \caption gives chapternumber.tablenumber. I want the latter in both cases. How to fix this?

The way it is now, I get the same number for different tables as long as they are in the same section, when I refer to them using \ref{mytable}.

I've tried with \renewcommand but that only changes the number by \caption, the number by \ref{} remains unchanged.

Aron
aron.wahlberg
Posts: 2
Joined: Wed Jun 24, 2009 2:47 pm

Re: \Ref and \label format

Post by aron.wahlberg »

My problem resolved when i put the label inside the caption:

\caption{Blabla. \label{myTable}}

Aron
Keta
Posts: 63
Joined: Tue Nov 25, 2008 1:00 pm

\Ref and \label format

Post by Keta »

aron.wahlberg wrote:My problem resolved when i put the label inside the caption:

\caption{Blabla. \label{myTable}}

Aron
Hi Aron,

What you were probably doing is putting the \label command before the caption. You don't need to write the label inside the caption, but after the caption:

\caption{Caption text.}
\label{mytable}
Post Reply