6

Minimal example (the problem is obvious):

\documentclass[]{report}

\makeatletter
\def\@makechapterhead#1{
    \vspace*{-5.0em}
    {\parindent \z@  \normalfont
    \interlinepenalty\@M
    \LARGE{0\thechapter}
    \par\vspace{0.25cm}
    \flushleft\MakeUppercase{#1}}
    \par\vspace{3.5em}
}
\makeatother

\begin{document}

\chapter{First Chapter}
\setcounter{chapter}{9}
\chapter{Tenth Chapter}

\appendix
\chapter{Appendix A}

\end{document}

Edit: I forgot to mention something important. Only the displayed chapter numbers should have 0s in front of them, not definitions, theorems, etc. That is: Chapter 01, Definition 1.1., etc.

3

You can adjust the printing of \thechapter within \@makechapterhead to insert a 0 only if the value of the chapter counter is less than 10:

enter image description here

\documentclass{report}

\usepackage{etoolbox}

\makeatletter
\patchcmd{\@makechapterhead}% <cmd>
  {\thechapter}% <search>
  {\expandafter\ifx\@chapapp\appendixname\else\ifnum\value{chapter}<10 0\fi\fi\thechapter}% <replace>
  {}{}% <success><failure>
\makeatother

\usepackage{amsthm}
\newtheorem{thm}{Theorem}[chapter]

\begin{document}

\chapter{First Chapter}

\begin{thm}
  A first theorem
\end{thm}
\setcounter{chapter}{9}
\chapter{Tenth Chapter}

\appendix
\chapter{Appendix A}
\begin{thm}
  Another theorem
\end{thm}

\end{document}

The nested condition in the "replacement clause" of \patchcmd first checks whether you're in the appendix or not. If you aren't, then it prepends the \thechapter counter with 0, similar to the kernel \two@digits macro.

  • +1; Your patch is basically the command \two@digits defined in the LaTeX kernel, so you could just write \two@digits{\thechapter}. – Pier Paolo Jun 7 '15 at 14:51
  • @Mico: Thanks for picking that up. I've corrected for this in the updated post. – Werner Jun 9 '15 at 6:01
8

Easy with \numprintand its \nplpadding command:

\documentclass[]{report}

\usepackage{numprint, apptools}

\makeatletter
\def\@makechapterhead#1{
    \vspace*{-5.0em}
    {\parindent \z@ \normalfont
    \interlinepenalty\@M
    \LARGE{\ifappendix\Alph{chapter}\else\nplpadding{2}\numprint{\arabic{chapter}}\fi}%
    \par\vspace{0.25cm}
    \flushleft\MakeUppercase{#1}}
    \par\vspace{3.5em}
    \renewcommand\thechapter{\ifappendix\Alph{chapter}\else\npnolpadding\arabic{chapter}\fi}}
\makeatother

\usepackage{amsthm}
\newtheorem{thm}{Theorem}[chapter]

\begin{document}

\chapter{First Chapter}

\begin{thm}
  A first theorem
\end{thm}
\setcounter{chapter}{9}
\chapter{Tenth Chapter}

\appendix
\chapter{Appendix A}
\begin{thm}
  Another theorem
\end{thm}

\end{document} 

enter image description here

enter image description here

  • Actually there's something I forgot to mention (sorry). I only want the displayed chapter numbers to have 0s. The definitions, theorems, etc. will be labeled normally. Any way to fix that? I'll leave the answer accepted because it's not that big of a deal, but I would like to fix it if possible. – Randy Randerson Jun 6 '15 at 13:53
  • @RandyRanderson: please see my updated answer. – Bernard Jun 6 '15 at 14:07
  • @Mico: with \newtheorem{thm}{Theorem}[chapter], it is modified, so I had to change my code. – Bernard Jun 6 '15 at 14:09
  • Shouldn't the chapter numbering style be reset explicitly to \Alph in the appendix? Without such a reset, one would seem to get "01" in the page header instead of "A". – Mico Jun 6 '15 at 14:18
  • It doesn't have to. It seems the \appendix switch does it.removed. It's fixed now. – Bernard Jun 6 '15 at 14:23
2

Here is a solution for ConTeXt users to force double digit numbers for the chapters. With the use of the \startsectionblockenvironment command one could provide setups which are only applied for a certain sectionblock environment.

\startsectionblockenvironment[bodypart]
    \setuphead[chapter][deepnumbercommand=\twodigits]
\stopsectionblockenvironment

\starttext

\startsectionblock[bodypart]

\chapter{First chapter}

\stopsectionblock

\startsectionblock[appendix]

\chapter{Appendix A}

\stopsectionblock

\stoptext

To have the same layout for the heading with the number on a separate line one has to write its own rendering alternative for it.

\defineheadalternative
  [stacked]
  [alternative=vertical,
   renderingsetup=headalternative:stacked]

\startsetups[headalternative:stacked]
    \vbox {
        \headsetupspacing
        \begstrut
        \ifconditional\headshownumber
            \headnumbercontent
            \par
        \fi
        \headtextcontent
    }
\stopsetups

After this is done with can load this new rendering with the alternative key from \setuphead.

\setuphead
  [chapter]
  [alternative=stacked,
   textstyle=WORD]

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.