我正在编写一份晋升和终身职位简历的出版部分。我希望有以下功能:
- 让某些作者变得大胆(我自己)
- Dagger(\dag)某些作者(学生)
- 双重匕首某些作者(博士后)
我能够通过以下方式使第一个工作:
\usepackage[backend=biber,style=numeric,defernumbers=true,sorting=ydnt,maxbibnames=99]{biblatex}
\addbibresource{references.bib}
\newcommand{\makeauthorbold}[1]{%
\DeclareNameFormat{author}{%
\ifthenelse{\value{listcount}=1}
{%
{\expandafter\ifstrequal\expandafter{\namepartfamily}{#1}{\mkbibbold{\namepartfamily\addcomma\addspace \namepartgiveni}}{\namepartfamily\addcomma\addspace \namepartgiveni}}
%
}{\ifnumless{\value{listcount}}{\value{liststop}}
{\expandafter\ifstrequal\expandafter{\namepartfamily}{#1}{\mkbibbold{\addcomma\addspace \namepartfamily\addcomma\addspace \namepartgiveni}}{\addcomma\addspace \namepartfamily\addcomma\addspace \namepartgiveni}}
{\expandafter\ifstrequal\expandafter{\namepartfamily}{#1}{\mkbibbold{\addcomma\addspace \namepartfamily\addcomma\addspace \namepartgiveni\addcomma\isdot}}{\addcomma\addspace \namepartfamily\addcomma\addspace \namepartgiveni\addcomma\isdot}}%
}
\ifthenelse{\value{listcount}<\value{liststop}}
{\addcomma\space}
}
}
\makeauthorbold{MyLastName}
我原本希望对第二点和第三点重复类似的过程,并创建一个\makeauthordag
和\makeauthorddag
命令,但只有最后一个会起作用(似乎是覆盖了以前的命令操作)。
答案1
我将在这里使用名称哈希而不是字符串比较。
我们可以参数化推荐的方法我的答案到使用 biblatex 将特定作者设为粗体允许几个独立的哈希列表。
我们\markname{<marker>}{<list of names>}
可以定义将被标记为 的名称<marker>
。然后我们可以使用 来测试此标记\ifnamemarked{<marker>}{<true>}{<false>}
。
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[backend=biber,style=numeric]{biblatex}
\addbibresource{biblatex-examples.bib}
\makeatletter
\def\nhblx@bibfile@name{\jobname -nhblx.bib}
\newwrite\nhblx@bibfile
\immediate\openout\nhblx@bibfile=\nhblx@bibfile@name
\immediate\write\nhblx@bibfile{%
@comment{Auto-generated file}\blx@nl}
\newcounter{nhblx@name}
\setcounter{nhblx@name}{0}
\newcommand*{\nhblx@writenametobib}[2]{%
\ifcsundef{nhblx@#1list}
{\csdef{nhblx@#1list}{}}
{}%
\stepcounter{nhblx@name}%
\edef\nhblx@tmp@nocite{%
\noexpand\AfterPreamble{%
\noexpand\setbox0\noexpand\vbox{%
\noexpand\def\noexpand\nhblx@listname{nhblx@#1list}%
\noexpand\nhblx@getmethehash{nhblx@name@\the\value{nhblx@name}}}}%
}%
\nhblx@tmp@nocite
\immediate\write\nhblx@bibfile{%
@misc{nhblx@name@\the\value{nhblx@name}, author = {\unexpanded{#2}}, %
options = {dataonly=true},}%
}%
}
\AtEndDocument{%
\closeout\nhblx@bibfile}
\addbibresource{\nhblx@bibfile@name}
\DeclareNameFormat{nhblx@hashextract}{%
\xifinlistcs{\thefield{hash}}{\nhblx@listname}
{}
{\listcsxadd{\nhblx@listname}{\thefield{hash}}}}
\DeclareCiteCommand{\nhblx@getmethehash}
{}
{\typeout{\nhblx@listname}\printnames[nhblx@hashextract][1-999]{author}}
{}
{}
\newcommand*{\markname}[1]{\forcsvlist{\nhblx@writenametobib{#1}}}
\newcommand*{\resetmark}[1]{\csdef{nhblx@#1list}{}}
\newcommand*{\ifnamemarked}[1]{%
\xifinlistcs{\thefield{hash}}{nhblx@#1list}}
\makeatother
\newcommand*{\studentorpostdoc}[1]{%
\ifnamemarked{student}{\dag}{}%
\ifnamemarked{postdoc}{\ddag}{}%
#1}
\newcommand*{\nameformatter}[1]{%
\ifnamemarked{me}
{\mkbibbold{#1}}
{\studentorpostdoc{#1}}}
\DeclareNameWrapperFormat{nameformatter}{%
\renewcommand*{\mkbibcompletename}{\nameformatter}%
#1}
\DeclareNameWrapperAlias{sortname}{default}
\DeclareNameWrapperAlias{default}{nameformatter}
\markname{me}{{Sigfridsson, Emma}}
\markname{student}{Philipp Jaff{\'e}}
\markname{postdoc}{Ulf Ryde}
\begin{document}
\nocite{sigfridsson,jaffe}
\printbibliography
\end{document}