# Lines with texttt reach into the page border, how to prevent?

MWE:

\documentclass{scrartcl}
\RequirePackage[utf8]{inputenc}
\RequirePackage[T1]{fontenc}
\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:

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

• Why are you using \RequirePackage? That's not how you conventionally load packages in a document (although it's almost technically the same). Go see this question, does it help? How to get long \texttt sections to break Jan 12 '16 at 10:17
• @Alenanno the person who wrote the house .sty file did; if I can improve, do tell. The question doesn’t help, as the texttt block should not be broken (i.e. current behaviour is good), but thanks anyway. Jan 12 '16 at 10:20
• Well, if it can't break, then your only option is to show the link alone in a new line. There aren't any more options than that. Jan 12 '16 at 10:22
• Would it be possible to show the link in a footnote? Jan 12 '16 at 10:30
• @Alenanno Which part of automatically do you not understand? I already wrote this in the question, but I’ll repeat it for you: if I spot these cases in the document, I can take manual action, but I want it to at least not spread content into the page margin automatically. Jan 12 '16 at 12:42

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.

• Perfect. Worked like magic. May 29 '19 at 8:56
• does not work for me Dec 1 '19 at 23:11
• @JFFIGK adjust the value if needed (will look uglier though) Dec 2 '19 at 19:27

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.

\documentclass{scrartcl}
\RequirePackage[utf8]{inputenc}
\RequirePackage[T1]{fontenc}
\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}

• 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? 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) Jan 12 '16 at 13:00
• OK thanks, I’ll play with this later (on a deadline again). Jan 12 '16 at 13:03
• @DavidCarlisle Doesn't \sloppy create underfull boxes? 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. Jan 12 '16 at 13:44