目录:页码与顶部对齐,而不是底部对齐

目录:页码与顶部对齐,而不是底部对齐

简单来说,我该如何将页码对齐到很长的目录条目的顶部?在此处输入图片描述

以下是 MWE:

\documentclass{book}
\usepackage{tocloft}% http://ctan.org/pkg/tocloft
\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox

\newcommand{\listdefinitionname}{My list of definitions}
\newlistof{definition}{def}{\listdefinitionname}
\newcommand{\definition}[1]{%
  \refstepcounter{definition}%
  \par\noindent\textbf{The Definition~\thedefinition. #1}%
  \addcontentsline{def}{definition}
    {\protect\numberline{\thechapter.\thedefinition}#1}\par%
}
\makeatletter
\preto\chapter{\addtocontents{def}{\protect\addvspace{10\p@}}}%
\makeatother

\begin{document}

\listofdefinition
\chapter{A chapter}
\definition{Some really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really long definition}
\definition{Some definition}
\definition{Some definition}


\end{document}

答案1

根据 Manual Kuehner 博士的评论,你可以调整egreg 的解决方案目录对齐问题,多\pbox\includepdfaddtotoc

\documentclass{book}
\usepackage{tocloft}
\usepackage{xpatch}

\usepackage{varwidth}
\makeatletter
\DeclareRobustCommand{\vwdef}[1]{%
  \begin{varwidth}[t]{\dimexpr\textwidth-\@pnumwidth-\cftdefinitionnumwidth}\strut#1\unskip\nobreak\strut\par
  \end{varwidth}%
}
\makeatother

\newcommand{\listdefinitionname}{My list of definitions}
\newlistof{definition}{def}{\listdefinitionname}
\newcommand{\definition}[1]{%
  \refstepcounter{definition}%
  \par\noindent\textbf{The Definition~\thedefinition. #1}%
  \addcontentsline{def}{definition}
    {\protect\numberline{\thechapter.\thedefinition}\vwdef{#1}}\par%
}
\setlength{\cftdefinitionnumwidth}{2em}

\xpretocmd\chapter{\addtocontents{def}{\protect\addvspace{10pt}}}{}{}%

\begin{document}

\listofdefinition
\chapter{A chapter}
\definition{Some really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really long definition}
\definition{Some definition}
\definition{Some definition}

\end{document}

在此处输入图片描述

相关内容