5

Code:

\documentclass[10pt,paper=14.8cm:21cm,BCOR=10mm,DIV=12,parskip=half]
{scrbook}
\usepackage[T1]{fontenc}
\usepackage[german]{babel}
\usepackage[utf8]{inputenc}
\begin{document}
Markus hat den Krieg überstanden, hat Zahnmedizin studiert und wurde
Zahnarzt in Bonn. Aus der Ehe mit Manuela Schmidt (1905–1989) gingen vier
Kinder hervor: Otto (1926–1995), Marta (geb. 1931), Fritz (1933–1999) und
Sonja (geb. 1942).
\end{document}

Output:

Text as rendered from above code

Desired output:

Text rendering as desired

To avoid overly long lines, I'd like to tell LaTeX that it's OK to line break date ranges.

Ruben
  • 13,448
feklee
  • 905
  • I think according to http://tex.stackexchange.com/questions/5036/, something like (1905-{\allowbreak}1989) would do the trick. – Thomas Weise Jul 19 '15 at 21:16
  • 1
    if you use the minus sign you can replace it with "=; also works for combined words like Mehrzweck"=Küchenmaschine – musicman Jul 19 '15 at 22:30

1 Answers1

3

I suggest you replace all instances of "" (hardcoded en-dash) with "--\allowbreak". (Aside: if your document has hard-coded em-dashes, you may want to replace them with "---\allowbreak".) The "\allowbreak" part is needed if you compile your document with LuaLaTeX; it's not strictly necessary with pdfLaTeX (though it doesn't hurt either).

For the paragraph at hand, one of the three possible new line breaks will be used.

enter image description here

\documentclass[10pt,paper=14.8cm:21cm,BCOR=10mm,DIV=12,parskip=half]
{scrbook}
\usepackage[T1]{fontenc}
\usepackage[german]{babel}
\usepackage[utf8]{inputenc}
\begin{document}
Markus hat den Krieg überstanden, hat Zahnmedizin studiert und wurde
Zahnarzt in Bonn. Aus der Ehe mit Manuela Schmidt (1905--\allowbreak 1989) 
gingen vier Kinder hervor: Otto (1926--\allowbreak 1995), Marta (geb. 
1931), Fritz (1933--\allowbreak 1999) und Sonja (geb. 1942).
\end{document}
Mico
  • 506,678
  • I feel like there was a way to automate this with \newunicodechar or something – Sean Allred Jul 19 '15 at 22:45
  • Why do you recommend replacing the hard coded dash with --? – feklee Jul 19 '15 at 22:45
  • @feklee - The \allowbreak directive is necessary if the document is compiled under LuaLaTeX. With pdfLaTeX, it's not required, but it doesn't hurt either. I'll add a note to the answer to point out this distinction. – Mico Jul 19 '15 at 22:48
  • What do you think about avoiding the hard-coding via \newcommand{\daterange}[2]{#1--\allowbreak#2} or something similar? – Ruben Jul 19 '15 at 23:59
  • @Ruben -- Sure, that'll work very well. – Mico Jul 20 '15 at 00:07
  • 1
    @Ruben Try this on for size: \def\daterange#1{\daterangei#1\stop}\def\daterangei#1-#2\stop{#1--\allowbreak#2}...\daterange{1926-1995}. (Untested, but should work. A more robust implementation is possible with \tl_replace_all:Nnn from expl3.) – Sean Allred Jul 20 '15 at 02:42
  • @SeanAllred -- I like the interface design of your version is way better ;) – Ruben Jul 20 '15 at 10:37