Narrowing ToC with titletoc

Following up this question of mine (Increase margin in section titles with titlesec), I'd like to configure my Table of Contents in a similar way, mainly to substitute the bold font for section titles with a slightly larger font and to remove the dotted lines. MWE:

\documentclass{article}
\usepackage{titletoc}
\titlecontents{section}
[0pt]
{}
{\Large\thecontentslabel\enspace}
{}
{\hfill\contentspage}
[]
\begin{document}
\tableofcontents
\section{This is another long long long long long long section name}
\end{document}


The goal is to get in the ToC:

1. This is another long long long long
long long section name


1. This is another long long long long long long sec-
tion name


So no hyphenation and a specified length. This is to prevent something like this in my document. The package documentation is not very clear to me. The command \contentsmargin{2.5cm} does indeed manipulate the right margin in the way I need it but it leads to some misplaced page numbers too.

• Please post a small complete code that illustrates your problem. Jul 24, 2021 at 18:00
• I use LyX and it is hard to reproduce. One section title is just long enough to reach the right margin without a line break so that the page number follows it on the next line but on the left hand side. I also copied the code above from another answer and don't really understand the syntax of titletoc. As said, I want to substitute the bold font of section titles with a larger font and to remove the dotted lines. Jul 24, 2021 at 18:22
• Can't make with Lyx a small fake document and post the resulting code? Jul 24, 2021 at 18:27
• I edited my question with a MWE. Some general remarks about the differences between dottedcontents, titlecontents and contentsmargin would be greatly appreciated! Jul 24, 2021 at 18:38
• Answer updated after your edit. No hyphenation and adjustable title width. Jul 24, 2021 at 21:42

UPDATE no hyphenation plus a narrow section title by adjusting its left and right "margins".

\documentclass{article}

\usepackage{titletoc}

\titlecontents{section}%
[0mm]%
{\Large\raggedright}% no hyphenation
{\contentspush{\makebox[75mm][l]{\thecontentslabel.} \hspace{-45mm}}}% use the makebox width and the \hspace to set the title
{}%
{\contentsmargin{25mm}\hfill\contentspage}%
[\vspace{3ex}]

\begin{document}
\tableofcontents
\newpage
\section{As any dedicated reader can clearly see, the Ideal of
practical reason is a representation of the things
in themselves.}
\section{IntroductionIntroduction IntroductionIntroductionI}
\end{document}


Try this code.

\documentclass{article}

\usepackage{titletoc}

\titlecontents{section}% <section-type>
[2.3em]%  align left
{\Large}% <above-code> Larger font <<<<<<<<<<<
{\hspace*{-1.5em}\makebox[1.5em][l]{\thecontentslabel.}}% <numbered-entry-format>
{}% <numberless-entry-format>
{\hfill\contentspage}% <filler+ page-format>
[\vspace{2ex}]

\begin{document}
\tableofcontents
\newpage
\section{As any dedicated reader can clearly see, the Ideal of
practical reason is a representation of the things
in themselves.}
\section{IntroductionIntroduction IntroductionIntroductionI}
\end{document}

• Thank you! Unfortunately, one page number is still on the left side. I added a graphic above. What does the 1.5em indicate in your code? Jul 24, 2021 at 19:13
• @johnny7 Which number? Jul 24, 2021 at 19:17
• @johnny7 [1.5em] is the indent used in book . Change the value and see what happens. Jul 24, 2021 at 19:18
• With a specific length of a chapter name, the page number still appears left as in the image I added in my question, no matter whether I use the makebox. Jul 24, 2021 at 19:35
• @johnny7 Are you able to compile my code, as it is? Jul 24, 2021 at 19:38