GeneralToC : how to make titles stay on a single line ?

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

ToC : how to make titles stay on a single line ?

Post by Cham »

I'm having a glitch with some section titles in the ToC. Some titles are a bit long and LaTeX put them in two lines. I would much prefer to show them on a single line only instead. Here's a MWE :

Code: Select all

\documentclass[11pt,letterpaper,twoside]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage{lmodern}
\usepackage{textcomp}
\usepackage{microtype}
\usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry}

\begin{document}

\tableofcontents

\newpage
\section{Présentation du cours}

\section{Contenu et programation des activités \newline d'apprentissage}

\end{document}
Here's a preview of what this code is doing and the problem indicated in red :
ToC.jpg
ToC.jpg (22.95 KiB) Viewed 1978 times
How to make the second title on a single line in the ToC ?

Recommended reading 2024:

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

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

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

ToC : how to make titles stay on a single line ?

Post by Johannes_B »

Use the optional argument.

Code: Select all

\documentclass[11pt,letterpaper,twoside]{article}
    \usepackage[T1]{fontenc}
    \usepackage[utf8]{inputenc}
    \usepackage[french]{babel}
    \usepackage{lmodern}
    \usepackage{textcomp}
    \usepackage{microtype}
    \usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry}
     
    \begin{document}
     
    \tableofcontents
     
    \section{Présentation du cours}
     
    \section{Contenu et programation des activités \newline d'apprentissage}
    \section{Hi \newline Cham}
    \section[Hi Wombat]{Hi \newline Wombat}
     
    \end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

ToC : how to make titles stay on a single line ?

Post by Cham »

Oh my god ! I apparently made a really stupid mistake. I didn't noticed the \newline command in my title ! :oops:

I'm an idiot ! Case appears to be trivially solved now !
Post Reply