为长 URL 加下划线并换行

为长 URL 加下划线并换行

我有一个很长的 URL,我想让它显示为蓝色并带有下划线。此外,如果 URL 太长而无法写成一行,则必须换行。

\documentclass[a4paper,10pt]{article}
\usepackage[colorlinks,urlcolor=blue,breaklinks=true]{hyperref}
\usepackage[hyphenbreaks]{breakurl}
\begin{document}
\underline{\href{http://www.atmel.com/Images/Atmel-11121-32-bit-Cortex-A5-Microcontroller\_SAMA5D3\_Datasheet.pdf}{http://www.atmel.com/Images/Atmel-11121-32-bit-Cortex-A5-Microcontroller\_SAMA5D3\_Datasheet.pdf}}
\end{document}}

换行很容易。问题是当您想要换行和下划线时。我尝试了这里描述的内容:是否可以使用 \underline{text} 命令来显示斜体、粗体文本以及换行符?。soul 包也能用,但效果并不好,这意味着有时 url 的一小部分下划线会消失,并且 url 末尾通常会出现一个额外的空格。

答案1

据我所知,最接近你想要的是:

\documentclass[a4paper,10pt]{article}
\usepackage{hyperref}
\hypersetup{colorlinks=false,pdfborderstyle={/S/U/W 1},pdfborder=0 0 1}
\begin{document}

\url{http://www.atmel.com/Images/Atmel-11121-32-bit-Cortex-A5-Microcontroller\_SAMA5D3\_Datasheet.pdf}

text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text 

\end{document}

但是,下划线和线宽显然有问题。通过多个“文本”可以看到,下划线停在行尾,而不是跟随 url 大小。我建议你不要使用下划线。尝试使用彩色链接。

相关内容