目录条目将大页码推入页边距

目录条目将大页码推入页边距

我只是在玩此解决方案我问的一个问题将目录点扩展到大页码.我注意到了以下行为。

对于一些很长的罗马页码,如果它们延伸到目录条目的文本中并留出一些空间来放置一些圆点,那么对齐就会保持。但是,如果没有空间放置圆点,那么页码就会被推到右边距。

我意识到这种行为是人为的,但我很好奇为什么会发生这种情况,因为我认为由于页码被放在右对齐框中,它仍然会保持右对齐,并且更有可能在表格条目中出现双重打印字符。

在此处输入图片描述

\documentclass{extarticle}
\usepackage{lipsum}
\usepackage[nottoc]{tocbibind}

\usepackage{tocbasic}
\DeclareTOCStyleEntries[
  rightindent=10em,
  pagenumberbox=\pagenumberbox
]{tocline}{section,subsection,subsubsection,paragraph,subparagraph,figure,table}
\newcommand*\pagenumberbox[1]{\mbox{\hspace{1em}#1}}

\begin{document}
\tableofcontents
\pagenumbering{Roman}
\setcounter{page}{12340}
\section{Some big page numbers}
\subsection{Something}
\subsection{Some possibly very long title section that might just decide to span several lines in the table of contents. Why would someone write this}
\subsection{Some possibly very long title section that might just decide to span several lines in the table of contents. Why would someone write this, but a line break fixes it}
\end{document}

答案1

您可以添加选项raggedentrytext

\documentclass{extarticle}
\usepackage{lipsum}
\usepackage[nottoc]{tocbibind}

\usepackage{tocbasic}
\DeclareTOCStyleEntries[
  rightindent=10em,
  raggedentrytext,% <- added
  pagenumberbox=\pagenumberbox
]{tocline}{section,subsection,subsubsection,paragraph,subparagraph,figure,table}
\newcommand*\pagenumberbox[1]{\mbox{\hspace{1em}#1}}

\begin{document}
\tableofcontents
\pagenumbering{Roman}
\setcounter{page}{12340}
\section{Some big page numbers}
\subsection{Something}
\subsection{Some possibly very long title section that might just decide to span several lines in the table of contents. Why would someone write this}
\subsection{Some possibly very long title section that might just decide to span several lines in the table of contents. Why would someone write this, but a line break fixes it}
\end{document}

结果:

在此处输入图片描述

或者您可以\sloppy在目录中使用:

\documentclass{extarticle}
\usepackage{lipsum}
\usepackage[nottoc]{tocbibind}

\usepackage{tocbasic}
\DeclareTOCStyleEntries[
  rightindent=10em,
  pagenumberbox=\pagenumberbox
]{tocline}{section,subsection,subsubsection,paragraph,subparagraph,figure,table}
\newcommand*\pagenumberbox[1]{\mbox{\hspace{1em}#1}}

\begin{document}
\tableofcontents
\addtocontents{toc}{\sloppy}% <- added
\pagenumbering{Roman}
\setcounter{page}{12340}
\section{Some big page numbers}
\subsection{Something}
\subsection{Some possibly very long title section that might just decide to span several lines in the table of contents. Why would someone write this}
\subsection{Some possibly very long title section that might just decide to span several lines in the table of contents. Why would someone write this, but a line break fixes it}
\end{document}

在此处输入图片描述

相关内容