0

I am working on a XeLaTeX “book” document, which is separated in two unnumbered parts. These two parts need to be entitled according to a “Title / Subtitle” scheme, with a linebreak as a separator between the title and the subtitle (both being quite short).

Therefore, it's quite logically (I guess?) that I have ended up doing this:

\part*{Title of my part\\Its subtitle}

which is producing what I want.

Then, to make my parts appear in the table of contents, as for every starred sections I have added the appropriate \addcontentsline:

\part*{Title of my part\\Its subtitle}
\addcontentsline{toc}{part}{Title of my part}

In my table of contents, I want my parts to appear in a certain manner, which involves no page number and a centered alignment. Here is what I have thus written in my preamble, using titletocs's \titlecontents to redefine the aspect of the titles in the ToC:

\usepackage{titletoc}
% Part aspect in ToC: vertical spacing before and after, centering, uppercase, no page number:
\titlecontents{part}
[0em]
{\addvspace{\baselineskip}\begin{center}}
{}
{\MakeUppercase}
{}
[\end{center}\addvspace{\baselineskip}]
% (Linebreaks after each argument for readibility)

The thing works exactly as I was hoping, except that I don't find the correct way to add my linebreak into the \addcontentsline without causing an error:

\part*{Title of my part\\Its subtitle}
\addcontentsline{toc}{part}{Title of my part\\Its subtitle} % Linebreak doesn't work!

I have found several solutions here to make it work for any chapter or section, but my parts appear to function differently… According to what the console seems to say, I believe that the centering used in the redefinition of the aspect of \part in the ToC is involved.

Any ideas how to include a working linebreak in there?

Thanks a lot!

Edit: Here is below a MWE!

% Minimal Working Example

\documentclass[12pt, twoside, openright]{book}

\usepackage{titletoc}
% Part aspect in ToC: vertical spacing before and after, centering, uppercase, no page number:
\titlecontents{part}[0em]{\addvspace{\baselineskip}\begin{center}}{}{\MakeUppercase}{}[\end{center}\addvspace{\baselineskip}]

\begin{document}

\part*{Title of my part\\Its subtitle}
\addcontentsline{toc}{part}{Title of my part\\Its subtitle} % Linebreak doesn't work!

\tableofcontents

\end{document}
FRND
  • 73
  • 1
    Welcome. Can you post a MWE? So we can compile your example? – Sango Sep 18 '19 at 11:31
  • Sorry you're right; just added one! Thanks! – FRND Sep 18 '19 at 12:21
  • I had to remove the center environment to get it compiled, than it seemed to be ok. Does the MWE compile for in your setup? Does it solve the problem to remove the center? – Sango Sep 18 '19 at 12:31
  • Yes exactly, that's my problem: without the centering everything is fine as you said, but I want this title/subtitle layout being centered in my ToC… – FRND Sep 18 '19 at 12:42
  • Have you tried this? https://tex.stackexchange.com/questions/67413/center-parts-in-toc-with-tocloft?rq=1 – Sango Sep 18 '19 at 12:50
  • I did have a look at this topic and tried accordinly a few things on my document, but I don't use a KOMA class… Even by trying to switch to “scrbook” I could not succeed to obtain what I want in the ToC… (Not to mention new problems that this quick change seemed to cause elsewhere! My document is already quite customised) – FRND Sep 18 '19 at 16:23

0 Answers0