How to underline specific author name automatically in LaTex bibiolgraphy

3.4k views Asked by At

For a CV, I want to underline my name wherever it appears in a bibliography. I am using LaTex with biblatex. Is there an easy way to automatically underline a certain name? Thanks!

For example, I want "Name Surname" to be underlined automatically in all the entries in the bibliography.

\documentclass[12pt]{article}
\usepackage[maxbibnames=99, sorting=ydnt]{biblatex}
\addbibresource{test.bib}

\begin{filecontents}{test.bib}
@article{paper1,
author   = {Surname, Name and Another, Name and Thethird, Name and Andthe, Last},
journal  = {JUR},
month    = {5},
title    = {{Title very good}},
year     = {2015}
}
@article{paper2,
author   = {Guy, Some and Surname, Name and Dude, The},
journal  = {JUR},
month    = {5},
title    = {{Another brilliant title}},
year     = {2016},
}
\end{filecontents}

\begin{document}

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

There are 2 answers

2
samcarter_is_at_topanswers.xyz On BEST ANSWER

You can use the trick from https://tex.stackexchange.com/a/355317/36296

\documentclass[12pt]{article}
\usepackage[maxbibnames=99, sorting=ydnt]{biblatex}


\begin{filecontents*}[overwrite]{\jobname.bib}
@article{paper1,
author   = {Surname, Name and Another, Name and Thethird, Name and Andthe, Last},
journal  = {JUR},
month    = {5},
title    = {{Title very good}},
year     = {2015}
}
@article{paper2,
author   = {Guy, Some and Surname, Name and Dude, The},
journal  = {JUR},
month    = {5},
title    = {{Another brilliant title}},
year     = {2016},
}
\end{filecontents*}

\addbibresource{\jobname.bib}

\usepackage{xstring}
\usepackage{etoolbox}
\newboolean{bold}
\newcommand{\makeauthorsbold}[1]{%
  \DeclareNameFormat{author}{%
  \setboolean{bold}{false}%
    \renewcommand{\do}[1]{\expandafter\ifstrequal\expandafter{\namepartfamily}{####1}{\setboolean{bold}{true}}{}}%
    \docsvlist{#1}%
    \ifthenelse{\value{listcount}=1}
    {%
      {\expandafter\ifthenelse{\boolean{bold}}{\mkbibbold{\namepartfamily\addcomma\addspace \namepartgiveni}}{\namepartfamily\addcomma\addspace \namepartgiveni}}%
    }{\ifnumless{\value{listcount}}{\value{liststop}}
      {\expandafter\ifthenelse{\boolean{bold}}{\mkbibbold{\addcomma\addspace \namepartfamily\addcomma\addspace \namepartgiveni}}{\addcomma\addspace \namepartfamily\addcomma\addspace \namepartgiveni}}%
      {\expandafter\ifthenelse{\boolean{bold}}{\mkbibbold{\addcomma\addspace \namepartfamily\addcomma\addspace \namepartgiveni\addcomma\isdot}}{\addcomma\addspace \namepartfamily\addcomma\addspace \namepartgiveni\addcomma\isdot}}%
      }
    \ifthenelse{\value{listcount}<\value{liststop}}
    {\addcomma\space}{}
  }
}

\makeauthorsbold{Surname, Name}



\begin{document}

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

enter image description here

2
Maxime EtiƩvant On

Just to be sure, do you want to highlight all the authors or just a particular name?

In the first case, I invite you to look at the .bst files that format the bibliography to find the one that suits you or even create one yourself (which is quite long).

In the second case, I don't see any solution except to add \hl{Name, Surname} inside your bib file.