[Tex/LaTex] How to avoid using \sloppy document-wide to fix overfull \hbox problems

line-breakingparagraphs

How to avoid using \sloppy document-wide to fix overfull \hbox problems?

overfull \hbox

This is my minimal working example.

\documentclass[12pt]{report}
 \usepackage[english,ngerman]{babel}
 \usepackage[a4paper,inner=25mm,outer=25mm,top=30mm,bottom=30mm]{geometry}
 \usepackage{lipsum}

 \begin{document}
  \lipsum[2]
  Have a look at this URL ignoring the page margin within the text flow \textit{example.com/donc\_oe/longurl} lorem ipsum.\par
  The very strange plugin Java-JDT (\textit{en. Java Development Toolkit}) "`Plugin-Entwicklungsumgebung"' -- what's wrong with this german word?\par
  \lipsum[2]
 \end{document}

With \sloppy it looks better.

enter image description here

But I got told it's (obviously) better to avoid using it document-wide. What else can I do?

Best Answer

  • When typesetting URLs, use the url package, since it provides adequate line-breaking support. If needed, you can change the typeface it uses in its display (default is \ttfamily).

  • Words not covered by default hyphenation (or that provided by babel can be incorporated in an ad-hoc way using \- or globally using \hypenation{<this-is-an-awk-ward-ly-long-word>}.

enter image description here

\documentclass[12pt]{report}
\usepackage[english,ngerman]{babel}% http://ctan.org/pkg/babel
\usepackage[a4paper,inner=25mm,outer=25mm,top=30mm,bottom=30mm]{geometry}% http://ctan.org/pkg/geometry
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\usepackage{url}% http://ctan.org/pkg/url
\begin{document}
\lipsum[2]
Have a look at this URL ignoring the page margin within the text flow \url{example.com/donc_oe/longurl} lorem ipsum.\par
The very strange plugin Java-JDT (\textit{en. Java Development Toolkit}) "`Plugin-Ent\-wick\-lungs\-umge\-bung"' -- what's wrong with this German word?\par
\lipsum[2]
\end{document}