1

I'd like to modify the way parts are named, into my toc, in the same way they are named in the body of my document:

Première partie

For the first part.

Deuxième partie

For the second part, and so on. How could I do that? This is my MWE:

\documentclass[fontsize=11pt,%
               twoside=semi,%
               headings=small,%
               chapterprefix=true,%
               listof=flat]%
{scrbook}
\usepackage[utf8]{inputenc}% can be removed with an uptodate TeX distribution
\usepackage[T1]{fontenc}
\usepackage [french]{babel}
\usepackage{fontspec}
\setmainfont{Didot}
\usepackage{lipsum}
\renewcommand*{\chapterformat}{%
  \mbox{\chapappifchapterprefix{\nobreakspace}\thechapter
  \IfUsePrefixLine{}{\enskip}}%
}


\begin{document}

\tableofcontents

\part{Éléments d'analyse}

\chapter{Définitions}

\lipsum


\end{document}
  • You should take a look at titlesec and the fmtcount package, which has an \ordinal{counter}command – Bernard Jul 2 at 17:45
2

You can redefine the KOMA-Script command \addparttocentry:

\renewcommand\addparttocentry[2]{%
  \IfArgIsEmpty{#1}
    {\addtocentrydefault{part}{#1}{#2}}
    {\addtocentrydefault{part}
      {\csname ordinal\romannumeral\value{part}\endcsname\space\partnameord}% copied from french.ldf
      {#2}%
    }%
}%
\RedeclareSectionCommand[tocdynnumwidth]{part}% adjust the space for part number in TOC

Example:


\documentclass[%fontsize=11pt,% default
               twoside=semi,%
               headings=small,%
               chapterprefix=true,%
               listof=flat]%
{scrbook}

\usepackage[T1]{fontenc}
\usepackage [ngerman,french]{babel}
\usepackage{fontspec}
%\setmainfont{Didot}% I do not have this font
\usepackage{lipsum}
\renewcommand*{\chapterformat}{%
  \mbox{\chapappifchapterprefix{\nobreakspace}\thechapter
  \IfUsePrefixLine{}{\enskip}}%
}

\renewcommand\addparttocentry[2]{%
  \IfArgIsEmpty{#1}
    {\addtocentrydefault{part}{#1}{#2}}
    {\addtocentrydefault{part}
      {\csname ordinal\romannumeral\value{part}\endcsname\space\partnameord}% copied from french.ldf
      {#2}%
    }%
}%
\RedeclareSectionCommand[tocdynnumwidth]{part}% adjust the space for part number in TOC 

\begin{document}
\tableofcontents
\part{Éléments d'analyse}\label{p}
\chapter{Définitions}
\lipsum
\end{document}

Run three times to get:

enter image description here

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.