0

i would like to center the part title in the table of contents (TOC) of my thesis. Based on an answer of egreg, i was able to at least modify the space between part number and part title in the TOC.
However, I cannot set this length individually for each \part (i try it in the MWE below, but as can be seen in the result, it does not work).

\documentclass[dottedtoc]{scrreprt}
\usepackage[parts]{classicthesis} 
%custom space between number and text in toc: https://tex.stackexchange.com/a/140053/38853
\makeatletter
\def\ttl@tocpart{% %magic code, don't ask
  \def\ttl@a{\protect\numberline{\thepart}\@gobble{}}}
\setlength{\cftpartnumwidth}{100px}
\makeatother

\begin{document}
\tableofcontents 
\part{P1}
\chapter{Ch1}
\setlength{\cftpartnumwidth}{150px}
\part{P2}
\chapter{Ch2}
\end{document}

Result: enter image description here

Other solutions are welcome as well!
(I am aware of https://tex.stackexchange.com/a/210676/38853, however, I don't see how to put the part number on the left and the page number on the right, as in the picture)

0

Based on Johannes_B's comments my hacky solution can be completed:

\documentclass[dottedtoc]{scrreprt}
\usepackage[parts]{classicthesis} 
%custom space between number and text in toc: http://tex.stackexchange.com/a/140053/38853
\makeatletter
\def\ttl@tocpart{% %magic code, don't ask
  \def\ttl@a{\protect\numberline{\thepart}\@gobble{}}}
\setlength{\cftpartnumwidth}{100px}
\makeatother

\begin{document}
\tableofcontents 
\part{P1}
\chapter{Ch1}
\addtocontents{toc}{\protect\setlength{\cftpartnumwidth}{150px}}
\part{P2}
\chapter{Ch2}
\end{document}

yields

enter image description here

Still, more comfortable solutions for centering the title are welcome. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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