我正在写论文,我想使用在出版物中突出显示我的名字,同时\fullcite{}
保持主要参考书目不变(如果不可能,也可以在那里突出显示名字)。我尝试了以下方法:
但我无法让它工作。因此我定义了一个命令:
% Show me as author
%\newcommand*{\showme}[1]{\textbf{#1}}
\newcommand*{\showme}[1]{\mkbibbold{#1}}
在我的 biblio.bib 中使用。它似乎有效。但我注意到条目没有格式化为其他作者的名字。这很容易看出来,因为我使用的是ieee
样式。
@incollection{Silva:2014a,
title={Radio Resource Management for Device-to-Device Communications in Long Term Evolution Networks},
author={\showme{Carlos F. M. Silva} and Jos\'{e} Mairton B. Silva Jr. and Tarcisio F. Maciel},
booktitle={Resource Allocation and {MIMO} for {4G} and Beyond},
publisher={Springer Science+Business Media},
year=2014,
address={New York, USA},
editor={Francisco Rodrigo Porto Cavalcanti},
pages={105-156},
doi={10.1007/978-1-4614-8057-0_3},
isbn={978-1-4614-8056-3},
}
这使:
卡洛斯·席尔瓦、JMBS Jr. 和 TF Maciel,“长期演进网络中设备到设备通信的无线电资源管理”,载于《4G 及以后的资源分配和 MIMO》,FRP Cavalcanti 编辑,美国纽约:Springer Science+Business Media,2014 年,第 105-156 页,isbn:978-1-4614-8056-3。doi:10.1007/978-1-4614-8057-0_3
从中可以看出,我的名字完整显示,而正确的输入应该是CFM席尔瓦。我知道发生这种情况是因为里面的任何内容{}
都不是按照书目样式格式化的。
所以我的问题是:我如何定义这样的命令,让书目样式格式化我的名字,并在标记打开时将其加粗,即\ifshowme=1
。MWE 如下。
\documentclass{article}
\usepackage[backend=biber,style=ieee]{biblatex}
% Show me as author
%\newcommand*{\showme}[1]{\textbf{#1}}
\newcommand*{\showme}[1]{\mkbibbold{#1}}
\usepackage{filecontents}
\begin{filecontents}{biblio.bib}
@incollection{Silva:2014a,
title={Radio Resource Management for Device-to-Device Communications in Long Term Evolution Networks},
author={\showme{Carlos F. M. Silva} and Jos\'{e} Mairton B. Silva Jr. and Tarcisio F. Maciel},
booktitle={Resource Allocation and {MIMO} for {4G} and Beyond},
publisher={Springer Science+Business Media},
year=2014,
address={New York, USA},
editor={Francisco Rodrigo Porto Cavalcanti},
pages={105-156},
doi={10.1007/978-1-4614-8057-0_3},
isbn={978-1-4614-8056-3},
}
\end{filecontents}
\addbibresource{biblio.bib}
\begin{document}
\fullcite{Silva:2014a}
\printbibliography
\end{document}
答案1
编辑此方法的持续更新发布到https://tex.stackexchange.com/a/416416/35864。
以下解决方案会自动提取给定名称的哈希值。其他所有内容均基于以下答案。
警告!代码将写入一个.bib
名为 的文件<your TeX file/\jobname>-boldnames.bib
,如果该文件存在,则会被覆盖。您可以通过调整 的值来更改该文件的名称\hlblx@bibfile@name
。
\documentclass{article}
\usepackage[backend=biber,style=numeric]{biblatex}
\makeatletter
\def\hlblx@bibfile@name{\jobname -boldnames.bib}
\newwrite\hlblx@bibfile
\immediate\openout\hlblx@bibfile=\hlblx@bibfile@name
\newcounter{hlblx@name}
\setcounter{hlblx@name}{0}
\newcommand*{\hlblx@writenametobib}[1]{%
\stepcounter{hlblx@name}%
\edef\hlblx@tmp@nocite{%
\noexpand\AfterPreamble{%
\noexpand\setbox0\noexpand\vbox{%
\noexpand\hlblx@getmethehash{hlblx@name@\the\value{hlblx@name}}}}%
}%
\hlblx@tmp@nocite
\immediate\write\hlblx@bibfile{%
@misc{hlblx@name@\the\value{hlblx@name}, author = {\unexpanded{#1}}, %
options = {dataonly=true},}%
}%
}
\AtEndDocument{%
\closeout\hlblx@bibfile}
\addbibresource{\hlblx@bibfile@name}
\newcommand*{\hlbxl@boldhashes}{}
\DeclareNameFormat{hlblx@hashextract}{%
\xifinlist{\thefield{hash}}{\hlbxl@boldhashes}
{}
{\listxadd{\hlbxl@boldhashes}{\thefield{fullhash}}}}
\DeclareCiteCommand{\hlblx@getmethehash}
{}
{\printnames[hlblx@hashextract][1-999]{author}}
{}
{}
\newcommand*{\addboldname}{\forcsvlist\hlblx@writenametobib}
\newcommand*{\resetboldnames}{\def\hlbxl@boldhashes{}}
\newcommand*{\mkboldifhashinlist}[1]{%
\xifinlist{\thefield{hash}}{\hlbxl@boldhashes}
{\mkbibbold{#1}}
{#1}}
\makeatother
\DeclareNameWrapperFormat{boldifhashinlist}{%
\renewcommand*{\mkbibcompletename}{\mkboldifhashinlist}%
#1}
\DeclareNameWrapperAlias{sortname}{default}
\DeclareNameWrapperAlias{default}{boldifhashinlist}
\addboldname{{Silva, Carlos F. M.}}
\begin{filecontents}{\jobname.bib}
@incollection{Silva:2014a,
title = {Radio Resource Management for Device-to-Device
Communications in Long Term Evolution Networks},
author = {Carlos F. M. Silva and Silva, Jr., Jos\'{e} Mairton B.
and Tarcisio F. Maciel},
booktitle = {Resource Allocation and {MIMO} for {4G} and Beyond},
publisher = {Springer Science+Business Media},
year = 2014,
address = {New York, USA},
editor = {Francisco Rodrigo Porto Cavalcanti},
pages = {105-156},
doi = {10.1007/978-1-4614-8057-0_3},
isbn = {978-1-4614-8056-3},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\fullcite{Silva:2014a}
\resetboldnames\addboldname{{Silva, Jr., Jos\'{e} Mairton B.}}\printbibliography
\end{document}
我们可以用奥黛丽的方法使用 biblatex 将特定作者设为粗体,但我们不使用字符串比较,而是使用 Biber 生成的名称哈希。
\newcommand*{\boldnames}{}
\newcommand*{\mkboldifhashinlist}[1]{%
\xifinlist{\thefield{hash}}{\boldnames}
{\mkbibbold{#1}}
{#1}}
\DeclareNameWrapperFormat{boldifhashinlist}{%
\renewcommand*{\mkbibcompletename}{\mkboldifhashinlist}%
#1}
\DeclareNameWrapperAlias{sortname}{default}
\DeclareNameWrapperAlias{default}{boldifhashinlist}
您可以通过查看 Biber 生成的文件来找到hash
您的名称(及其版本)的值.bbl
,它将包含类似这样的引用条目的信息
\entry{Silva:2014a}{incollection}{}
\name{author}{3}{}{%
{{hash=894de27062ab25d43f1d7b50fd923256}{%
family={Silva},
familyi={S\bibinitperiod},
given={Carlos\bibnamedelimb F.\bibnamedelimi M.},
giveni={C\bibinitperiod\bibinitdelim F\bibinitperiod\bibinitdelim M\bibinitperiod}}}%
{{hash=cc273ec4593222cb35c353d3f073214e}{%
family={Silva},
familyi={S\bibinitperiod},
given={José\bibnamedelimb Mairton\bibnamedelima B.},
giveni={J\bibinitperiod\bibinitdelim M\bibinitperiod\bibinitdelim B\bibinitperiod},
suffix={Jr.},
suffixi={J\bibinitperiod}}}%
{{hash=1f31fc59b1a438cdb6e7efa3f16611fe}{%
family={Maciel},
familyi={M\bibinitperiod},
given={Tarcisio\bibnamedelima F.},
giveni={T\bibinitperiod\bibinitdelim F\bibinitperiod}}}%
}
\name{editor}{1}{}{%
{{hash=3ac5e392f4edfbddb80549d1ccca0d11}{%
family={Cavalcanti},
familyi={C\bibinitperiod},
given={Francisco\bibnamedelimb Rodrigo\bibnamedelima Porto},
giveni={F\bibinitperiod\bibinitdelim R\bibinitperiod\bibinitdelim P\bibinitperiod}}}%
}
\list{location}{1}{%
{New York, USA}%
}
\list{publisher}{1}{%
{Springer Science+Business Media}%
}
\strng{namehash}{b4c654eecf5e554d731ed21594f20b31}
\strng{fullhash}{b4c654eecf5e554d731ed21594f20b31}
\strng{bibnamehash}{b4c654eecf5e554d731ed21594f20b31}
\strng{authorbibnamehash}{b4c654eecf5e554d731ed21594f20b31}
\strng{authornamehash}{b4c654eecf5e554d731ed21594f20b31}
\strng{authorfullhash}{b4c654eecf5e554d731ed21594f20b31}
\strng{editorbibnamehash}{3ac5e392f4edfbddb80549d1ccca0d11}
\strng{editornamehash}{3ac5e392f4edfbddb80549d1ccca0d11}
\strng{editorfullhash}{3ac5e392f4edfbddb80549d1ccca0d11}
\field{sortinit}{S}
\field{sortinithash}{c319cff79d99c853d775f88277d4e45f}
\field{labelnamesource}{author}
\field{labeltitlesource}{title}
\field{booktitle}{Resource Allocation and {MIMO} for {4G} and Beyond}
\field{isbn}{978-1-4614-8056-3}
\field{title}{Radio Resource Management for Device-to-Device Communications in Long Term Evolution Networks}
\field{year}{2014}
\field{pages}{105\bibrangedash 156}
\range{pages}{52}
\verb{doi}
\verb 10.1007/978-1-4614-8057-0_3
\endverb
\endentry
相关名称的哈希值显示在名称前面,对于 CFM Silva 为894de27062ab25d43f1d7b50fd923256
,对于 JM B Silva Jr. 为cc273ec4593222cb35c353d3f073214e
。(请注意,此哈希值的值可能会在 Biber 版本之间发生变化:检查更新后名称是否正确突出显示。)
由于hash
不同名称输入的 不同(hash
“Donald E. Knuth” 的 不会等于“DE Knuth”或“Donald Knuth”的 ),您必须为您使用的所有名称变体找到正确的哈希值。
在...的帮助下
\newcommand*{\detokenizelistadd}[2]{%
\listeadd#1{\detokenize{#2}}}
然后你可以将哈希列表添加到\boldnames
宏中
\forcsvlist{\detokenizelistadd\boldnames}
{{894de27062ab25d43f1d7b50fd923256}}
平均能量损失
\documentclass{article}
\usepackage[backend=biber,style=numeric]{biblatex}
\newcommand*{\boldnames}{}
\newcommand*{\mkboldifhashinlist}[1]{%
\xifinlist{\thefield{hash}}{\boldnames}
{\mkbibbold{#1}}
{#1}}
\DeclareNameWrapperFormat{boldifhashinlist}{%
\renewcommand*{\mkbibcompletename}{\mkboldifhashinlist}%
#1}
\DeclareNameWrapperAlias{sortname}{default}
\DeclareNameWrapperAlias{default}{boldifhashinlist}
\newcommand*{\detokenizelistadd}[2]{%
\listeadd#1{\detokenize{#2}}}
\renewcommand*{\boldnames}{}
\forcsvlist{\detokenizelistadd\boldnames}
{{894de27062ab25d43f1d7b50fd923256}}
\begin{filecontents}{\jobname.bib}
@incollection{Silva:2014a,
title = {Radio Resource Management for Device-to-Device
Communications in Long Term Evolution Networks},
author = {Carlos F. M. Silva and Silva, Jr., Jos\'{e} Mairton B.
and Tarcisio F. Maciel},
booktitle = {Resource Allocation and {MIMO} for {4G} and Beyond},
publisher = {Springer Science+Business Media},
year = 2014,
address = {New York, USA},
editor = {Francisco Rodrigo Porto Cavalcanti},
pages = {105-156},
doi = {10.1007/978-1-4614-8057-0_3},
isbn = {978-1-4614-8056-3},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\fullcite{Silva:2014a}
\printbibliography
\end{document}
答案已更新,以反映biblatex
> = 3.3所需的更改(请参阅biblatex
3.3 名称格式)。last
名称宏中所有提及的现在都是 ,family
并first
变为given
。请参阅 3.3 之前代码的编辑历史。
編輯使用更优雅的版本来格式化完整名称。\DeclareNameWrapperFormat
和\mkbibcompletename
仅分别在 v3.12 (2018-10-30) 和 v3.13 (2019-08-17) 中可用biblatex
。如果您使用的是旧版本的,请参阅编辑历史biblatex
。