下划线命令可防止换行

下划线命令可防止换行

基于以下代码以及来自Jinwen 这里,我制作了一个自定义下划线命令,效果很好:正如您在图片上看到的那样(这里和我编辑的 Jinwen 的帖子中),下划线永远不会与字符重叠。这是因为字母有一个轮廓在它们周围,充当一个外壳。

问题是该命令不允许换行,这是一个很大的问题。

我们知道怎样才能添加对换行符的支持吗?

\documentclass{article}
\usepackage[backend=biber]{biblatex}
\usepackage{hyperref}
\usepackage{contour}
\usepackage{fp}
\usepackage[normalem]{ulem}


\begin{filecontents}[overwrite]{\jobname.bib}
    @misc{lakoff,
        author = {Lakoff, George},
        title = {Counterparts or the Problem of Reference in Transformational Grammar},
        year = {1968},
        url = {https://georgelakoff.files.wordpress.com/2011/01/counterparts-or-the-problem-of-reference-in-transformational-grammar-lakoff-1968.pdf}
    }
\end{filecontents}


\addbibresource{\jobname.bib}


\makeatletter

\NewDocumentCommand{\clevulaux}{mmmmm}
{%
    \FPmul\cleverul@temp{\f@size}{0.#1}% This is \f@size * 0.15
    \setlength{\ULdepth}{\cleverul@temp pt}%
    \FPdiv\cleverul@temp{\f@size}{#2}% This is \f@size / 15
    \renewcommand{\ULthickness}{\cleverul@temp pt}%
    \contourlength{#3pt}%
    \uline{\phantom{#5}}%
    \llap{\contour{#4}{#5}}%
}%
\makeatother


\ExplSyntaxOn
\cs_set_eq:NN \coolclevul:nnnnn \clevulaux

\cs_generate_variant:Nn \coolclevul:nnnnn { VVVV }

\NewDocumentCommand{\coolclevul}{O{}m}{
    \group_begin:
    \keys_set:nn{coolclev}{#1}
    \coolclevul:VVVVn
    \coolclevul_space
    \coolclevul_thinness
    \coolclevul_boldness
    \coolclevul_color
    {#2}
    \group_end:
}

\keys_define:nn {coolclev}
{
    space.tl_set:N = \coolclevul_space,
    thinness.tl_set:N = \coolclevul_thinness,
    boldness.tl_set:N = \coolclevul_boldness,
    color.tl_set:N = \coolclevul_color,
    space.initial:n = 15,
    thinness.initial:n = 12,
    boldness.initial:n = 0.8,
    color.initial:n = white,
}
\ExplSyntaxOff



\urlstyle{same}

\DeclareFieldFormat{url}{\coolclevul[space=18,thinness=14]{\url{#1}}} % The command \coolclevul prevents hyphenation.


\begin{document}
    
    \nocite{*}
    
    \printbibliography
    
\end{document}

在此处输入图片描述

相关内容