1

I am using this template from Overleaf. I used the following packages to fix my overfull hbox errors:

\usepackage[hyphens]{url}
\usepackage[breaklinks]{hyperref}

Most of the URLs were then fixed, except for this one that still overflows: enter image description here

The URL in question is https://saanyan.github.io/saanmaycommunitypantry/. It seems to be the only one that can't be broken.

Any and all advice would be appreciated. Thank you!

dagitab
  • 13
  • 2
    The URL is too long to brake nicely. \emergencystretch may help here, but may have to stretch things too far. If you load \usepackage{xurl} URLs can break anywhere, which definitely improves this URL's line breaking. – moewe Jul 20 '21 at 05:13
  • See also https://tex.stackexchange.com/q/442308/35864 for a longer discussion on line breaking in the bibliography. – moewe Jul 20 '21 at 05:15
  • You haven't shown the code to reproduce the screenshot, so it is impossible to know what's going on, but the different indentation between the entries shown in the image looks a bit odd. You may want to verify that everything is as you expect and make sure TeX reports no errors. – moewe Jul 20 '21 at 05:16

1 Answers1

2

URLs can be really problematic for breaking and in your case you have a super-long word in the middle of a URL which doesn't allow for any good break points.

The best hope here is to tell LaTeX that lots of extra space is OK during the bibliography. Adding something like

\emergencystretch=1em

Before the bibliography will tell LaTeX that if it can't find a good breakpoint¹, it can add up to an extra em of space to try fixing line breaks. You may need to boost the size of \emergencystretch, but it will eventually fix your line break in the bibliography.


  1. A lot of people will try to do things by adjusting \tolerance to allow sloppier line breaking (and this is exactly what \sloppy did historically, although it was changed to incorporate \emergencystretch at some point in the years after TeX 3.0 was released). I find that judicious use of \emergencystretch always produces better results.
Don Hosek
  • 14,078