I'm trying to create a toc in a large Latex document which uses the KOMA script.
In the toc I would like to center the parts and remove all other components (pagenumber, partnumber). I use tocloft (a hard requirement for other reasons).
While I managed to remove the pagenumber, the partnumber is still there and the parts are very much on the right site instead of being centered.
A simplified example is:
\documentclass{scrbook}
\usepackage[ngerman]{babel}
\usepackage{lipsum}
\usepackage{tocloft}
\renewcommand{\cftpartfont}{\hfill\Large\bfseries}
\renewcommand{\cftpartaftersnum}{\hfill}
\addtocontents{toc}{\cftpagenumbersoff{part}}
\begin{document}
\tableofcontents
\part{A}
\section{a}
\lipsum
\part{B}
\section{b}
\lipsum
\end{document}
I have adapted the commands for the centering from an example of the tocloft manual, where
\renewcommand{\cftZtitlefont}{\hfill\Large\bfseries} together with
\renewcommand{\cftafterZtitle}{\hfill} will give a centered Large
bold title.
was used to center the title (instead of the parts).
So my question, how can I center the parts and remove the partnumber?
Best Answer
Try this:
Instead of
\hfil
I used a\parbox
with centered contents, just in case some title would span more than one line. I suppresses the part number in the ToC with a simple redefinition of\addparttocentry
.You mentioned that you need to use
tocloft
, but if this is not the case, you can use thetocstyle
package (designed especifically for theKOMA
classes) instead and say something like:Warning:
The following solution should be used only for old versions of KOMA-Script (for example, the one in TeX Live2009); for recent versions (those from TeX Live2010 on), please see the code above; I only include this solution here sice the OP is using TeX Live2009 and has no possibility to update: