3

I'm using the memoir class to typeset a novel. I have formatted the chapter display as below. The chapter numbers are displayed as '1', '2', '3', etc. How do I pad the chapter numbers less than 10, using a '0'?

\titleformat
{\chapter}
[display]
{\normalfont\scshape\huge}
{\HUGE\thechapter\centering}
{0pt}
{\vspace{18pt}\centering}[\vspace{42pt}]
  • 0\thechapter -- that's all. If you want to achieve this scheme everywhere, better use \renewcommand{\thechapter}{0\arabic{chapter}} – user31729 Jun 10 '16 at 14:44
  • 2
    Extra question: what should happen at chapter 10? – daleif Jun 10 '16 at 14:47
  • 1
    @daleif: Well, there's no indication that 0 means padding. Perhaps it's 010, 011 then... – user31729 Jun 10 '16 at 14:50
  • 2
    @ChristianHupfer thank you for pointing out the ambiguity in the question. I've corrected it now. – Ram Iyer Jun 10 '16 at 14:52
7
\renewcommand*\thechapter{\ifnum\value{chapter}<10 0\fi\arabic{chapter}}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.