首页 > 解决方案 > 如何在 LaTex bibiolgraphy 中自动为特定作者姓名添加下划线

问题描述

对于简历,我想在我的名字出现在参考书目中的任何地方加上下划线。我正在将 LaTex 与 biblatex 一起使用。有没有一种简单的方法可以自动为某个名称添加下划线?谢谢!

例如,我希望在参考书目的所有条目中自动为“姓氏”添加下划线。

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

标签: latexbiblatex

解决方案


您可以使用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}

在此处输入图像描述


推荐阅读