3

MWE:

\documentclass{scrartcl}
\RequirePackage[utf8]{inputenc}
\RequirePackage[T1]{fontenc}
\RequirePackage[a4paper,includeheadfoot,inner=2.4cm,outer=2cm,top=1.78cm,bottom=1.5cm,twoside,headheight=1.1cm,headsep=0.9cm,foot=1.2cm]{geometry}
\renewcommand{\familydefault}{\sfdefault}
\RequirePackage[varqu,varl]{inconsolata}

\setlength{\parskip}{0.3cm}
\setlength{\parindent}{0cm}

\begin{document}

Falls Sie von einer VerA.web-Version, die die Konfigurationsdateien
noch nicht in \texttt{/etc/veraweb} ablegt, aktualisieren, müssen Sie
dort zunächst (nur) die gegenüber den in der \texttt{veraweb.war}
ausgelieferten Dateien angepaßten Konfigurationen aus dem Verzeichnis
\texttt{/var/lib/tomcat7/webapps/veraweb/OCTOPUS/config\_*.xml}
Ihrer alten Installation hinkopieren.

\end{document}

(Note, these aren’t the actual page margins we use; I tweaked it to exhibit the issue with the standard font as well.)

This renders as:

rendering of MWE

How can I tell pdflatex (which we run twice already anyway) to always prevent such runoffs, at the cost of slightly worse spacing of the surrounding lines (intra-word, or possibly hanging lines) automatically?

To be clear: I know I could shuffle the text in the paragraph around a bit to fix this (and I do), but this requires manual effort, and changing the text to match the formatting is not quite what I thought Teχ was for, so I wish to have an automatic solution (I could still see places with bad spacing in the PDF output and do the shuffle dance, but I no longer would be required to manually review each and every single PDF built from the source after each change).

Alenanno
  • 37,338
mirabilos
  • 808

2 Answers2

4

After reading this answer detailling which does what, and what \sloppy internally does, I’ve decided to go with the following, for now:

% Zu lange Zeilen
\emergencystretch 5em%

The value of 5 em is probably too large, but it doesn’t seem to hurt so far and judging from the documentation.

mirabilos
  • 808
0

You need to say how to get enough white space to allow the unbreakable string to go to a new line, two possibilities, allow larger inter-word stretch or allow white space at ends of lines.

enter image description here

\documentclass{scrartcl}
\RequirePackage[utf8]{inputenc}
\RequirePackage[T1]{fontenc}
\RequirePackage[a4paper,includeheadfoot,inner=2.4cm,outer=2cm,top=1.78cm,bottom=1.5cm,twoside,headheight=1.1cm,headsep=0.9cm,foot=1.2cm]{geometry}
\renewcommand{\familydefault}{\sfdefault}
\RequirePackage[varqu,varl]{inconsolata}

\setlength{\parskip}{0.3cm}
\setlength{\parindent}{0cm}

\begin{document}

{\sloppy
Falls Sie von einer VerA.web-Version, die die Konfigurationsdateien
noch nicht in \texttt{/etc/veraweb} ablegt, aktualisieren, müssen Sie
dort zunächst (nur) die gegenüber den in der \texttt{veraweb.war}
ausgelieferten Dateien angepaßten Konfigurationen aus dem Verzeichnis
\texttt{/var/lib/tomcat7/webapps/veraweb/OCTOPUS/config\_*.xml}
Ihrer alten Installation hinkopieren.

}

{\raggedright
Falls Sie von einer VerA.web-Version, die die Konfigurationsdateien
noch nicht in \texttt{/etc/veraweb} ablegt, aktualisieren, müssen Sie
dort zunächst (nur) die gegenüber den in der \texttt{veraweb.war}
ausgelieferten Dateien angepaßten Konfigurationen aus dem Verzeichnis
\texttt{/var/lib/tomcat7/webapps/veraweb/OCTOPUS/config\_*.xml}
Ihrer alten Installation hinkopieren.

}

\end{document}
David Carlisle
  • 757,742
  • Almost good… but this still requires me to add \sloppy to the paragraphs manually. Can I set this globally, and is that actually a good idea to do? – mirabilos Jan 12 '16 at 12:58
  • @mirabilos sure you can put it at the start of the document. It's a good idea if that's what you want, a bad idea if only parts of the text have difficult content and need it (you can turn it off with \fussy if you do not use a group) – David Carlisle Jan 12 '16 at 13:00
  • OK thanks, I’ll play with this later (on a deadline again). – mirabilos Jan 12 '16 at 13:03
  • @DavidCarlisle Doesn't \sloppy create underfull boxes? – Alenanno Jan 12 '16 at 13:33
  • @Alenanno it depends how you define things, it increases tolerance which means that more stretch is allowed before things are counted as underfull, and it sets emergencystretch which adds extra stretch that is distributed across the paragraph so tex can act as if the lines were not underful even if tolerance would otherwise be exceeded. – David Carlisle Jan 12 '16 at 13:44