5

I'm using the scrbook document class for a publication. In order to properly format the part entries in the table of contents, I would like to write an entry like

\contentsline {part}{\numberline{I}Introduction}{9}{part.1}

instead of

\contentsline {part}{I\hspace {1em}Introduction}{9}{part.1}

I have no idea how to achieve this, but I mentioned, that this is true for all other levels (chapter, section, subsection and so on) already.

Edit:

Here is a minimal working example:

\documentclass[10pt,listof=totoc,numbers=noenddot,a4paper]{scrbook}
\usepackage{mathspec}
\usepackage{xunicode}
\usepackage{polyglossia}
\setmainlanguage{english}

\setkomafont{part}{\Huge}
\setkomafont{chapter}{\huge}

\usepackage{titlesec}
\titleformat{\part}[hang]{\thispagestyle{empty}\centering\sffamily\bfseries\huge}{}{0mm}{{\fontsize{36pt}{0pt}\selectfont Part \thepart\\\vspace{3mm}}}[]

\usepackage{titletoc}
\titlecontents{part}[3pc]{\addvspace{3pc}\filcenter}{\sffamily\bfseries PART \thecontentslabel\\*[.2pc]\large}{\sffamily\bfseries\large}{}[\addvspace{.5pc}]

\begin{document}

\tableofcontents

\part{First Testpart}
\section{Just a sample section}

\end{document}

Edit 2:

The problem seems to be the \titleformat line. I am not able to find any hint in the documentation of titlesec for this behaviour.

\documentclass[10pt,listof=totoc,numbers=noenddot,a4paper]{scrbook}
\usepackage{titlesec}
% comment the following line out and check *.toc-file
\titleformat{\part}[display]{\centering\huge}{}{0mm}{{Part \thepart\\\vspace{3mm}}}[]

\begin{document}
\tableofcontents
\part{First Testpart}
\section{Just a sample section}
\end{document}
7
  • 1
    Please provide a minimal working example with the settings of the toc. Very often most of the settings can be done with KOMA itself. Dec 10, 2011 at 18:51
  • I get \contentsline {part}{\numberline {I}Part}{1}{part.1}; but you're mentioning titletoc in the tags, so that could be the cause. Please, provide a minimal example.
    – egreg
    Dec 10, 2011 at 19:00
  • Please excuse the inconvenience regarding the minimal working example, I've prepared it, but simply forgotten to paste it. I noticed, that the first version is written to TOC, when the line \titleformat{\part}[hang]{\thispagestyle{empty}\centering\sffamily\bfseries\huge}{}{0mm}{{\fontsize{36pt}{0pt}\selectfont Part \thepart\\\vspace{3mm}}}[] is present. Otherwise, the TOC entry is correctly made with \numberline.
    – DigNative
    Dec 10, 2011 at 19:22
  • @saint: So what you're saying is there is a conflict between titletoc and titlesec in the sense that your ToC entry doesn't match what you specify (via titletoc) when you also specify a title format (via titlesec)?
    – Werner
    Dec 10, 2011 at 19:38
  • @Werner: No, it seems that there is no conflict between titletoc and titlesec. The problem seems to be the line with \titleformat. I've attached a new minimal working example, showing the problem. I found nothing in the documention of titlesec regarding this behaviour.
    – DigNative
    Dec 10, 2011 at 19:44

1 Answer 1

8

According to the titlesec documentation (p 8, section 3.7. Other Package Options), you need to specify the package option newparttoc:

newparttoc oldparttoc (Package options)

Standard parts write the toc entry number in a non standard way. You may change that with newparttoc so that titletoc or a similar package can manipulate the entry. (That works only if \part has been redefined.)

\documentclass[10pt,listof=totoc,numbers=noenddot,a4paper]{scrbook}
\usepackage[newparttoc]{titlesec}% http://ctan.org/pkg/titlesec
% comment the following line out and check *.toc-file
\titleformat{\part}[display]{\centering\huge}{}{0mm}{{Part \thepart\\\vspace{3mm}}}[]

\begin{document}
\tableofcontents
\part{First Testpart}
\section{Just a sample section}
\end{document}

This leaves you with the .toc entries resembling:

\contentsline {part}{\numberline {I}First Testpart}{3}
\contentsline {section}{\numberline {0.1}Just a sample section}{5}
1
  • Thank you really, really much. I've spent over two hours until now in solving the problem. Although I read the titlesec documentation, the meaning of the package option newparttoc was not obvious to me.
    – DigNative
    Dec 10, 2011 at 20:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .