# Hyphen that appears only if near end of line

I have a section with the title in the picture. If I don't put the hyphen manually, the word ultimo does not get hyphenated and stays on the first line, producing an Overfull \hbox. But as you can see, the manually put hyphen goes into the toc which is not nice. Is there a way to mark a hyphenation point or to insert a hyphen that will be put in only if the line breaks immediately after it?

PS In case you're wondering, the blue italic text conceals a link. I decided to highlight links that way. Any advice on that is welcome, though not properly on-topic in this question :).

• Use \- to hyphenate. For example ul\-ti\-mo. (I don't know Italian.) – Sigur Dec 27 '14 at 16:18
• Please post a MWE, otherwise we are just going to be guessing. – Andrew Swann Dec 27 '14 at 16:22
• Also, are you loading babel? \usepackage[italian]{babel} – Sigur Dec 27 '14 at 16:23
• @Sigur yes I am. Or at least the .log file says (/usr/local/texlive/2013/texmf-dist/tex/generic/babel/babel.sty Package: babel 2013/05/16 v3.9f The Babel package (/usr/local/texlive/2013/texmf-dist/tex/generic/babel-italian/italian.ldf Language: italian 2008/03/14 v1.2t Italian support from the babel system. – MickG Dec 27 '14 at 16:32
• @Sigur -- i am pretty sure that even using babel won't result in automatic hyphenation because of the apostrophe in the "word". so the "discretionary hyphen" is indeed the correct answer. post it, please. – barbara beeton Dec 27 '14 at 18:29

In this case, let LaTeX decide where the word should be hyphenated.

To do this, use \- to hyphenate.

For example ul\-ti\-mo. (I don't know Italian, so I don't know if this is the right way to split the word).

• Yes it is @Sigur :). – MickG Dec 29 '14 at 10:53

Too long for a comment. Don't vote, please: it's just for spurring the OP to produce an example.

This reproduces the title as in the image, and the hyphenation is obtained without manual intervention:

\documentclass[a4paper]{article}
\usepackage[textwidth=13.2cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[italian]{babel}
\usepackage{mathptmx}

\begin{document}

\tableofcontents

\renewcommand{\thesection}{6.\arabic{section}}
\setcounter{section}{3}

\section{Aggiustiamo la dimostrazione del primo pezzo dell'ultimo teorema}

Qualcos'altro per avere testo dopo il titolo.

\end{document}