0

I want to have a part name in more than one line in the ToC, but then the lower lines aren't aligned as the first one. How can I fix that? See pic below. The \documentclass is a report.

ToC part alignment

  • 1
    Welcome to tex.sx. How this is done will depend on what \documentclass you are using, and you haven't specified that. (Recommendation: Use ragged right when supporting long toc entries. Otherwise, they can look perfectly horrible with very uneven word spacing.) – barbara beeton May 22 at 20:10
  • I use report document class. – Mak Pavičević May 22 at 20:16
  • Could you please post a minimal compilable code that we can play with? – Bernard May 22 at 21:16
  • I don't know how this could help you, but alright, here it is \documentclass[12pt,a4paper]{report} \begin{document} \tableofcontents \include{part1} \include{part2} \end{document} and then chapters and parts are in part1 and part2 – Mak Pavičević May 23 at 12:12
1

Here is a solution. you can replace 2em with a more precise dimension.

\documentclass[12pt,a4paper]{report}
\usepackage{etoolbox}
\makeatletter 
\patchcmd{\l@part}{\parindent}{\hangindent 2em \parindent}{}{\err}
\makeatother


\begin{document}
\tableofcontents
\part{Here is a part name in more than one line in the ToC, with the lower lines  aligned as the first one}
\chapter{A chapter of foo}
\end{document} 
  • Thaaaaaank youuuu very much! – Mak Pavičević May 27 at 18:14
  • @MakPavičević you're welcome, – touhami May 27 at 19:39

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.