
私の論文のスタイル設定では、出版社は目次に少なくとも 2 つのドットを要求しています。または、行を分割する必要があります (手動で行うと、他の問題が発生します)。このtocloft
\renewcommand\cftdotsep{..}
-thing (他の行で新しい問題が発生する) よりも優れたソリューションを作成するアイデアはありますか?
MWE:
\documentclass[
paper=233mm:155mm,
fontsize=10.5,
cleardoubleempty,
headings=optiontohead,
bibliography=totoc,
idxtotoc,
pointlessnumbers]
{scrbook}
\usepackage{fontspec}
\setmainfont{Times New Roman}
\usepackage{polyglossia} % Sprachumschaltung
\setdefaultlanguage{german}% Voreingestellte Dokumentsprache: Deutsch
%%% Seitenränder etc.
\usepackage[footnotesep=1.5\baselineskip]{geometry}
\geometry{includehead=true, textwidth=117mm, textheight=186mm, headsep=6mm, left=18mm, bottom=24mm}
%% Design der Überschriften %%%%%%%%%%
\setkomafont{sectioning}{\normalfont\large\scshape\centering}
\setkomafont{part}{\normalfont\Huge\scshape\centering}
\setkomafont{chapter}{\normalfont\LARGE\scshape\centering}
\setkomafont{section}{\normalfont\Large\centering}
\setkomafont{subsection}{\normalfont\large\centering}
\setkomafont{subsubsection}{\normalfont\normalsize\centering}
\setkomafont{minisec}{\normalfont\normalsize\itshape\centering}
\setkomafont{paragraph}{\normalfont\normalsize\itshape}
\setkomafont{subparagraph}{\normalfont\normalsize\itshape}
%% Inhaltsverzeichnis formatieren %%%%%%%%%%%%%%%%%%%
\usepackage{tocloft}
\tocloftpagestyle{empty} %keine Seitenzahl auf erster Seite des Inhaltsverzeichnisses
\renewcommand{\cftchappagefont}{} % Seitenzahlen auch bei Chapter nicht fett
\renewcommand{\cftpartpagefont}{} % Seitenzahlen auch bei Chapter nicht fett
\renewcommand{\cftchapleader}{\cftdotfill{\cftchapdotsep}} % Punkte nicht fett
\renewcommand{\cftchapdotsep}{\cftdotsep}
\renewcommand{\cfttoctitlefont}{\hfill\normalfont\LARGE\scshape} % Größe der Überschrift wie \chapter
\renewcommand{\cftaftertoctitle}{\hfill}
\renewcommand{\cftchapfont}{\normalfont} %% Im Inhaltsverzeichnis Titel normal. alternativ fett. \bfseries
\setcounter{tocdepth}{4}
\setcounter{secnumdepth}{4}
\renewcommand\thesection{\thechapter.\arabic{section}} %% Nummerierung Section Römisch
\renewcommand\thesubsection{\thesection.\arabic{subsection}} %% Nummerierung Subsection arabisch usw.
\renewcommand\thesubsubsection{\thesubsection.\arabic{subsubsection}}
\usepackage{blindtext}
\begin{document}
\tableofcontents
\chapter{A chapter with a title much too long as there aren't any dots any more}
\blindtext
\section{A section that is ok as there are at least two dots left}
\blindtext
\subsection{A subsection again not fitting as it is only ONE dot left}
\blindtext
\end{document}
答え1
1 つの方法は、内部コマンドを直接パッチして\@dottedtocline
、少なくとも 2 つの em の長さのリーダーを生成することです (次のようにします)。
\documentclass{scrbook}
\makeatletter
\renewcommand*\@dottedtocline[5]{%
\ifnum #1>\c@tocdepth \else
\vskip \z@ \@plus.2\p@
{\leftskip #2\relax \rightskip \@tocrmarg \parfillskip -\rightskip
\parindent #2\relax\@afterindenttrue
\interlinepenalty\@M
\leavevmode
\@tempdima #3\relax
\advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
{#4}\nobreak
\leaders\hbox{$\m@th
\mkern \@dotsep mu\hbox{.}\mkern \@dotsep
mu$}\hskip 2em \@plus 1fill % <<< PATCH
\nobreak
\hb@xt@\@pnumwidth{\hfil\normalfont \normalcolor #5}%
\par}%
\fi}
\makeatother
\begin{document}
\tableofcontents
\chapter{One}
Lorem ipsum.
\section{Some words to fill the line, words to fill the line,
words to fill the line}
Dolor sit amet.
\section{Some words to fill the line, words to fill the line,
words to fill the line, w}
Consectetur adipisci elit.
\section{Some words to fill the line, words to fill the line,
words to fill the line, wo}
Numquam faucibus,.
\end{document}
両方とも本そしてそのスクラップブッククラスは最終的に\@dottedtocline
リーダー付きの toc エントリを生成するために呼び出されるので、パッチは機能するはずです。
出力:
追加
\patchcmd
いつものように、ツールボックスpackage を代わりに使用できます\renewcommand
(完全な定義を繰り返す必要があります):
\documentclass{scrbook}
\usepackage{etoolbox}
\makeatletter
\patchcmd{\@dottedtocline}{\hfill}{\hskip 2em \@plus 1fill }{}{}
\makeatother
\begin{document}
\tableofcontents
\chapter{One}
Lorem ipsum.
\section{Some words to fill the line, words to fill the line,
words to fill the line}
Dolor sit amet.
\section{Some words to fill the line, words to fill the line,
words to fill the line, w}
Consectetur adipisci elit.
\section{Some words to fill the line, words to fill the line,
words to fill the line, wo}
Numquam faucibus,.
\end{document}
2回目の追加
コメントには、同様のパッチが必要です。トクロフト\@dottedtocline
パッケージ。簡単に調べてみると、このパッケージはリーダーを生成するために に依存せず、その目的のために独自のコマンド、つまり を定義していることがわかります\cftdotfill
。したがって、この場合にパッチを適用する必要があるのは、次のコマンドです。
\documentclass{scrbook}
\usepackage{tocloft}
\makeatletter
\renewcommand{\cftdotfill}[1]{%
\def\@tempa{#1}%
\def\@tempb{\cftnodots}%
\ifx\@tempa\@tempb
\hfill % <<< this has not been changed
\else
\leaders\hbox{$\m@th\mkern #1 mu\hbox{\cftdot}\mkern #1 mu$}%
\hskip 2em \@plus 1fill \relax % <<< PATCH
\fi
}
\makeatother
\begin{document}
\tableofcontents
\chapter{One}
Lorem ipsum.
\section{Some words to fill the line, words to fill the line,
words to fill the line}
Dolor sit amet.
\section{Some words to fill the line, words to fill the line,
words to fill the line, w}
Consectetur adipisci elit.
\section{Some words to fill the line, words to fill the line,
words to fill the line, wo}
Numquam faucibus,.
\end{document}
答え2
クヌース&プラスの1981年紙「段落を行に分割する」では、TeX の行分割アルゴリズムの基礎となるボックスとグルーのモデルについて説明し、それによって実現されるいくつかの花火のような機能を紹介します。
これらのトリックの 1 つを使用すると、より野心的な目標を設定できます。つまり、スペース不足のためにリーダーとページ番号が独自の行に配置されている場合、前の行を右から固定マージンの範囲内でリーダーで埋めます。
追加の行を強制すると、リーダーの右端がどのように一致するかに注意してください。
を調整することで、次の行に表示されるページ番号の上の右余白に余分なリーダーがどれだけはみ出すかを制御できます\rmargin
。
\documentclass[a5paper]{article}
\usepackage{fontspec}
\setmainfont{Times New Roman}
\parindent=0pt % optional, mimick TOC environment
\newdimen\pagenumwidth \pagenumwidth=0.5cm % reserved right margin space for page numbers
% leaders will reach flush with it
\newdimen\rmargin \rmargin=0.5cm % reserved right margin for leaders followed by linbreal
\newdimen\minspc \minspc=1.6em % if this much hspace isn't available for leaders, break
\def\fillwith{\hbox to 1ex {\hss.\hss}}
\def\DotsAndPage#1{%
\leaders\fillwith\hfil
\hskip \rmargin
\penalty50
\hskip - \rmargin plus -1fil % Thanks Gustavo
\hbox{}
\unskip\leaders\fillwith\hskip \minspc plus 1fill
\nobreak
{\bfseries\normalsize \hbox to \pagenumwidth{\hfil#1}}%
\break}
\begin{document}
{
\hsize=2.4in
A chapter with a title any \DotsAndPage{1}%\par
A chapter with a title A chapter with a title A chapter with a title\DotsAndPage{13}%\par
A chapter with a title A chapter with a title A chapter with a title with a title so t\DotsAndPage{132}
A chapter with a title A chapter with a title A chapter with a title with a title so th\DotsAndPage{132}
\rmargin=0.25cm % leaders tail bite into right margin
A chapter with a title with a title so th\DotsAndPage{132}
\rmargin=-0.1cm
A chapter with a title with a title so th\DotsAndPage{132}\par
}
\end{document}