如何在 LaTex 参考书目中自动为特定作者姓名下划线
How to underline specific author name automatically in 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}
确定一下,您是要突出显示所有作者还是仅突出显示特定姓名?
在第一种情况下,我邀请您查看格式化参考书目的.bst 文件以找到适合您的文件,甚至自己创建一个(相当长)。
在第二种情况下,除了在您的 bib 文件中添加 \hl{Name, Surname}
之外,我没有看到任何解决方案。
您可以使用 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}
对于简历,我想在参考书目中出现的任何地方加下划线。我将 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}
确定一下,您是要突出显示所有作者还是仅突出显示特定姓名?
在第一种情况下,我邀请您查看格式化参考书目的.bst 文件以找到适合您的文件,甚至自己创建一个(相当长)。
在第二种情况下,除了在您的 bib 文件中添加 \hl{Name, Surname}
之外,我没有看到任何解决方案。
您可以使用 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}