Graphics, Figures & TablesLoss of figure chapter numbers when using frontmatter

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
annazn
Posts: 4
Joined: Mon Jul 11, 2016 7:17 pm

Loss of figure chapter numbers when using frontmatter

Post by annazn »

I am writing my master thesis using the memoir package.

I use \frontmatter for table of contents, abstract and so on, and \mainmatter for the thesis.
I use
\makeatletter
\renewcommand\@memmain@floats{%
\counterwithin{figure}{chapter}
\counterwithin{table}{chapter}
}
\makeatother

and it works fine when I'm only using \mainmatter. When I activate \fronmatter the chapter numbers are lost. Do anyone know how to fix it?

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

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Re: Loss of figure chapter numbers when using frontmatter

Post by Johannes_B »

Chapters in the frontmatter are unnumbered.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
annazn
Posts: 4
Joined: Mon Jul 11, 2016 7:17 pm

Re: Loss of figure chapter numbers when using frontmatter

Post by annazn »

I know that chapters are unnumbered in frontmatter :)
The problem is that my figures in mainmatter lose their chapter numbers when I start my document using frommatter:

\frontmatter
abstract etc.

\mainmatter
main document (no chapter numbers)

If I deactive frontmatter I can see the chapter numbers again.
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Loss of figure chapter numbers when using frontmatter

Post by Johannes_B »

Ah, that wasn't apparent from your original post. And it shouldn't be the case at all. Please provide a minimal working example for us to reproduce your issue and help you fast.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
annazn
Posts: 4
Joined: Mon Jul 11, 2016 7:17 pm

Loss of figure chapter numbers when using frontmatter

Post by annazn »

Here is an example of my problem:

Code: Select all

\documentclass[final,a4paper,11pt,fleqn,dvipsnames,article,twoside,openright,english]{memoir}
						
\usepackage{amsmath}  
\usepackage{subfig}
\usepackage{graphicx}
\usepackage{todonotes}

\setsecnumdepth{subsection}
\maxtocdepth{subsection}
\numberwithin{figure}{chapter}
\numberwithin{table}{chapter}

\makeatletter
\renewcommand\@memmain@floats{%
	\counterwithin{figure}{chapter}
	\counterwithin{table}{chapter}
}
\makeatother


\begin{document}

\frontmatter

text

\mainmatter

\chapter{Test}
\begin{figure}
\centering
\includegraphics[width=0.7\linewidth]{file}
\caption{}
\label{fig:acalparticlesize}
\end{figure}

\end{document}[/latex]

My figure is named Figure 1.
If i deactivate \frontmatter the figure is now called figure 1.1

[latex]\documentclass[final,a4paper,11pt,fleqn,dvipsnames,article,twoside,openright,english]{memoir}
						
\usepackage{amsmath}  
\usepackage{subfig}
\usepackage{graphicx}
\usepackage{todonotes}

\setsecnumdepth{subsection}
\maxtocdepth{subsection}
\numberwithin{figure}{chapter}
\numberwithin{table}{chapter}

\makeatletter
\renewcommand\@memmain@floats{%
	\counterwithin{figure}{chapter}
	\counterwithin{table}{chapter}
}
\makeatother


\begin{document}

%\frontmatter

%text

\mainmatter

\chapter{Test}
\begin{figure}
\centering
\includegraphics[width=0.7\linewidth]{file}
\caption{}
\label{fig:acalparticlesize}
\end{figure}

\end{document}
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Loss of figure chapter numbers when using frontmatter

Post by Johannes_B »

In your very first line, you have the word article, which you don't want, since you want chapters. Remove it.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
annazn
Posts: 4
Joined: Mon Jul 11, 2016 7:17 pm

Re: Loss of figure chapter numbers when using frontmatter

Post by annazn »

Thanks a lot! It works now :mrgreen: 4 days before I'm handing in, you saved my day!
Post Reply