Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

enter image description here

share|improve this question
2  
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
add comment

2 Answers

up vote 5 down vote accepted

Here's one possible solution using a redefinition of \Part as defined in 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}

enter image description here

share|improve this answer
    
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
1  
@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
show 8 more comments

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.

enter image description here

\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}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.