Thursday, May 3, 2018

Breaking Long URL in LaTeX Documents

Sometimes we wish to break a long URL in a LaTeX document.  I am among many people who have struggled with this. The following summarizes the answers I found online,

  1. Pass hypens to the url package that is referenced in the hyperref package, e.g.,

  2. However, the above would not work when the long URL has hyphens to avoid confusion by design. To break a long URL that has hyphens, we can use


  3. In the above, LaTeX works hard and attempts to break the long URL at some location. If the location is not to our liking, we add the \sloppy command right before the reference to an URL, e.g.,

The above is the summaries of the following two discussions,
  1. How to break long url in an item
  2. Forcing linebreaks in \url
Great discussions, folks. Thanks.