Text FormattingPrevent hyphenation in TOC

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
Harmont
Posts: 13
Joined: Tue Aug 31, 2010 3:52 pm

Prevent hyphenation in TOC

Post by Harmont »

Hello guys,

Does somebody know how to prevent hyphenation in table of contents? To prevent hyphenation in headings throughout the text I use

Code: Select all

\usepackage[raggedright]{titlesec}
But I can't find out how to do that in TOC.

Thanks in advance,
Nikita
Last edited by Harmont on Sun Sep 12, 2010 12:25 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Prevent hyphenation in TOC

Post by gmedina »

Hi, Nikita

you can use the optional argument of the sectioning commands and the change line command \\ as the following example suggests (the text is some non-sense sentence in Spanish, but the idea is the same for any language):

Code: Select all

\documentclass{article} 
\usepackage[spanish]{babel}
\usepackage[raggedright]{titlesec}

\begin{document}
\tableofcontents

\section[Espero que tanto trigonom\'etricamente se particione este\\ encabezado]{Espero que tanto trigonom\'etricamente se particione este encabezado}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Harmont
Posts: 13
Joined: Tue Aug 31, 2010 3:52 pm

Re: Prevent hyphenation in TOC

Post by Harmont »

Perfect. Thank you.
Post Reply