[Tex/LaTex] Linebreak between numbers connected by dash

hyphenationline-breakingpunctuation

In my text I am using lots of dates. Now I have the following problem: 1480–1541 (two figures and between them a dash) appears at the end of one line and extends over the line into the margin space without being properly broken into the next line. I guess this is caused by the dash. Something like 1480–\-1541 does not work, since it adds an extra hyphen. So, how I can achieve the proper result:

... ... ... 1480–
1541?

Best Answer

Sebastian,

I believe what you want for this is \emergencystretch, for example \emergencystretch=3em. This allows TeX a bit more flexibility when it applies its line-breaking algorithm.

Here is a simple example, followed by a picture. Try it out with different values between 0em (the LaTeX default) and 5em and let us know if that works for you.

 \documentclass{article}
 \usepackage{amsmath}
 \setlength{\topmargin}{-1.3in}
 \setlength{\textheight}{11in}
 \begin{document}

 \newcommand{\composers}{\noindent
 A short list of famous composers includes Bach (1685--1750),
 Beethoven (1770--1827), Brahms (1833--1897), Chopin (1810--1849),
 Elgar (1857--1934), Handel (1685--1759), Haydn (1732--1809),
 Holst (1874--1934), Gustav (1860--1911), Mendelssohn (1809--1847),
 Mozart (1756--1791), Scarlatti (1685--1757), Schubert (1797--1828),
 Schumann (1810--1856), Shostakovich (1906--1975), Sibelius (1865--1957),
 Tchaikovsky (1840--1893), and Vivaldi (1678--1741).\par}

 \emergencystretch=3em
 \composers\narrower\composers\narrower\composers\narrower\composers
 \narrower\composers\narrower\composers\narrower\composers

 \end{document}

And here's how that looks — no more overfull or underfull boxes. :)    It's not perfect, but it may just do the trick for the text you are typesetting. How wide/narrow are your margins? This sample output below progresses through several narrowings: