# Align the roman numbers of the parts in ToC

How can I align the roman numbers of the parts in this manner? The alternative is to use an arabic enumeration. I would not any changes at the TOC of classicthesis outside of the alignment of the roman numbers of the parts.

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

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

\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}


-
this is similar in concept to the question right-align-numbers-in-toc – barbara beeton Aug 31 '12 at 11:57
Yeah but i don't want to change anything in the TOC. I would simply to align the parts titles. I don't understand why LaTeX provide a very ugly alignment for the parts with the roman numbering – FormlessCloud Aug 31 '12 at 19:46

Here's one possible solution using a redefinition of \Part as defined in classicthesis.sty:

\documentclass{scrreprt}
\usepackage[%
pdfspacing,%
dottedtoc,%
parts%
]{classicthesis}

\makeatletter
\setlength\cftpartnumwidth{1.5em}
\renewcommand\Part[2][]{%
\ifpdf\pdfstringdefDisableCommands{\let\thepart\@gobbletwo}%
\oldpart[\texorpdfstring{\spacedlowsmallcaps{#1}}{#1}]{#2}
\else\oldpart[\spacedlowsmallcaps{#1}]{#2}%
\fi%
\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}


-
I have simplified your code and i get the same effect adding just this: \ifthenelse{\boolean{@parts}}% {% \renewcommand{\thepart}{\hspace{-0.5em}\hbox to 1em{\hfill\roman{part}}}% } what do you think about this? – FormlessCloud Sep 1 '12 at 17:33
@FormlessCloud your redefinition could be a little problematic since \thepart is also used for some other constructs (cross-references and possible headers, for example); also, you are missing the else part: \ifthenelse{\boolean{@parts}} {\renewcommand{\thepart}{\hspace{-0.5em}\hbox to 1em{\hfill\roman{part}}}}{} – Gonzalo Medina Sep 1 '12 at 17:42
thanks, I have made a re-edit of your code because if you try to put the parts option at classicthesis you get the TOC in a strange manner and also I use the dottedtoc option... – FormlessCloud Sep 1 '12 at 17:52
and for the parts headings in classicthesis is used \spacedlowsmallcaps not \scshape, and also the space between the chapter titles and the parts titles is a littel bigger than classicthesis. Maybe i'm explained bad with the picture. I would not any changes at the TOC of classicthesis outside of the alignment of the roman numbers of the parts. Sorry ! – FormlessCloud Sep 1 '12 at 18:01
@FormlessCloud that's because the calc package reimplements \setcounter and makes it a fragile command; to prevent the problem, protect both occurrences of \setcounter; i.e., replace \setcounter... with \protect\setcounter.... – Gonzalo Medina Sep 2 '12 at 21:47

Unlike other sectional commands, \part does not use any alignment of its number in the ToC. Alignment similar to other commands is possible when using \numberline (which requires setting a value for \@tempdima to 1.5em from the original 3em). xpatch provides a means to patch the two commands necessary to correct the ToC behaviour: \l@part and \@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}
`
-