0

enter image description here

enter image description here

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 :).

MickG
  • 5,426
  • 2
    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
  • @MickG, did my 1st comment solve your problem? – Sigur Dec 27 '14 at 16:34
  • @Sigur yes it seems to. The hyphen is now there in the page but not in the toc. – MickG Dec 27 '14 at 17:12
  • 2
    @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
  • @Sigur You should turn your first comment into an answer. – cryingshadow Dec 27 '14 at 21:18
  • @barbarabeeton an actual experiment, with italian babel and t1 encoding, gives \T1/cmr/m/n/10 del-l'ul-ti-mo from \showhyphens ... faintly surprises me, too, but i don't speak italian either. – wasteofspace Dec 27 '14 at 22:01
  • @barbarabeeton The apostrophe, when the Italian language is active, receives \lccode`'=`', so it counts as a letter, as far as hyphenation is concerned. – egreg Dec 29 '14 at 10:54
  • @MickG Since, as you see below, hyphenation happens without any manual intervention, there's something in your document that prevents it. Maybe you have \raggedright in the titles, which stops hyphenation. – egreg Dec 29 '14 at 11:04
  • @egreg I am not doing anything like that explicitly as far as I know. I am using a lot of packages and the report class though. Could they be responsible? Among my packages, mathptmx multicolumn multirow fontspec xunicode hyperref thmtools babel and many many more. – MickG Dec 29 '14 at 12:03
  • @MickG Without a minimal example showing the behavior it's difficult to say. It may just be a problem due to the line width. If you have long section titles it's indeed a good idea to set them ragged right. – egreg Dec 29 '14 at 13:46
  • @egreg -- thanks for explanation. (my knowledge of italian is only slightly better than my knowledge of sanskrit. very low.) – barbara beeton Dec 29 '14 at 14:18
  • @egreg as for the line width, I use \usepackage[top=3cm, bottom=3.5cm, outer=4cm, inner=4cm, marginparsep=0.7cm, marginparwidth=1.5cm]{geometry}. – MickG Dec 29 '14 at 15:54

2 Answers2

2

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).

Andrew Swann
  • 95,762
Sigur
  • 37,330
2

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}

enter image description here

egreg
  • 1,121,712