2

I would like to have the first 1-9 numbered heading from chapter to subsubsections be two digits.

So instead of:
1 Chapter One
1.1 Section One
1.1.1 Subsection One
1.1.1.1 Subsubsection One

I would like:
01 Chapter One
01.01 Section One
01.01.01 Subsection One
01.01.01.01 Subsubsection One

After the first 9 they should just continue 10, 11, 12 etc. without a zero in front.

Faergen
  • 531
  • 5
  • 14
  • 2
    The question is not really memoir related, here is a general solution: https://tex.stackexchange.com/a/30932/3929, you'll need to use it in a redefinition of \thechapter, \thesection etc. – daleif May 14 '21 at 07:50

1 Answers1

5

The code of memoir contains

\renewcommand*{\thechapter}{\@arabic\c@chapter}
\renewcommand*{\thesection}{\thechapter.\@arabic\c@section}
\renewcommand*{\thesubsection}{%
              \thesection.\@arabic\c@subsection}
\renewcommand*{\thesubsubsection}{%
              \thesubsection.\@arabic\c@subsubsection}

so you have to replace every \@arabic... by \two@digits...

\documentclass{memoir}

\setcounter{secnumdepth}{3}

\makeatletter \renewcommand{\thechapter}{\two@digits\c@chapter} \renewcommand{\thesection}{\thechapter.\two@digits\c@section} \renewcommand{\thesubsection}{% \thesection.\two@digits\c@subsection} \renewcommand{\thesubsubsection}{% \thesubsection.\two@digits\c@subsubsection} \makeatother

\begin{document}

\chapter{Foo} \section{Bar} \subsection{Baz} \subsubsection{Bla}

\end{document}

enter image description here

campa
  • 31,130
  • Ahh, didn't even know that was in the kernel – daleif May 14 '21 at 08:13
  • 2
    @daleif I found that out quite by accident only last week while looking for the definition of \@firstoftwo (I couldn't remember if it was \long or not). I've been using my own macro for years :-) – campa May 14 '21 at 08:17
  • Legend. This is my favorite kind of answer; one that requires a level of understanding I can forgive myself for not having, and yet being easy to apply in practice. – Faergen May 15 '21 at 20:22