Graphics, Figures & Tablesabout figure and table numbering.

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
sds
Posts: 6
Joined: Sun Nov 14, 2010 6:36 pm

about figure and table numbering.

Post by sds »

Currently, my figures and tables are numbered according to chapter.section order, like

figure 1.1.1
figure 1.2.1
figure 1.2.2
figure 2.1.1
...

But I want them to be numbered only in terms of chapter, sth like:

figure 1.1
figure 1.2
figure 1.3
figure 2.1
...

How should I do? It should have some command to do this. Unfortunately, I did not figure it out. Any hint? Thank you very much for your time.
Last edited by sds on Tue Nov 16, 2010 10:00 pm, edited 1 time in total.

Recommended reading 2024:

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

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

meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

about figure and table numbering.

Post by meho_r »

Try this:

Code: Select all

\documentclass{report}

\renewcommand{\thefigure}{\arabic{chapter}.\arabic{figure}}

\begin{document}

\listoffigures

\chapter{A chapter}

\section{A section}

Some text\ldots

\begin{figure}[h]\centering
\rule{5cm}{2ex}
\caption{A figure}
\end{figure}

\begin{figure}[h]\centering
\rule{5cm}{2ex}
\caption{Another figure}
\end{figure}

\chapter{Another chapter}

\section{Another section}

Some text\ldots

\begin{figure}[h]\centering
\rule{5cm}{2ex}
\caption{One more figure}
\end{figure}

\begin{figure}[h]\centering
\rule{5cm}{2ex}
\caption{And the last figure}
\end{figure}

\end{document}
sds
Posts: 6
Joined: Sun Nov 14, 2010 6:36 pm

Re: about figure and table numbering.

Post by sds »

Hi meho_r,

Thanks for your reply. After replacing the existing \renewcommand with your command in the template, it numbers the figure in each section individually.
For instance, chapter 1 has two section, in each section, it numbers the figures individually:

Chapter 1
section 1
figure 1.1
section 2
figure 1.1
figure 1.2
.....

Do you know what the problem is?

Thanks a lot.
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

about figure and table numbering.

Post by meho_r »

The code I provided works as expected. Without any additional information it's hard to tell. Please, follow the Board Rules and provide a Minimal Working Example (MWE). Also, if you're using a custom "template" or document class, you should provide them to.

In the meantime, you may try another solution. Using chngcntr package, try \counterwithin... command instead of \renewcommand... I mentioned in my previous post:

Code: Select all

\usepackage{chngcntr}
\counterwithin{figure}{chapter}
sds
Posts: 6
Joined: Sun Nov 14, 2010 6:36 pm

Re: about figure and table numbering.

Post by sds »

Hi meho_r,
Sorry for the inconvenience. I am using a three-part template, and due to some reason, I need to use it. The template is attached.

(1) With the \renewcommand, I had problems on both figures and tables:
Figures:
Chapter 1
section 1
figure 1.1
section 2
figure 1.1
figure 1.2
...

Tables:
Chapter 1
section 1
table 1.1
section 2
table 1.2
table 1.3
Chapter 2
table 1.4
Chapter 3
table 1.5
....

(2) With the \counterwithin, the tables works great. But the problem on figures is still there.

Could you please take a look at the template and see what the problem is?
Attachments
uconnthesis.cls
(17.32 KiB) Downloaded 247 times
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

about figure and table numbering.

Post by meho_r »

You've forgotten to add a Minimal Working Example (MWE) too, so please do so.
sds
Posts: 6
Joined: Sun Nov 14, 2010 6:36 pm

Re: about figure and table numbering.

Post by sds »

Hi meho_r,
The problem has been fixed by commenting out \@addtoreset{figure}{section}.
It seems that is the problem.
Thank you very much for your help.
Post Reply