我正在排版一本包含多篇文章的书。为了为每个贡献创建条目,我使用
\addcontentsline{toc}{chapter}{\toctitle\newline{}{\hspace*{1cm} \textit{\cname}}}
\toctitle being the title of the contribution to appear in the table of contents, and \cname the name of the author(s).
With the package titletoc, I am formatting the entry in the table of contents thus:
\titlecontents{chapter}[0em]{\vspace{\baselineskip}}{0em}{}{\hfill\thecontentspage}
这很好。唯一的问题是与条目相关的页码应该是 bside \toctitle
,而不是\cname
。这意味着页码应该比现在的位置高一行。
非常感谢您的帮助!
抱歉,打字错误:该包名为 titletoc,而不是 titledoc。
这是一个最简单的例子:
==>
\documentclass[12pt]{book}
\pagestyle{empty}
\usepackage{titletoc}
\titlecontents{chapter}[0em]{\vspace{\baselineskip}}{0em}{}{\hfill\thecontentspage}
\begin{document}
\tableofcontents
\cleardoublepage
\addcontentsline{toc}{chapter}{Title of the first
contribution\newline{}{\hspace*{1cm} \textit{Author of the first contribution}}}
Text of the first Contribution.
\cleardoublepage
\addcontentsline{toc}{chapter}{Title of the second
contribution – a title much longer than you might expect, since it
takes not only one, but two lines\newline{}{\hspace*{1cm} \textit{Author of the second contribution}}}
Text of the second Contribution.
\end{document}
<==
我想要实现的是,在目录中,页码(分别为 3 和 5)位于“第一个贡献的标题”和“第二个贡献的标题 - 这个标题比您预期的要长得多,因为它不仅需要一行,而且需要两行”的最后一行旁边,而不是在“第一个贡献的作者”和“第二个贡献的作者”旁边。
再次感谢您的帮助
雷纳
答案1
尝试一下,将您的 ToC 输入分成两个,而不是一个(参见我上次的贡献)。
% tocpagenosprob.tex SE 636969
\documentclass[12pt]{book}
\pagestyle{empty}
\usepackage{titletoc}
\titlecontents{chapter}[0em]{\vspace{\baselineskip}}{0em}{}{\hfill\thecontentspage}
\begin{document}
\tableofcontents
\cleardoublepage
\addcontentsline{toc}{chapter}{Title of the first
contribution\newline{}{\hspace*{1cm} \textit{Author of the first contribution}}}
Text of the first Contribution.
\cleardoublepage
\addcontentsline{toc}{chapter}{Title of the second
contribution – a title much longer than you might expect, since it
takes not only one, but two lines\newline{}{\hspace*{1cm} \textit{Author of the second contribution}}}
Text of the second Contribution.
\cleardoublepage
\addcontentsline{toc}{chapter}{Title of the third
contribution – a title much longer than you might expect, since it
takes not only one, but two lines}
% adjust the 4mm space to suit
\addtocontents{toc}{\hspace*{4mm} \textit{Author of the third contribution}}
Text of the third Contribution.
\end{document}
答案2
感谢所有提供帮助的人。我认为拆分 TOC 输入是最稳妥的方法。我不会采用这种方法,因为它需要重新编程几个宏。
另一份名单建议更换
\titlecontents{chapter}[0em]{\vspace{\baselineskip}}{0em}{}{\hfill\thecontentspage}
经过
\titlecontents{chapter}[0em]{\vspace{\baselineskip}}{0em}{}{\hfill\raisebox{\baselineskip}[0pt]{\thecontentspage}}
当然,这有点不合时宜,而且作为一般方法确实有一些局限性。但在这种情况下,它正在做它应该做的事情,而且对我来说,这是目前最简单的方法。
再次感谢所有回复的人!