linebreak in long URL? Breakurl won't break it

There are several questions on this site (for example here and here) where people are struggling with overfill hboxes when making clickable URLs. I have read and tried the answers there and none of them seem to work for me, so I thought I would ask a new question.

Here's a minimal example of my problem:

\documentclass[english]{amsart}
\usepackage[anythingbreaks]{breakurl}
\begin{document}
Here's a longish sentence so I can just keep track of where the
end of the page is as far as normal line breaks are concerned.

However, Blah de blah de blah de blah
blah ~\href{https://blahblaaaaaaaaaaaaaaa.aaaaaaaaa.com/xxxx/xx/xx/blaaah-bl-blaaaah-bla/}{https://blahblaaaaaaaaaaaaaaa.aaaaaaaaa.com/xxxx/xx/xx/blaaah-bl-blaaaah-bla/} an argument which shows that\ldots
\end{document}


I have a sentence with pretty much this syntax/length in a paper I'm writing (including the URL which is the same length as the one I'm quoting and has slashes, hyphens, full stops in the same place). When I run the above through pdflatex I get an overfill hbox and this:

I don't care where that URL breaks, but I am reluctant to just break it myself because this paper has been accepted by a journal and they might well play with the margins etc and end up re-breaking something if I fix it in an ad hoc manner.

I had thought that breakurl, especially with its relatively new anythingbreaks option, would just break the URL to fit it on the page. As you can see, it hasn't done so.

Here are the things I've tried:

• Adding \usepackage[hyphens]{url} in various places.

• Discovering that breakurl will only break URLs after one of :/.?#&_,;! (but there's a . in the URL (the first one) after which it would be a perfect place to break the URL)

• Using \sloppy (changed nothing)

• \def\UrlBreaks{\do\/\do-\do.} (changed nothing)

I guess what I want in this case is the break after blahblaaaaaaaaaaaaaaa. I do not understand why I cannot persuade the URL to break here. Can anyone help?

To make matters worse, when my coauthor uploaded the paper to ArXiv, ArXiv choked on the TeX, possibly because it didn't have the most recent breakurl so choked on [anythingbreaks], and possibly because it was complaining about an options clash with hyperref. However this problem might go away once I've broken this URL.

EDIT2:

According to the hyperref-manual, breaklinks is automatically set by the driver. A manual override as tried results in the behaviour as experienced by QO.

If you don't mask the URL in

\href{long URL goes here}{here goes a masking label}


then you could simply use (using \usepackage{hyperref} or \usepackage[hyphens]{url})

\url{long URL}


with the result of having a correctly typeset URL.

Code as follows. See result in 1:

\documentclass[english]{amsart}
\usepackage[
bookmarksopen,
bookmarksdepth=2,
]{hyperref}

\begin{document}
Here's a longish sentence so I can just keep track of where the
end of the page is as far as normal line breaks are concerned.

However, Blah de blah de blah de blah
blah ~\url{https://blahblaaaaaaaaaaaaaaa.aaaaaaaaa.com/xxxx/xx/xx/blaaah-bl-blaaaah-bla/} an argument which shows that\ldots
\end{document}


EDIT:

Same code with some improvements. See result in 2:

\documentclass[english]{amsart}
\usepackage{xcolor}
\usepackage[
bookmarksopen,
bookmarksdepth=2,
urlcolor=blue]{hyperref}

\begin{document}

%using \url{URL}
However, Blah de blah de blah de blah
blah \url{https://blahblaaaaaaaaaaaaaaa.aaaaaaaaa.com/xxxx/xx/xx/blaaah-bl-blaaaah-bla/} an argument which shows that\ldots

%using \href{URL}{text}

\end{document}


• This works for me! Many thanks. So I seem to deduce from this that I don't need breakurl to break a URL? – Kevin Buzzard Mar 14 '16 at 11:11
• @KevinBuzzard: I've never used breaklinks therefore I'm cluesless as when to use it. Usually the url with [hyphens] or hyperref works fine for me. – naphaneal Mar 14 '16 at 11:24
• According to the hyperref-manual, breaklinks is automatically set by the driver. A manual override as you have tried result in the experienced behaviour. – naphaneal Mar 14 '16 at 11:40
• @naphaneal Concerning \href, your example has a long link but a short alternative text. I was looking for a way to line-break the alternative text, i.e., the second argument to \href. Is that possible? – dow Mar 21 at 2:38
• @dow according to what I understand, \href is not supposed to be used with large masking labels. usually, you use short labels. having said that, my guess is it should be working with larger labels as well, assuming it doesn't exceed the character limit, so far one is applied. I don't know, what this limit is, though. – naphaneal Mar 21 at 15:21