我试图让 URL 链接像您使用时那样中断\url
,但我已经定义了自己的链接,因为我希望它以特定的方式加下划线,但现在它与文本宽度不匹配。
这是我的代码:
%add underline- above the hanging letters but with white buffer to break line betweeen hanging letters
\usepackage{contour}
\usepackage{ulem} %underline, can choose many types
\usepackage{xcolor} % specify colors by name (e.g. "red")
\usepackage[breaklinks=true]{hyperref} %load clickable urls
\hypersetup{
colorlinks=true,
linkcolor=black,
filecolor=black,
urlcolor=blue,
citecolor=black,
}
\renewcommand{\ULdepth}{1.8pt} %to make underline above text and have outline to make it seem like gap
\contourlength{0.8pt}
\newcommand{\myuline}[1]{%
\uline{\phantom{#1}}%
\llap{\contour{white}{#1}}%
}
% hack into hyperref- to have blue and underline
\makeatletter
\DeclareUrlCommand\ULurl@@{%
\def\Url{\myuline}}%
\def\UrlFont{\computermodern\color{blue}}%
\def\ULurl@#1{\hyper@linkurl{\ULurl@@{#1}}{#1}}
\DeclareRobustCommand*\ULurl{\hyper@normalise\ULurl@}
\makeatother