0

I was wondering if there is a neat way of aligning the chapter, section and subsection headings in memoir class so as to look like this:

enter image description here

(the largest heading at the top is the chapter, etc.)

  • What code have you got? What have you tried? Please provide a minimal example. – cfr Dec 8 '16 at 23:33
1

The following example provides a length \secnumwidth that is used to fix the widths within which the section numbers (including that of \chapter) is printed. All other display styles have been preserved (including the vertical spacing for \chapter):

enter image description here

\documentclass{memoir}

\newlength{\secnumwidth}
\setlength{\secnumwidth}{3em}

\renewcommand{\printchaptername}{}% Don't print 'Chapter'
\renewcommand{\chapnumfont}{\chaptitlefont}
\renewcommand{\chapternamenum}[1]{\makebox[\secnumwidth][l]{#1}}
\renewcommand{\afterchapternum}{}% Remove (vertical) skip between chapter number and title
\makeatletter
\renewcommand{\@seccntformat}[1]{\makebox[\secnumwidth][l]{\csname the#1\endcsname}}
\makeatother

\setcounter{secnumdepth}{2}% Number up to \subsection

\begin{document}

\chapter{A chapter}

\section{A section}

\subsection{A subsection}

\end{document}

Here's a similar way to achieve it in the default report document class. It involves updating \@makechapterhead and \@seccntformat:

enter image description here

\documentclass{report}

\newlength{\secnumwidth}
\setlength{\secnumwidth}{5em}

\makeatletter
\def\@makechapterhead#1{%
  \vspace*{50\p@}%
  {\interlinepenalty\@M
    \parindent \z@ \raggedright \normalfont
    \huge\bfseries
    \ifnum \c@secnumdepth >\m@ne
      \makebox[\secnumwidth][l]{\thechapter}%
    \fi
     #1\par\nobreak
    \vskip 40\p@
  }}
\renewcommand{\@seccntformat}[1]{\makebox[\secnumwidth][l]{\csname the#1\endcsname}}
\makeatother

\begin{document}

\chapter{A chapter}

\section{A section}

\subsection{A subsection}

\end{document}

Like before, the regular vertical spacing for \chapter has been preserved (but could be changed).

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.