3

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: enter image description here

1 Answers1

3

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}