![回忆录 hangnum 章节编号在右边距切换吗?](https://linux22.com/image/284820/%E5%9B%9E%E5%BF%86%E5%BD%95%20hangnum%20%E7%AB%A0%E8%8A%82%E7%BC%96%E5%8F%B7%E5%9C%A8%E5%8F%B3%E8%BE%B9%E8%B7%9D%E5%88%87%E6%8D%A2%E5%90%97%EF%BC%9F.png)
关于回忆录中的内置样式,是否有一个简单的命令或选项可以将 hangnum 章节样式反转为右对齐并将章节号放在右边距?我遇到过几个实现此目的的自定义样式示例,但我希望有一个简单的解决方案。
答案1
这可以做到,但不能用简单的命令或选项;必须定义新的章节样式。下面是invhangnum
具有所需规格的章节样式:
\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}