Alex
Alex

Reputation: 437

How to underline specific author name automatically in LaTex bibiolgraphy

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}

Upvotes: 2

Views: 4194

Answers (2)

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

Upvotes: 3

Maxime Eti&#233;vant
Maxime Eti&#233;vant

Reputation: 71

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.

Upvotes: -1

Related Questions