Referring to this thread: Handle part (book class) with titletoc
, I've a new file, this time compiled with XeLaTeX (and no more with pdfLaTeX).
If I use the same code for titletoc, section titles are no more correctly aligned, I mean centered. It's very evident in the first part title, as you can see in the under picture:
The code:
\documentclass[a4paper,11pt]{book}
\usepackage{fontspec}
\usepackage{polyglossia}
\usepackage{titlesec,titletoc}
\usepackage{etoolbox}
\setmainfont{EB Garamond}
\setmainlanguage[babelshorthands=true]{italian}
\PolyglossiaSetup{italian}{indentfirst=false}
\frenchspacing
\makeatletter
\patchcmd\@part
{\thepart}
{\protect\numberline{\thepart}}
{}{\FAIL}
\makeatother
\makeatletter
\contentsmargin[-1.55em]{1.55em}
\titlecontents{part}
[0em]
{\addvspace{1.5pc}\filcenter}
{\large\partname~\thecontentslabel\endgraf\bfseries}
{\large}
{}
[\addvspace{.5pc}]
\titlecontents{chapter}
[4em]
{\vspace*{\baselineskip}\mdseries}
{\contentslabel[\hfill\thecontentslabel]{3em}\enspace}
{\hspace*{0.5em}}
{}
[]
\titlecontents{section}
[4em]
{\vspace*{.2\baselineskip}\mdseries\small}
{\contentslabel[\hfill\thecontentslabel]{3em}\enspace}
{}
{\hfill\llap{\makebox[\dimexpr\linewidth-1.3pc][l]{\makebox[1pc][r]{\thecontentspage}}}}
[]
\titlecontents*{subsection}
[4.525em]
{\footnotesize}
{}
{}
{, \thecontentspage}
[~--~]
[]
\makeatletter\@addtoreset{chapter}{part}\makeatother
\begin{document}
\tableofcontents
\part{Title}
\chapter{First Chapter}
\chapter{Second Chapter}
\part{Long Title of the Second Part}
\chapter{First Chapter}
\chapter{Second Chapter}
\part{Very Long Title of the Third Part}
\chapter{First Chapter}
\chapter{Second Chapter}
\end{document}
What could be the cause of the problem? Thanks!


