Document ClassesFigure numbering with memoir

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
suatlatex
Posts: 4
Joined: Mon Mar 07, 2011 7:18 am

Figure numbering with memoir

Post by suatlatex »

I'm using the memoir class write my thesis, and I want to number the floats in #chapter.#section.#equation format.

I have included the following codes in the \frontmatter.

Code: Select all

\numberwithin{equation}{section}
\numberwithin{figure}{section}
The number of an equation is shown as 1.2.3. This is exactly what I want. However, it doesn't work for figures (or tables). The number of a figure is still shown as #chapter.#figure, e.g., Figure 1.1, Figure 1.2, although the counter of figures is reset for a section.

This is a short code demonstrating this problem. It shows "Figure 1.1: Figure One" in Section 1.1 and "Figure 1.1: Figure Two" in Section 1.2.

Code: Select all

\documentclass{memoir}

\usepackage{graphicx}
\usepackage{amsmath, amssymb, amsthm}

\numberwithin{figure}{section}

\begin{document}

\mainmatter

\chapter{Chapter One}
\section{Section One}
\begin{figure}[h]
Figure One
\caption{Figure One}
\end{figure}

\section{Section Two}
\begin{figure}[h]
Figure Two
\caption{Figure Two}
\end{figure}

\end{document}
I've also tried to redefine \thefigure variable. It doesn't help either.

Code: Select all

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

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

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Figure numbering with memoir

Post by gmedina »

Hi,

add the following lines to the preamble of your document:

Code: Select all

\makeatletter
\renewcommand\@memmain@floats{%
  \counterwithin{figure}{section}
  \counterwithin{table}{section}}
\makeatother
1,1,2,3,5,8,13,21,34,55,89,144,233,...
suatlatex
Posts: 4
Joined: Mon Mar 07, 2011 7:18 am

Re: Figure numbering with memoir

Post by suatlatex »

It works! Thanks a lot!!!!
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Figure numbering with memoir

Post by localghost »

suatlatex wrote:It works! […]
Then please mark the topic (not the last post) accordingly as written in Section 3 of the Board Rules (to be read before posting).


Best regards and welcome to the board
Thorsten
Post Reply