5

With regards to the built in styles in memoir, is there a simple command or option to reverse the hangnum chapter style to be right aligned and put the chapter number in the right margin? I have come across a few examples of custom styles that achieve this but I am hoping for a simple solution.

0

1 Answer 1

5

This can be done, but not with a simple command or option; a new chapter style has to be defined. Below there's an invhangnum chapter style with the required specifications:

\documentclass{memoir}
\usepackage{lipsum}% just to generate text for the example

\makechapterstyle{invhangnum}{%
  \setlength\beforechapskip{0pt}%
  \renewcommand*\chapterheadstart{\vspace{\beforechapskip}}%
  \setlength\afterchapskip{2\onelineskip plus .2\onelineskip minus 0.2\onelineskip}%  
  \renewcommand\chaptitlefont{\Huge\bfseries}
  \setlength\midchapskip{-\baselineskip}%
  \renewcommand\chapnumfont{\Huge\bfseries}
  \renewcommand*{\printchaptername}{}
  \renewcommand*{\chapternamenum}{}
  \renewcommand*{\printchapternum}{%
      \raisebox{\dimexpr\midchapskip+\baselineskip\relax}[0pt][0pt]{%
        \makebox[0pt][l]{%
        \makebox[\dimexpr\textwidth+4em\relax][l]{%
          \parbox[t]{\textwidth}{\mbox{}}%
          \parbox[t]{4em}{\hfill\chapnumfont \thechapter}}}}}%
  \renewcommand*{\printchaptertitle}[1]{%
    \raisebox{\dimexpr\midchapskip+\baselineskip\relax}[0pt][0pt]{%
      \parbox[t]{\textwidth}{\raggedright\chaptitlefont ##1}}}%
}
\chapterstyle{invhangnum}

\begin{document}
\chapter{Test chapter}
\lipsum[2]
\end{document}

enter image description here

2
  • I would have accepted just a no answer, so I really appreciate the example you provided too!
    – Kozbot
    Feb 21, 2014 at 12:38
  • Can this be extened to sections? Tried \hangsecnum but didn't seem to carry the new style.
    – Algeboy
    Feb 4, 2022 at 16:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .