0

Is there a way to underline a specific author (instead of making it bold such as in the code snippet provided here):

\newcommand*{\mkboldifhashinlist}[1]{%
  \xifinlist{\thefield{hash}}{\nhblx@boldhashes}
    {\mkbibbold{#1}}
    {#1}}
\makeatother

Inspired from the following answers:

EDIT 1

So I tried to implement the answer in my answer in my code but get an error

%https://tex.stackexchange.com/questions/73136/make-specific-author-bold-using-biblatex/416416#416416
%https://tex.stackexchange.com/questions/602723/making-specific-author-bold-using-biblatex/602735?noredirect=1#comment1511845_602735
\documentclass[british]{article}
\usepackage{babel}
\usepackage{csquotes}
\usepackage{enumitem}
\usepackage{color}
\usepackage{soul}
\usepackage{import}
\usepackage{soul}

\setlist[enumerate]{itemsep=0mm} \usepackage{geometry} \geometry{ a4paper, total={170mm,257mm}, left=20mm, right=20mm, top=20mm, }

\usepackage[backend=biber,style=authoryear,maxcitenames=2,maxbibnames=50,firstinits=true,uniquelist=false,uniquename=init,isbn=false,doi=false,useprefix=true]{biblatex}

%\usepackage{biblatex}

\usepackage{helvet} \renewcommand{\familydefault}{\sfdefault}

\makeatletter \def\nhblx@bibfile@name{\jobname -nhblx.bib} \newwrite\nhblx@bibfile \immediate\openout\nhblx@bibfile=\nhblx@bibfile@name

\immediate\write\nhblx@bibfile{% @comment{Auto-generated file}\blx@nl}

\newcounter{nhblx@name} \setcounter{nhblx@name}{0}

\newcommand*{\nhblx@writenametobib}[1]{% \stepcounter{nhblx@name}% \edef\nhblx@tmp@nocite{% \noexpand\AfterPreamble{% \noexpand\setbox0\noexpand\vbox{% \noexpand\nhblx@getmethehash{nhblx@name@\the\value{nhblx@name}}}}% }% \nhblx@tmp@nocite \immediate\write\nhblx@bibfile{% @misc{nhblx@name@\the\value{nhblx@name}, author = {\unexpanded{#1}}, % options = {dataonly=true},}% }% }

\AtEndDocument{% \closeout\nhblx@bibfile}

\addbibresource{\nhblx@bibfile@name}

\newcommand*{\nhblx@boldhashes}{} \DeclareNameFormat{nhblx@hashextract}{% \xifinlist{\thefield{hash}}{\nhblx@boldhashes} {} {\listxadd{\nhblx@boldhashes}{\thefield{hash}}}}

\DeclareCiteCommand{\nhblx@getmethehash} {} {\printnames[nhblx@hashextract][1-999]{author}} {} {}

\newcommand{\addboldnames}{\forcsvlist\nhblx@writenametobib} \newcommand{\resetboldnames}{\def\nhblx@boldhashes{}}

\newcommand*{\mkboldifhashinlist}[1]{% \xifinlist{\thefield{hash}}{\nhblx@boldhashes} %{\mkbibbold{#1}} {\ul{#1}}

{#1}}

\makeatother

\DeclareNameWrapperFormat{boldifhashinlist}{% \renewcommand*{\mkbibcompletename}{\mkboldifhashinlist}% #1}

\DeclareNameWrapperAlias{sortname}{default} \DeclareNameWrapperAlias{default}{boldifhashinlist}

% just for demonstration \ExecuteBibliographyOptions{maxnames=99,giveninits} \DeclareNameAlias{default}{family-given/given-family} \setlength\bibitemsep{1.5\itemsep}

\def\changemargin#1#2{\list{}{\rightmargin#2\leftmargin#1}\item[]} \let\endchangemargin=\endlist \newtoggle{myrefs} \newcommand{\myref}[1]{\iftoggle{myrefs}{\underline{#1}}{#1}}

\begin{filecontents}{\jobname.bib} @MISC{test1, AUTHOR = {Last1, First1 and Last2, First2 and Last3, First3}, } @MISC{test2, AUTHOR = {Last2, First2 and Last3, First3 and Last1, First1}, }

@MISC{test3, AUTHOR = {Last4, First4 and Last3, First3 and Last1, First1 and Last2, First2}, } \end{filecontents} \addbibresource{\jobname.bib}

\DeclareLabeldate[online]{% \field{date} \field{year} \field{eventdate} \field{origdate} \field{urldate} } \usepackage[dvipsnames]{xcolor} \definecolor{myblue}{RGB}{0, 32, 255} \usepackage[colorlinks]{hyperref} \hypersetup{ colorlinks, filecolor=magenta, linkcolor=blue, urlcolor=myblue, final } \usepackage{titlesec}

\titleformat{\section} {\normalfont\large\bfseries}{\thesection}{0.8em}{}[{\titlerule[0.8pt]}] \titleformat{\subsection} {\normalfont\normalsize\bfseries}{\thesubsection}{0.8em}{} \titleformat{\subsubsection} {\normalfont\normalsize\bfseries}{\thesubsubsection}{0.8em}{} \begin{document}

\title{ \vspace{-2.5cm} \textbf{Publications - Eric Buffle, MD-PhD}\vspace{-0.6cm}} %\date{\today} \date{\vspace{-5ex}} \maketitle \nocite{*}

\addboldnames{{Last2, First2}}

\begin{enumerate} \item \fullcite{test1} \item \fullcite{test2} \item \fullcite{test3} \end{enumerate}

\end{document}

and I get the following error

LaTeX Warning: No \author given.

! Argument of \etb@ifdefmacro has an extra }. <inserted text> \par l.149 \item \fullcite{test1}

?

ecjb
  • 883

1 Answers1

1

The bit in the quoted code that makes the name bold is the \mkbibbold{#1}, you can replace that with code that underlines #1.

Note that most TeX implementations of underlining have issues with complex arguments and usually do not allow for line breaks with complex arguments (if they work at all). You could try to use standard \underline{#1}, soul's \ul{#1}, ulem's \uline{#1} (load ulem with the normalem option to avoid \emph-italics turning into underlines) if you can get them to work and don't mind that the underlined names do not line break.

The only "safe" implementation of underline that allows for line breaking and usually accepts all kinds of inputs that I'm aware of is lua-ul's \underLine{#1}. That needs LuaLaTeX, however.

moewe
  • 175,683
  • Many thanks for your comment @moewe. I tried to implement your answer in my code (which is I admit more complicated than the snippet I providedO but get an error. Do you have an idea how to solve the problem? – ecjb Sep 21 '23 at 18:14
  • @ecjb Seems that the argument is too complex for soul's \ul. Sorry. As I said the only safe implementation that allows line breaks that I know of is lua-ul's \underLine , which works here. (You could also use the standard \underline if you don't mind not having line breaks.) – moewe Sep 21 '23 at 18:35