Graphics, Figures & TablesCustomize Figure and Table Numbering

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
davidfall
Posts: 14
Joined: Thu Aug 11, 2011 4:11 pm

Customize Figure and Table Numbering

Post by davidfall »

Hi all,

I am running into problem compiling a thesis using a University specific (chapter-based) documentclass. It seems to be default that figures (and tables) are numbered Figure thechapter.thesection.figure

Problem is that I have figures placed directly in the section, i.e.

\chapter{On something}
\begin{figure}
...
\end{figure}
\section{Something specific}
\subsection{Even more in detail}

This renders that the number on the figure will be: Figure 1.0.1; hence I will need to go for either: thechapter.figure (prefered) or contious numbering through the thesis.

I have tried various remedies, e.g:

Code: Select all

\renewcommand{\thefigure}{\thechapter.\arabic{figure}}
and

Code: Select all

\usepackage{chngcntr}
\counterwithout{figure}{section}
, but it doesn't seem to effect my numbering at all.

Any suggestions?

Cannot easily create a mwe due to documentclass but here is the preamble:

Code: Select all

\RequirePackage[l2tabu,orthodox]{nag} % This package helps prevent you from doing things wrong.

% change doctorate to licentiate if necessary
\documentclass[licentiate,g5paper]{chalmers-thesis}
% All options are; doctorate, licentiate, masters, bachelors, nocover, draft, g5paper,
% and everything the standard report class support.

\usepackage[ansinew]{inputenc} % File encoding, you should try to stick to utf8. Change back!!!
\usepackage{microtype} % Magically improves typesetting for pdflatex
\usepackage{subfiles} % Convenient use of subfiles in documents. Using \subfile is optional. See README
\usepackage[swedish, english]{babel}
\usepackage{csquotes} % Needed for biblatex
\usepackage[
    bibencoding=latin1,
    citestyle=authoryear,
    natbib=true,
    hyperref=true,
    bibstyle=authoryear,
    maxcitenames=2,
    sorting=nyt,
    dashed=false
]{biblatex}
\usepackage{textcomp}
\usepackage{hyperref} % Required for in document links and document metadata.
\usepackage{mathtools} % All your math related needs
\usepackage{tikz} % Draw figures, required for cover page
\usepackage{subfig} % Subfloats
\usepackage{subfloat}
\usepackage[capitalise]{cleveref}
\usepackage{subfig}
\usepackage{epstopdf}
\usepackage{tikz}
\usepackage{float}
\usepackage{pdfpages}
\usepackage{amsfonts}
\usepackage{pax} % java -jar pax.jar name.pdf
\usepackage{upgreek}
\usepackage{tabularx}
\usepackage{todonotes}
\usepackage{epsfig}
\usepackage[tight,nice]{units}
\usepackage{graphicx}
\usepackage{siunitx}
\usepackage{placeins}
\usepackage{chngcntr}

\crefname{figure}{Figure}{Figures}
\usetikzlibrary{decorations.pathreplacing}
\usetikzlibrary{arrows}
\usepackage[parfill]{parskip}
Best regards,
David
Last edited by davidfall on Fri Nov 04, 2011 11:19 am, 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.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Customize Figure and Table Numbering

Post by Stefan Kottwitz »

Hi David,

you could use the chngcntr package for that:

Code: Select all

\usepackage{chngcntr}
\counterwithout{figure}{section}
Perhaps add

Code: Select all

\counterwithin{figure}{chapter}
The same for tables etc. since I assume you would like to have consistent numbering style for all numbered environments.

Stefan
LaTeX.org admin
davidfall
Posts: 14
Joined: Thu Aug 11, 2011 4:11 pm

Re: Customize Figure and Table Numbering

Post by davidfall »

Thanks Stefan,
But I have already tried that...
For strange reason such change does not affect the numbering style.
I've browsed through the *cls for the document class; does not seem to be anything to do with the numbering there... Could it be some kind of package conflict?

Bests,
David
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Re: Customize Figure and Table Numbering

Post by Stefan Kottwitz »

Perhaps post the document class here as attachment to a post, I guess the University style is not a secret.

Stefan
LaTeX.org admin
davidfall
Posts: 14
Joined: Thu Aug 11, 2011 4:11 pm

Customize Figure and Table Numbering

Post by davidfall »

Hi,

Sorry for not coming back with the document class. Found the solution myself.
It strange, tried to sort this out for long time before posting here. Gave up and had some other stuff to take care of. Today I browsed through the .cls again before coming back here and found the very simple solution!

Simply replaced section with chapter in the following section in the cls:

Code: Select all

\@ifpackageloaded{amsmath}{
  \numberwithin{equation}{section}  
  \numberwithin{figure}{section} 
  \numberwithin{table}{section} 
 }
..and now I get continuous numbering within the chapters...

Thanks anyway for trying to help me!
D
Post Reply