# Continuous Figures Numbering in Memoir

I want to number my figures as Figure 1, 2, ... throughout the document. I checked the answer here and it works perfectly. However, when I use \mainmatter in memoir class it returns. (If you comment the \mainmatter line in my code it will work, but I need the\mainmatter)

MWE:

\documentclass{memoir}
\usepackage{chngcntr}
\counterwithout{figure}{chapter}
\counterwithout{table}{chapter}
\begin{document}
\mainmatter    %when using this the numbering changes
\chapter{Test Chapter}
\section{Test Section}
\begin{figure}
\caption{Caption 1}
\end{figure}

\begin{figure}
\caption{Caption 2}
\end{figure}
\end{document}


Output:

• Use the \counterwithout command after the \mainmatter. Mar 21 '18 at 18:41
• Wow, three answers in less than 15 seconds. I'm quite impressed :) Mar 21 '18 at 18:43
• lol, I didn't think of placing it after the \mainmatter. That was fast. thnx Mar 21 '18 at 18:44
• Note that you don't actually need to load chngcntr, as memoir implements \counterwithout. Mar 21 '18 at 18:47
• Also see the end of section 6.1 LOGICAL DIVISIONS in the memoir documentation. There is a reference on code required for continuous float numbering.
– Werner
Mar 21 '18 at 18:50

Just place the \counterwithout calls after \mainmatter.

Explanation:

\mainmatter is actually a command that allows \mainmatter* as well, the starred version calls \@memmain@floats, which in turn uses \counterwithin{figure}{chapter} etc. Later, \@memmain calls \@smemmain, so the previous \counterwithout is reversed.

In the very end \mainmatter does the same as \mainmatter* but additionally switches to \pagenumbering{arabic}.

\newcommand{\mainmatter}{%
\@ifstar{\@smemmain}{\@memmain}}
\newcommand\@memmain@floats{%
\counterwithin{figure}{chapter}
\counterwithin{table}{chapter}
}
\newcommand*{\@smemmain}{%
\@mainmattertrue
\setcounter{secnumdepth}{\value{maxsecnumdepth}}
\ifartopt
\if@twoside
\cleardoublepage
\else
\clearpage
\fi
\else
\cleardoublepage
\@memmain@floats
\fi}
\newcommand{\@memmain}{%
\@smemmain\pagenumbering{arabic}}


Real code...

\documentclass{memoir}
\usepackage{chngcntr}
\begin{document}
\mainmatter    %when using this the numbering changes

\counterwithout{figure}{chapter}
\counterwithout{table}{chapter}

\chapter{Test Chapter}
\section{Test Section}
\begin{figure}
\caption{Caption 1}
\end{figure}

\begin{figure}
\caption{Caption 2}
\end{figure}
\end{document}
`
• I should wait 10 minutes to accept this as an answer Mar 21 '18 at 18:45