[Tex/LaTex] Underfull \hbox in bibliography

bibliographieshorizontal alignmentline-breakingurlswarnings

I am getting lots of "Underfull \hbox" warnings that point to the *.bbl file. It looks like these messages appear only when URLs are very long, like in the below example:

@techreport{nistguidesec,
  author    = {Wayne Jansen and Timothy Grance},
  title     = {Guidelines on Security and Privacy in Public Cloud Computing},
  month    = {January},
  note     = {Draft Special Publication 800-144. Available at \url{http://csrc.nist.gov/publications/drafts/800-144/Draft-SP-800-144_cloud-computing.pdf}},
}

In the produced PDF text is correctly hyphened and links are correctly split over several lines (I am using hyperref package)

How can I avoid annoying warning messages about "underfull \hbox" pointing to bibliography?

Best Answer

Because "line-breaking in the bibliography is often more difficult than in the body text" (biblatex manual, p. 91), LaTeX typesets the bibliography using the \sloppy macro which relaxes some of TeX's parameters/penalties for line-breaking. However, \sloppy (maybe for some good reason!) does not touch \hbadness which is (among other things) responsible for "Underfull \hbox" warnings. The following code (to be added to your preamble) appends \hbadness 10000 to \sloppy which should remove those warnings.

\usepackage{etoolbox}
\apptocmd{\sloppy}{\hbadness 10000\relax}{}{}

Alternatively (and without possible adverse affects), you could typeset the bibliography \raggedright:

\usepackage{etoolbox}
\apptocmd{\thebibliography}{\raggedright}{}{}

Minimal example (compilable):

\documentclass{article}

\textwidth 300pt

\usepackage{etoolbox}
% Variant A
\apptocmd{\sloppy}{\hbadness 10000\relax}{}{}
% Variant B
% \apptocmd{\thebibliography}{\raggedright}{}{}

\usepackage{hyperref}

\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@techreport{nistguidesec,
  author    = {Wayne Jansen and Timothy Grance},
  title     = {Guidelines on Security and Privacy in Public Cloud Computing},
  month    = {January},
  note     = {Draft Special Publication 800-144. Available at \url{http://csrc.nist.gov/publications/drafts/800-144/Draft-SP-800-144_cloud-computing.pdf}},
}
\end{filecontents}

\begin{document}

\nocite{*}

\bibliographystyle{plain}
\bibliography{\jobname}

\end{document}

(The filecontents environment is only used to include some external files directly into the example, so that it compiles. It is not necessary for the solution.)