带点下划线/自定义下划线和换行的 URL

带点下划线/自定义下划线和换行的 URL

我如何获得点状 URL 下划线换行

我找到了这个解决方案:所有链接均用虚线加下划线但这个 TIKZ 确实如此不支持换行

我也尝试了一个更简单的解决方案。这会产生虚线,但没有换行。

\documentclass{article} 
\usepackage[hidelinks]{hyperref}  
\usepackage{ulem}
\makeatother
\AtBeginDocument{
   \let\oldurl=\url
   \renewcommand\url[1]{\dotuline{\oldurl{#1}}}
}
\begin{document}
Desired dotted line, but no linebreaking:\\
\url{http://www.very.very.very,very.very.very.very.very.very.very.long.url.com/a/b/c/d/e/df/sadasd/asdasda}
\par Line breaking but no dotted line\\
\oldurl{http://www.very.very.very,very.very.very.very.very.very.very.long.url.com/a/b/c/d/e/df/sadasd/asdasda}
\end{document}

输出如下内容:

在此处输入图片描述

如何使换行与虚线(或一般来说:自定义)下划线结合使用?

答案1

使用命令\href和,\allowbreak我能够获得所需的输出。虚线和换行符。不幸的是,我不知道如何\allowbreak在每个 / 后自动添加 s。

\documentclass{article} 
\usepackage[hidelinks]{hyperref} 
\usepackage{ulem}
\makeatother
\AtBeginDocument{
   \let\oldurl=\url
   \renewcommand\url[1]{\dotuline{\oldurl{#1}}}
}
\begin{document}
Desired dotted line, but no linebreaking:\\
\url{http://www.very.very.very,very.very.very.very.very.very.very.long.url.com/a/b/c/d/e/df/sadasd/asdasda}
\par Line breaking but no dotted line\\
\oldurl{http://www.very.very.very,very.very.very.very.very.very.very.long.url.com/a/b/c/d/e/df/sadasd/asdasda}\\
\href{http://www.very.very.very,very.very.very.very.very.very.very.long.url.com/a/b/c/d/e/df/sadasd/asdasda}{\dotuline{http://www.very.very.very,very.very.very.very.very.very.very.long.url.com/\allowbreak{}a/\allowbreak{}b/\allowbreak{}c/\allowbreak{}d/\allowbreak{}e/\allowbreak{}df/\allowbreak{}sadasd/\allowbreak{}asdasda}}
\end{document}

输出: 在此处输入图片描述

相关内容