2

Based on a code by Alex Chan and help from Jinwen here, I made a custom underlining command with nice results: as you can see on the pictures (here and in Jinwen's post edited by me), the underline never overlaps the characters. This is because the letters have a contour around them, acting as a shell.

The problem is that the command just disallows line breaks, which is quite an issue.

Any idea how we could add support for line breaks?

\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}

enter image description here

6
  • 1
    Just out of idle curiosity: What purpose is served by underlining a URL string?
    – Mico
    Commented Apr 25, 2023 at 22:00
  • It's a convention like another one, I'd say. One day someone must have asked: "What purpose is served by italicizing work titles?" and now everyone is doing it. The fact is, URL is something relatively new, and underlining isn't officially reserved for anything. So I can reverse the question: why wouldn't you want to underline a URL? Maybe it looks better that way? naked URLs are as ugly as a string can be. Commented Apr 25, 2023 at 22:14
  • 1
    URLs are an example, but the problem is that the command disallows line breaks. Which is sad, considering it's aesthetically very satisfying. Commented Apr 25, 2023 at 22:26
  • 4
    url's are no longer new. And they are certainly not so important that you should emphasize them in the bibliography. I would simply write them in a normal font. Commented Apr 25, 2023 at 22:27
  • 4
    if you want underlining with good line breaks, use lualatex and the lua-ul package. Commented Apr 25, 2023 at 22:27

0

You must log in to answer this question.

Browse other questions tagged .