Выровняйте римские номера деталей в оглавлении

Выровняйте римские номера деталей в оглавлении

Как можно выровнять римские номера частей таким образом? Альтернативой является использование арабской нумерации. Я бы не стал вносить никаких изменений в TOC 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не использует никакого выравнивания своего номера в ToC. Выравнивание, аналогичное другим командам, возможно при использовании \numberline(что требует установки значения для \@tempdimato 1.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}

Связанный контент