# URL with dotted/customized underline AND line breaking

How can I get a dotted URL underline with line breaking?

I found this solution: Having all links underlined with dotted line but this TIKZ one does not work with line breaking.

I also tried a simpler solution. This results in a dotted line, but also no line breaking.

\documentclass{article}
\usepackage{ulem}
\makeatother
\AtBeginDocument{
\let\oldurl=\url
\renewcommand\url[1]{\dotuline{\oldurl{#1}}}
}
\begin{document}
Desired dotted line, but no linebreaking:\\
\par Line breaking but no dotted line\\
\end{document}


This outputs this:

How to get linebreaking working in combination with dotted (or more in general: customized) underline?

• You can use Martin's code here tex.stackexchange.com/a/24279/2388 and then \tikzul[dashed]{\url{http://www.very.very.very,very.very.very.very.very.very.very.long.url.com/a/b/c/d/e/df/sadasd/asdasda}}. (If your url contains special chars, you will have to store the url first with \urldef). You must compile twice. – Ulrike Fischer May 13 '15 at 15:40
• This solution of Ulrike does not work: this: "\tikzul[dashed]{\url{A}}" results in "! Undefined control sequence. l.135 \tikzul[dashed]{\url" however without URL it is working (so "\tikzul[dashed]{A}" does work but off course no URL). – robert May 14 '15 at 11:52
• Well you naturally should load the url or hyperref package if you want to use the command \url. – Ulrike Fischer May 14 '15 at 12:00
• Thanks Ulrike that did the trick. Is this TIKZUL already packaged up? – robert May 14 '15 at 12:32
• Repeated question: tex.stackexchange.com/questions/236337/… – Carlos Viegas May 14 '15 at 13:43

With the commands \href and \allowbreak I was able to get the desired output. Dotted line and line break. Unfortunately I have no idea how it would be possible to add the \allowbreaks automatically after every /.

\documentclass{article}
\usepackage{ulem}
\makeatother
\AtBeginDocument{
\let\oldurl=\url
\renewcommand\url[1]{\dotuline{\oldurl{#1}}}
}
\begin{document}
Desired dotted line, but no linebreaking:\\