# Forcing linebreaks in \url does not work with biblatex and menukeys

This question is related to “Forcing linebreaks in \url. One of its answer is to pass the hyphens option to the url package:

\PassOptionsToPackage{hyphens}{url}
\usepackage{hyperref}


As I have my own class file, I adapted the commands to be:

\PassOptionsToPackage{hyphens}{url}
\RequirePackage{hyperref}


However, the line \PassOptionsToPackage{hyphens}{url} is clashing on my side and I got this error message: Option clash for package url. \let.

Then, I tried to replace that line with \requirePackage[hyphens]{url}, but since hyperref already defines implicitly url, I got the error Option clash for package url. \RequirePackage.

I even tried the hyperref package option breaklinks=true but this did not help and the latter is reported to only work with slashes not dashes like I want.

Any idea? What could be the issue, where do I need to look for? I don't understand, the aforementioned command is reported to work fine by others, while on my side this is not working.

• I'm not sure why it should be better to use the package options than to just use \g@addto@macro{\UrlBreaks}{\UrlOrds} as described in this post, which can be placed anywhere and doesn't need complicated package ordering. I'm not an expert, but just another user trying to figure out the most robust way of doing this. Aug 9, 2019 at 1:47
• @user21820 Good remark. Actually I have never considered that option. Good to know it could be working for this use case. Have you been able to test it successfully for this example?
– wget
Aug 10, 2019 at 13:39
• I did not test your example, but it worked for me after \usepackage{hyperref}. I have a ton of packages so I like to minimize the ordering constraints needed. I hope never to come to a day when the ordering required is not a linear order. Aug 10, 2019 at 15:51

After some time of debug, I finally found what was wrong or actually the package responsible for that malfunction. I was using BibLaTeX, and as the following minimal working examples prove it, we have to declare the line \PassOptionsToPackage{hyphens}{url} before BibLaTeX is declared.

Working example, links packages are declared before :

\documentclass[twoside]{report}
\usepackage[margin=2cm]{geometry}
\usepackage{parskip}
\PassOptionsToPackage{hyphens}{url}
\usepackage[backend=biber,sorting=none,alldates=short]{biblatex}
\usepackage{hyperref}
\begin{document}
\end{document}


Non working one, links packages are declared after :

\documentclass[twoside]{report}
\usepackage[margin=2cm]{geometry}
\usepackage{parskip}
\usepackage[backend=biber,sorting=none,alldates=short]{biblatex}
\PassOptionsToPackage{hyphens}{url}
\usepackage{hyperref}
\begin{document}
\end{document}


Also, I was using menukeys and I realized the compilation was failing on the line \PassOptionsToPackage{hyphens}{url} if menukeys was declared before hyperref. Moving menukeys after hyperref solved the issue.

Hope this could help others.

• You don't have to move hyperref before biblatex. It is enough to move the \PassOptionsToPackage{hyphens}{url}. Apr 9, 2015 at 10:10
• @UlrikeFischer Yes, you were right. On my side, I needed to put it before because I was using menukeys and the compilation fails if hyperref is declared after menukeys.
– wget
Apr 9, 2015 at 10:30
• Then it is better to move menukeys. It is always better not to move hyperref before another package if it is not really needed. Apr 9, 2015 at 10:47
• Just so future visitors reading the above know: menukeys is no longer required to be loaded after hyperref. Dec 19, 2020 at 15:29
• @wget yes (but no). It loads xparse, xstring, etoolbox, tikz, xcolor, adjustbox, relsize, kvoptions. If you need any of those packages (or their dependencies) with specific options you have to load them earlier. But else the load order shouldn't matter. Dec 20, 2020 at 16:54