在这个简单的回忆录目录中,标题和目录之间似乎有间距。也就是说,左侧页面上的“目录”规则和“1 Lorem”之间的垂直间距大于右侧页面上的“Lorem”规则和“Lorem ipsum ...”之间的间距。
我该如何调整这个间距?
\documentclass{memoir}
\usepackage{lipsum}
\headstyles{bringhurst}
\begin{document}
(intentionally left blank)
\newpage
\tableofcontents*
\chapter{Lorem}
\lipsum[1]
\section{Num dui ligula}
\lipsum[2]
\end{document}
答案1
该类在目录中每个章节标题前memoir
添加垂直空间。\cftbeforechapterskip
您可以将其删除在第一个章节标题之前。
\documentclass{memoir}
\usepackage{lipsum}
\headstyles{bringhurst}
\begin{document}
(intentionally left blank)
\newpage
\tableofcontents*
\addtocontents{toc}{\protect\vspace{-\cftbeforechapterskip}}
\chapter{Lorem}
\lipsum[1]
\section{Num dui ligula}
\lipsum[2]
\chapter{Lorem}
\lipsum[1]
\section{Num dui ligula}
\lipsum[2]
\end{document}
或者,使用\aftertoctitle
,其标准定义是\afterchaptertitle
:
\documentclass{memoir}
\usepackage{lipsum}
\headstyles{bringhurst}
\renewcommand{\aftertoctitle}{%
\afterchaptertitle % standard behavior
\vspace{-\cftbeforechapterskip}% remove the excess
}
\begin{document}
(intentionally left blank)
\newpage
\tableofcontents*
\chapter{Lorem}
\lipsum[1]
\section{Num dui ligula}
\lipsum[2]
\chapter{Lorem}
\lipsum[1]
\section{Num dui ligula}
\lipsum[2]
\end{document}
答案2
通常bringhurst
禁用 skip 的使用\afterchaptertitle
,将责任分别留给memoir
的\@starttoc
和版本\newlistof
。由此我们可以得出结论,目录中章节标题之后发生的第一件“事情”是\contentsline
通过相应的\@input
。请记住 是\contentsline
在 中定义的latex.ltx
:
\def\contentsline#1#2#3#4{\gdef\@contentsline@destination{#4}%
\csname l@#1\endcsname{#2}{#3}}
因此,它归结为\l@<#1>
;在你的情况下\l@chapter
,它memoir
看起来像:
\newcommand*{\l@chapter}[2]{%
\l@chapapp{#1}{#2}{\cftchaptername}}
再往下抽象一层,我们发现:
\newcommand*{\l@chapapp}[3]{%
\ifnum \c@tocdepth >\m@ne
\cftchapterbreak
\vskip \cftbeforechapterskip
{%\leftskip \cftchapterindent\relax
\memRTLleftskip \cftchapterindent\relax
%%% \rightskip \@tocrmarg
\memRTLrightskip \@tocrmarg
%%% \parfillskip -\rightskip
\parfillskip -\memRTLrightskip
\parindent \cftchapterindent\relax
\@afterindenttrue
\interlinepenalty\@M
\leavevmode
\let\@cftbsnum \cftchapterpresnum
\let\@cftasnum \cftchapteraftersnum
\let\@cftasnumb \cftchapteraftersnumb
\def\@chapapp@head{#3}%
\settowidth{\@tempdima}{\cftchapterfont\@chapapp@head}%
\addtolength{\@tempdima}{\cftchapternumwidth}%
%%% \advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
\advance\memRTLleftskip \@tempdima \null\nobreak\hskip -\memRTLleftskip
{\cftchapterfont #1}\nobreak
\cftchapterfillnum{#2}}
\fi}
最后,尺寸会\cftbeforechapterskip
“污染”间距。一个非常简单的事情,因此,你可以尝试
\makeatletter
\setlength\cftbeforechapterskip{\z@}
\makeatother
也许更优雅和更不粗糙的方法是使用这个xpatch
包:
\def\m@patch@toc@padding@top{%
\def\m@patch@toc@padding@top{\vskip \cftbeforechapterskip}
}
\patchcmd\l@chapapp{%
\vskip \cftbeforechapterskip% search
}{%
\m@patch@toc@padding@top% replace
}{}{}% success / failure
如果你想控制间距,你可以添加类似
\renewcommand*\afterchaptertitle{%
\vskip\onelineskip \hrule\vskip \afterchapskip
}
\setlength\afterchapskip{12\p@} % add your desired spacing here
完整代码
\documentclass{memoir}
\usepackage{lipsum}
\usepackage{xpatch}
\headstyles{bringhurst}
\makeatletter
\def\m@patch@toc@padding@top{%
\def\m@patch@toc@padding@top{\vskip \cftbeforechapterskip}
}
\patchcmd\l@chapapp{%
\vskip \cftbeforechapterskip
}{%
\m@patch@toc@padding@top
}{}{}
\renewcommand*\afterchaptertitle{%
\vskip\onelineskip \hrule\vskip \afterchapskip
}
\setlength\afterchapskip{12\p@}
\makeatother
\begin{document}
(intentionally left blank)
\newpage
\tableofcontents*
\chapter{Lorem}
\lipsum[1]
\section{Num dui ligula}
\lipsum[2]
\end{document}