如果内容行的长度有点长,但又不是太多,LaTeX 会将其挤在页码之前。这对我来说看起来很糟糕。
在这种情况下,我怎样才能说服它打破这条线,就好像这条线有点长并且挤不进去一样?
请注意,我的真实文档用途是etoc
,我需要一个与该用法一致的解决方案。(我使用它来生成多个目录并灵活地淡化其中的部分内容。)
梅威瑟:
\documentclass[a4paper]{book}
\usepackage{geometry}
\begin{document}
\tableofcontents
\chapter{In the beginning}
\section{The emptiness of nothingness and the blue ovoidness of avoiding voiding kangaroos}
\section{The emptiness of nothingness and the blue ovoidness of avoiding voiding kangaroos and jumping counts}
\section{Counting kangaroos and jumping counts}
\chapter{In the middle}
\setcounter{page}{50}
\section{The emptiness of nothingness and the blue ovoidness of avoiding voiding kangaroos}
\section{The emptiness of nothingness and the blue ovoidness of avoiding voiding kangaroos and jumping counts}
\section{Counting kangaroos and jumping counts}
\chapter{In the end}
\setcounter{page}{100}
\section{The emptiness of nothingness and the blue ovoidness of avoiding voiding kangaroos}
\section{The emptiness of nothingness and the blue ovoidness of avoiding voiding kangaroos and jumping counts}
\section{Counting kangaroos and jumping counts}
\end{document}
我无法想象以前没有人问过这个问题,但我没有找到一个好的解决方案。如何强制长章节名称(包括页码)保留在目录的边距中?担心同样的问题,但我已经加载了英国英语和威尔士语的连字模式,我正在使用 pdfLaTeX,但我不是使用 hyperref。因此,只剩下手动添加连字符点的解决方案,这远非最佳解决方案。评论中的另一个建议是缩短标题,但这不是这里的选项:我没有命名要包含的内容,也无法重新命名它。
有更好的解决方案吗?“更好”意味着解决方案是自动的(不需要在 LaTeX 知道如何在其他地方连字的单词中插入连字点)并且不需要重写内容以使其更短(或更长)。
答案1
首先,我想给你提供来自layouts
包自述文件的内容结构。
然后您可以根据需要调整任何参数。对于您的问题,我们可以按如下方式调整值\@pnumwidth
。\@tocrmarg
\documentclass[a4paper]{book}
\usepackage{geometry}
\makeatletter
\renewcommand\@pnumwidth{2.4em}
\renewcommand{\@tocrmarg}{2.4em}
%make sure that these two values are the same and then the titles
%on the right would break lines at one vertical lines.
\makeatother
\begin{document}
\tableofcontents
\chapter{In the beginning}
\section{The emptiness of nothingness and the blue ovoidness of avoiding voiding kangaroos}
\section{The emptiness of nothingness and the blue ovoidness of avoiding voiding kangaroos and jumping counts}
\section{Counting kangaroos and jumping counts}
\chapter{In the middle}
\setcounter{page}{50}
\section{The emptiness of nothingness and the blue ovoidness of avoiding voiding kangaroos}
\section{The emptiness of nothingness and the blue ovoidness of avoiding voiding kangaroos and jumping counts}
\section{Counting kangaroos and jumping counts}
\chapter{In the end}
\setcounter{page}{100}
\section{The emptiness of nothingness and the blue ovoidness of avoiding voiding kangaroos}
\section{The emptiness of nothingness and the blue ovoidness of avoiding voiding kangaroos and jumping counts}
\section{Counting kangaroos and jumping counts}
\end{document}
PDF 是
答案2
标准类留出\@pnumwidth
了页码的宽度,因此,如果你有很多页,你只需要增加它,
\documentclass[a4paper]{book}
\usepackage{geometry}
\makeatletter
\renewcommand\@pnumwidth{2.5em}
\renewcommand\@tocrmarg{2.5em}
\makeatother
\begin{document}
\tableofcontents
\chapter{In the beginning}
\section{The emptiness of nothingness and the blue ovoidness of avoiding voiding kangaroos}
\section{The emptiness of nothingness and the blue ovoidness of avoiding voiding kangaroos and jumping counts}
\section{Counting kangaroos and jumping counts}
\chapter{In the middle}
\setcounter{page}{50}
\section{The emptiness of nothingness and the blue ovoidness of avoiding voiding kangaroos}
\section{The emptiness of nothingness and the blue ovoidness of avoiding voiding kangaroos and jumping counts}
\section{Counting kangaroos and jumping counts}
\chapter{In the end}
\setcounter{page}{100}
\section{The emptiness of nothingness and the blue ovoidness of avoiding voiding kangaroos}
\section{The emptiness of nothingness and the blue ovoidness of avoiding voiding kangaroos and jumping counts}
\section{Counting kangaroos and jumping counts}
\end{document}
答案3
您有\contentsmargin
以下命令titletoc
:
\documentclass[a4paper]{book}
\usepackage{titletoc, calc}
\usepackage[showframe]{geometry}
\contentsmargin{2pc}
\begin{document}
\tableofcontents
\chapter{In the beginning}
\section{The emptiness of nothingness and the blue ovoidness of avoiding voiding kangaroos}
\section{The emptiness of nothingness and the blue ovoidness of avoiding voiding kangaroos and jumping counts}
\section{Counting kangaroos and jumping counts}
\chapter{In the middle}
\setcounter{page}{50}
\section{The emptiness of nothingness and the blue ovoidness of avoiding voiding kangaroos}
\section{The emptiness of nothingness and the blue ovoidness of avoiding voiding kangaroos and jumping counts}
\section{Counting kangaroos and jumping counts}
\chapter{In the end}
\setcounter{page}{100}
\section{The emptiness of nothingness and the blue ovoidness of avoiding voiding kangaroos}
\section{The emptiness of nothingness and the blue ovoidness of avoiding voiding kangaroos and jumping counts}
\section{Counting kangaroos and jumping counts}
\end{document}