将目录中各部分的罗马数字对齐

将目录中各部分的罗马数字对齐

我如何以这种方式对齐各部分的罗马数字?另一种方法是使用阿拉伯数字枚举。除了对齐各部分的罗马数字外,我不会对 classicthesis 的目录进行任何更改。

\documentclass{scrreprt}                  % classe report di KOMA-Script;

\usepackage[%
                    pdfspacing,%                   % migliora il riempimento di riga
                    linedheaders,%
                    dottedtoc,%
                    parts%                        % da decommentare in un documento diviso in parti
                    ]{classicthesis}               % stile ClassicThesis

\hypersetup{hidelinks}

\begin{document}

\tableofcontents

\part{Test Part One}
\chapter{Test Chapter One}
\section{Test Section One One}
\section{Test Section One Two}
\part{Test Part Two}
\chapter{Test Chapter One}
\section{Test Section One One}
\section{Test Section One Two}
\part{Test Part Three}
\chapter{Test Chapter One}
\section{Test Section One One}
\section{Test Section One Two}

\end{document}

在此处输入图片描述

答案1

这是一个可能的解决方案,使用重新\Part定义classicthesis.sty

\documentclass{scrreprt}
\usepackage[%
                    pdfspacing,%
                    linedheaders,%
                    dottedtoc,%
                    parts%
                    ]{classicthesis}
\hypersetup{bookmarksnumbered,hidelinks}

\makeatletter
\setlength\cftpartnumwidth{1.5em}
\renewcommand\Part[2][]{%
\addtocontents{toc}{\setcounter{tocdepth}{-2}}
\ifpdf\pdfstringdefDisableCommands{\let\thepart\@gobbletwo}%
  \oldpart[\texorpdfstring{\spacedlowsmallcaps{#1}}{#1}]{#2}
\else\oldpart[\spacedlowsmallcaps{#1}]{#2}%
\fi%
\addtocontents{toc}{\setcounter{tocdepth}{2}}%
\addcontentsline{toc}{part}{\protect\numberline{%
  \hspace*{4pt}\texorpdfstring{\llap{\thepart}}{}}\texorpdfstring{\noexpand\spacedlowsmallcaps{#1}}{#1}}
\ctparttext{\relax}%
}%
\makeatother

\begin{document}

\tableofcontents

\part{Test Part One}
\chapter{Test Chapter One}
\section{Test Section One One}
\section{Test Section One Two}
\part{Test Part Two}
\chapter{Test Chapter One}
\section{Test Section One One}
\section{Test Section One Two}
\part{Test Part Three}
\chapter{Test Chapter One}
\section{Test Section One One}
\section{Test Section One Two}

\end{document}

在此处输入图片描述

答案2

与其他分段命令不同,\part不使用目录中其编号的任何对齐方式。使用时可以进行与其他命令类似的对齐\numberline(这需要为 设定一个值,以\@tempdima1.5em原始进行比较3em)。xpatch提供了一种修补纠正 ToC 行为所需的两个命令的方法:\l@part\@part

在此处输入图片描述

\documentclass{book}
\usepackage{xpatch}% http://ctan.org/pkg/xpatch
\makeatletter
\patchcmd{\l@part}{3em}{1.5em}{}{}% <cmd><search><replace><success><failure>
\xpatchcmd{\@part}{\thepart\hspace{1em}}{\protect\numberline{\ \llap{\thepart}}}{}{}% <cmd><search><replace><success><failure>
\makeatother
\begin{document}

\tableofcontents

\part{title}
\chapter{title}
\section{title}
\part{title}
\chapter{title}
\section{title}
\part{title}
\chapter{title}
\section{title}

\end{document}

相关内容