LaTeX forum ⇒ GeneralToC : how to make titles stay on a single line ? Topic is solved

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

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

Postby Cham » Fri Oct 13, 2017 1:59 pm

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 :

  1. \documentclass[11pt,letterpaper,twoside]{article}
  2. \usepackage[T1]{fontenc}
  3. \usepackage[utf8]{inputenc}
  4. \usepackage[french]{babel}
  5. \usepackage{lmodern}
  6. \usepackage{textcomp}
  7. \usepackage{microtype}
  8. \usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry}
  9.  
  10. \begin{document}
  11.  
  12. \tableofcontents
  13.  
  14. \newpage
  15. \section{Présentation du cours}
  16.  
  17. \section{Contenu et programation des activités \newline d'apprentissage}
  18.  
  19. \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 183 times


How to make the second title on a single line in the ToC ?

User avatar
Johannes_B
Site Moderator
Posts: 3598
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Fri Oct 13, 2017 4:13 pm

Use the optional argument.

  1. \documentclass[11pt,letterpaper,twoside]{article}
  2. \usepackage[T1]{fontenc}
  3. \usepackage[utf8]{inputenc}
  4. \usepackage[french]{babel}
  5. \usepackage{lmodern}
  6. \usepackage{textcomp}
  7. \usepackage{microtype}
  8. \usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry}
  9.  
  10. \begin{document}
  11.  
  12. \tableofcontents
  13.  
  14. \section{Présentation du cours}
  15.  
  16. \section{Contenu et programation des activités \newline d'apprentissage}
  17. \section{Hi \newline Cham}
  18. \section[Hi Wombat]{Hi \newline Wombat}
  19.  
  20. \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: 826
Joined: Sat Apr 02, 2011 4:06 pm

Postby Cham » Fri Oct 13, 2017 5:01 pm

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 !


Return to “General”

Who is online

Users browsing this forum: No registered users and 8 guests