0

Here is my code:

\documentclass{amsart}

\usepackage{hyperref}


\usepackage[svgnames]{xcolor}

\hypersetup{%
    colorlinks=true,
    urlcolor=Blue
}

\begin{document}


    \url{https://math.stackexchange.com/questions/2893035/propositional-logic-notation-conversions-and-naming}

    \url{https://www.google.de/search?ei=zcaPW8DmHMPLwQLm_6jgBw&q=table&oq=table&gs_l=psy-ab.3..0l10.28636.29973.0.30300.5.4.0.1.1.0.191.677.0j4.4.0....0...1c.1.64.psy-ab..0.5.674....0.UqDEfSRjRB0}


\end{document}

Why the second url correctly goes to next line correctly and the first url don't (goes beyond the horizontal margin of page)?

vasili111
  • 377
  • By default \url only allows line breaks at certain points (., \, /, ...). To avoid confusion with hyphenations, URLs are not broken after -. In your first URL there is no good break point to perform a line break. You can load \usepackage[hyphens]{url} before \usepackage{hyperref} to allow breaks after - as well. But that won't help with all URLs. So if you have further problems have a look at https://tex.stackexchange.com/q/3033/35864 – moewe Sep 05 '18 at 14:56
  • @moewe any way to force linebreak? – vasili111 Sep 05 '18 at 14:57
  • 1
    In your example \usepackage[hyphens]{url} already helps. \usepackage{xurl} is more radical and allows breaks everywhere, so it might mercilessly cut words in unfortunate places, but it will break the URL. – moewe Sep 05 '18 at 14:59
  • Theoretically you could also write a macro where you can control the breaking manually, I wrote a very naive implementation for that in a German forum (https://golatex.de/viewtopic,p,102225.html#102225). With \manualurlbreak you have to mark up each acceptable line break with \: (good break) or \. (acceptable break). – moewe Sep 05 '18 at 15:02
  • @moewe Both works great! If you wish to make an answer and I will accept it. If not I will add an answer later. – vasili111 Sep 05 '18 at 15:12
  • I guess this would be a duplicate of https://tex.stackexchange.com/q/3033/35864 then. – moewe Sep 05 '18 at 15:12

0 Answers0