在回忆录类中,“hangnum”章节样式将章节编号放在左边距,右对齐。我如何将其更改为左对齐?
下面是从手册中复制的 MWE,其中包含“hangnum”章节样式的原始定义:
\documentclass[12pt]{memoir}
\usepackage[usehighlevels]{alnumsec}
\alnumsectionlevels{1}{section,subsection,subsubsection,paragraph}
\alnumsecstyle{aaaa}
\surroundarabic[{.}][]{}{}
\otherseparators{1}
\alnumsecstyle{aaaa}
\makechapterstyle{myhangnum}{%
\renewcommand*{\chapnumfont}{\chaptitlefont}
\settowidth{\chapindent}{\chapnumfont 999}
\renewcommand*{\printchaptername}{}
\renewcommand*{\chapternamenum}{}
\renewcommand*{\chapnumfont}{\chaptitlefont}
\renewcommand*{\printchapternum}{%
\noindent\llap{\makebox[\chapindent][l]{%
\chapnumfont \thechapter}}}
\renewcommand*{\afterchapternum}{}
}
\chapterstyle{myhangnum}
\hangsecnum
\begin{document}
\section{All these section numbers}
\subsection{should be aligned on the left}
\subsection{so that all the first digits}
\subsubsection{which is 1 in this case}
\paragraph{are underneath each other}\
Moreover, is it possible to decrease the space between
the numbers and the titles? I rarely have paragraphs,
but I have a lot of subsubsections.
\end{document}
我尝试在 makebox 中添加 \hfill,改变 makebox 参数,但都无济于事:
\noindent\llap{\makebox[3cm][l]{%
\chapnumfont \thechapter \hfill}}}
我也尝试改变宏 \chapternamenum(手册:定义为一个空格,在打印章节名称和编号之间调用),但即使我在其中输入一个字符串,它也不会在完成的文档中出现。
答案1
呃,可以通过以下方式实现
\setsecnumformat{\llap{%
\makebox[\chapindent][l]{%
\csname the#1\endcsname\hfill%
}%
}}
而不是发行\hangsecnum
,默认情况下与
\setsecnumformat{\llap{\csname the#1\endcsname\quad}}}
@鲁本
你这边还是失败了吗?我应该使用相同的memoir
版本,但是正在使用TeLive 2015
\documentclass{memoir}
\hangsecnum
\setsecnumformat{\llap{\makebox[\chapindent][l]{\csname
the#1\endcsname\hfill}}}
\chapterstyle{hangnum}
\begin{document}
\chapter{A chapter}
\section{All these section numbers}
\subsection{should be aligned on the left}
\subsection{so that all the first digits}
\subsubsection{which is 1 in this case}
\end{document}
答案2
这是一种可能性,尽管它被黑客攻击得非常肮脏:
\documentclass{memoir}
\usepackage[usehighlevels]{alnumsec}
\alnumsectionlevels{1}{section,subsection,subsubsection,paragraph}
\alnumsecstyle{aaaa}
\surroundarabic[{.}][]{}{}
\otherseparators{1}
\alnumsecstyle{aaaa}
\usepackage{marginnote}
\reversemarginpar
\usepackage{xpatch}
\chapterstyle{hangnum}
\makeatletter
\xpatchcmd\M@sect{\protected@edef}{\protected\def}{}{}
\xpatchcmd\@mn@@@marginnote{\@tempswatrue}{\@tempswafalse}{}{}
\marginparwidth 45\p@
\renewcommand{\printchapternum}{%
\raisebox{5\p@}{\marginnote{\raggedright\chapnumfont\thechapter}}
}
\def\@seccntformat#1{\marginnote{\raggedright\csname the#1\endcsname}}
\makeatother
\begin{document}
\chapter{Some chapter}
\section{All these section numbers}
\subsection{should be aligned on the left}
\subsection{so that all the first digits}
\subsubsection{which is 1 in this case}
\paragraph{are underneath each other}
\end{document}