# Section titles alignement with titletoc

with the following code

\documentclass{book}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{titletoc}

\titlecontents{chapter}
[0em]
{\vspace*{\baselineskip}}
{\mdseries \contentslabel[\thecontentspage] {0mm}  \hspace*{1.4em}  \chaptername
\,\,\thecontentslabel \\
\hspace*{2em} \itshape    \vspace*{0.3\baselineskip}}
{\mdseries   \thecontentspage \hspace*{1.2em}   \itshape}
{}
[]

\titlecontents*{section}
[0em]
{}
{\footnotesize \thecontentslabel~}
{}
{\footnotesize,~\thecontentspage}
[~--\ ]
[]

\begin{document}

\tableofcontents

\chapter{Events and Probability}
\section{Composite Events}
\section{Composite Events}
\section{An Application of Composite Events}
\section{Probability}
\section{The Probability of an Unknown Constant}
\section{A Confirmation}

\setcounter{page}{277}

\chapter*{Conclusion}

\end{document}


how can I align the left left margin of sections titles with the chapter title? I'm able to line up with an eye, but obviously it's a very bad idea... thanx

PS

Now I realize another problem. The starred chapter is not aligned with the other titles. why?

PS2

i add an image of that I'd like to obtain

PS 3 With this complete code

\documentclass{book}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{newpxtext,newpxmath}
\useosf
\usepackage{microtype}
\usepackage{titletoc}

\usepackage[margin=3cm,heightrounded]{geometry}
\usepackage{showframe}

% book -- titletoc patch: https://tex.stackexchange.com/a/454553/134574
\usepackage{etoolbox}
\makeatletter
\patchcmd\@part
{\thepart}
{\protect\numberline{\thepart}}
{}{\FAIL}
\makeatother

\makeatletter

\titlecontents{part}
[0em]
{\large\partname~\thecontentslabel\endgraf\bfseries}
{\large}
{} % without page number

\titlecontents{chapter}
[0em]
{\vspace*{\baselineskip}}
{\mdseries
\vspace*{0.3\baselineskip}%
\itshape
}
{\mdseries
\itshape
}
{}
[]

\titlecontents*{section}
[0em]
{}
{\footnotesize \thecontentslabel~}
{}
{\footnotesize,~\thecontentspage}
[~--~]
[]

\begin{document}

\renewcommand*\contentsname{\hfill\mdseries\huge Indice}
\tableofcontents

\chapter{Events and Probability}
\section{Composite Events}
\section{Composite Events}
\section{An Application of Composite Events}
\section{Probability}
\section{The Probability of an Unknown Constant}
\section{A Confirmation}

\chapter*{Conclusion}

\clearpage

\chapter{Events and Probability}
\section{Composite Events}
\section{Composite Events}
\section{An Application of Composite Events}
\section{Probability}
\section{The Probability of an Unknown Constant}
\section{A Confirmation}

\setcounter{page}{277}

\chapter*{Conclusion}

\end{document}


the page margins and the index margins are different. Why? Index is narrower as page.... You can see it in the picture under

• If I add a starred chapter to the ToC with \addcontentsline{toc}{chapter}{Conclusion} they look aligned... Can you please expand your MWE so that it shows the misalignment? – Phelype Oleinik Oct 16 '18 at 13:07
• I updated code, recompiled. same problem, as in the figure above – user41063 Oct 16 '18 at 13:20

You had some spurious spaces in your \titlecontents definition, for example:

\hspace*{1.4em} \chaptername


produces a larger space than

\hspace*{1.4em}\chaptername


You also was using \contentslabel incorrectly. This macro reserves some space to the left of the margin for the label. But form your picture I assumed you didn't want it, so I removed and used a plain \hbox with \llap. I also added the \part formatting from your other question:

Updated code:

\documentclass{book}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{titletoc}

% book -- titletoc patch: https://tex.stackexchange.com/a/454553/134574
\usepackage{etoolbox}
\makeatletter
\patchcmd\@part
{\thepart}
{\protect\numberline{\thepart}}
{}{\FAIL}
\makeatother

\usepackage{tikz}

\makeatletter

\contentsmargin[-1.55em]{1.55em}

\titlecontents{part}
[0em]
{\large\partname~\thecontentslabel\endgraf\bfseries}
{\large}
{} % without page number

\titlecontents{chapter}
[0em]
{\vspace*{\baselineskip}}
{\mdseries
\vspace*{0.3\baselineskip}%
\itshape
}
{\mdseries
\itshape
}
{}
[]

\titlecontents*{section}
[0em]
{}
{\footnotesize \thecontentslabel~}
{}
{\footnotesize,~\thecontentspage}
[~--~]
[]

\begin{document}

\tableofcontents

\addcontentsline{toc}{chapter}{\protect\tikz[remember picture, overlay]\protect\draw[red,ultra thick] (0,0) -- (0,-7);}

\chapter{Events and Probability}
\section{Composite Events}
\section{Composite Events}
\section{An Application of Composite Events}
\section{Probability}
\section{The Probability of an Unknown Constant}
\section{A Confirmation}

\chapter*{Conclusion}

\clearpage

\chapter{Events and Probability}
\section{Composite Events}
\section{Composite Events}
\section{An Application of Composite Events}
\section{Probability}
\section{The Probability of an Unknown Constant}
\section{A Confirmation}

\setcounter{page}{277}

\chapter*{Conclusion}