latex - 如何在 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}
解决方案
您可以使用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}
推荐阅读
- optimization - 在 Julia 中使用 Optim 进行并行计算
- python - 使用用户定义的函数修复异常值
- django - 字段级权限 django
- python - 如何将图像发送到 PUBSUB google(Opencv Python)
- vb.net - 安装在用户配置文件中的 vb.net 文件并非对所有用户都可用
- python - pydotplus.graphviz.InvocationException:未找到 GraphViz 的可执行文件
- r - 如何在 R 中为 S3 类设置默认操作?
- javascript - 如何撤消在 javascript 谷歌地图中创建的标记
- javascript - 在javascript中检查电话号码格式
- reactjs - React路由器dom将数据从父组件传递到子路由器组件不传递props.match