目次の各部分のローマ数字を揃える

目次の各部分のローマ数字を揃える

パートのローマ数字をこのように揃えるにはどうすればよいでしょうか。別の方法としては、アラビア数字の列挙を使用することです。classicthesis の TOC では、パートのローマ数字の揃え以外に変更は行いません。

\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で定義されているの再定義を使用した 1 つの解決策を次に示します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を設定する必要があります)。\@tempdima1.5em3emxpatchToC の動作を修正するために必要な 2 つのコマンドをパッチする手段を提供します:\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}

関連情報