我使用这个代码使用 biblatex 将特定作者设为粗体用以下方式突出显示具有“名字”和“姓氏”的作者:
\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}[1]{%
\stepcounter{nhblx@name}%
\edef\nhblx@tmp@nocite{%
\noexpand\AfterPreamble{%
\noexpand\setbox0\noexpand\vbox{%
\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{#1}}, %
options = {dataonly=true},}%
}%
}
\AtEndDocument{%
\closeout\nhblx@bibfile}
\addbibresource{\nhblx@bibfile@name}
\newcommand*{\nhblx@boldhashes}{}
\DeclareNameFormat{nhblx@hashextract}{%
\xifinlist{\thefield{hash}}{\nhblx@boldhashes}
{}
{\listxadd{\nhblx@boldhashes}{\thefield{hash}}}}
\DeclareCiteCommand{\nhblx@getmethehash}
{}
{\printnames[nhblx@hashextract][1-999]{author}}
{}
{}
\newcommand*{\addboldnames}{\forcsvlist\nhblx@writenametobib}
\newcommand*{\resetboldnames}{\def\nhblx@boldhashes{}}
\newcommand*{\mkboldifhashinlist}[1]{%
\xifinlist{\thefield{hash}}{\nhblx@boldhashes}
{\mkbibbold{#1}}
{#1}}
\makeatother
\DeclareNameWrapperFormat{boldifhashinlist}{%
\renewcommand*{\mkbibcompletename}{\mkboldifhashinlist}%
#1}
\DeclareNameWrapperAlias{sortname}{default}
\DeclareNameWrapperAlias{default}{boldifhashinlist}
\resetboldnames\addboldnames{{Pedro Filipe Oliveira}, {Pedro Oliveira}}
\bibliography{info_extra_files/PFO_Publications}
突出显示是正确的,但在参考文献中,打印的前两个出版物是之前定义的粗体名称,就像您在附图中看到的那样。
完整代码为:main.tex
\documentclass[portuguese,a4paper,nologo]{europasscv}
\usepackage[utf8]{inputenc}
\usepackage[backend=bibtex,autolang=hyphen,sorting=none,style=numeric,maxbibnames=99,doi=true,isbn=false,maxcitenames=2]{biblatex}
\usepackage{csquotes}
\usepackage{europasscv-bibliography}
\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}[1]{%
\stepcounter{nhblx@name}%
\edef\nhblx@tmp@nocite{%
\noexpand\AfterPreamble{%
\noexpand\setbox0\noexpand\vbox{%
\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{#1}}, %
options = {dataonly=true},}%
}%
}
\AtEndDocument{%
\closeout\nhblx@bibfile}
\addbibresource{\nhblx@bibfile@name}
\newcommand*{\nhblx@boldhashes}{}
\DeclareNameFormat{nhblx@hashextract}{%
\xifinlist{\thefield{hash}}{\nhblx@boldhashes}
{}
{\listxadd{\nhblx@boldhashes}{\thefield{hash}}}}
\DeclareCiteCommand{\nhblx@getmethehash}
{}
{\printnames[nhblx@hashextract][1-999]{author}}
{}
{}
\newcommand*{\addboldnames}{\forcsvlist\nhblx@writenametobib}
\newcommand*{\resetboldnames}{\def\nhblx@boldhashes{}}
\newcommand*{\mkboldifhashinlist}[1]{%
\xifinlist{\thefield{hash}}{\nhblx@boldhashes}
{\mkbibbold{#1}}
{#1}}
\makeatother
\DeclareNameWrapperFormat{boldifhashinlist}{%
\renewcommand*{\mkbibcompletename}{\mkboldifhashinlist}%
#1}
\DeclareNameWrapperAlias{sortname}{default}
\DeclareNameWrapperAlias{default}{boldifhashinlist}
\resetboldnames\addboldnames{{Pedro Filipe Oliveira}, {Pedro Oliveira}}
\bibliography{PFO_Publications}
\begin{document}
\begin{europasscv}
\section{Introduction}
\nocite{*}
\renewcommand{\section}[2]{\ecvsection{#2}}
\printbibtabular[title=Publicações]
\end{europasscv}
\end{document}
PFO_出版物.bib
@article{oliveira2016blegen,
title={BLEGen—a code generator for bluetooth low energy services},
author={Oliveira, Pedro Filipe and Matos, Paulo},
journal={Lecture Notes on Software Engineering},
volume={4},
number={1},
pages={7--11},
year={2016},
publisher={Lecture Notes on Software Engineering}
}
@inproceedings{oliveira2016behaviour,
title={Behaviour analysis in smart spaces},
author={Oliveira, Pedro and Matos, Paulo and Novais, Paulo},
booktitle={2016 Intl IEEE Conferences on Ubiquitous Intelligence \& Computing, Advanced and Trusted Computing, Scalable Computing and Communications, Cloud and Big Data Computing, Internet of People, and Smart World Congress (UIC/ATC/ScalCom/CBDCom/IoP/SmartWorld)},
pages={880--887},
year={2016},
organization={IEEE}
}
@inproceedings{oliveira2017challenges,
title={Challenges in smart spaces: aware of users, preferences, behaviours and habits},
author={Oliveira, Pedro and Novais, Paulo and Matos, Paulo},
booktitle={International Conference on Practical Applications of Agents and Multi-Agent Systems},
pages={268--271},
year={2017},
organization={Springer, Cham}
}
答案1
您使用的代码假定您运行 Biber 作为后端( ),但您正在运行不支持所有功能的backen=bibtex,
传统 BibTeX 后端( ) 。backend=bibtex,
biblatex
最重要的是,BibTeX 实际上并不像 Biber 那样计算名称哈希值,因此我不确定是否能保证在任何情况下都能正确检测名称。
如果可能的话,您应该考虑切换到 Biber,在文档中改用并运行 Biber 而不是 BibTeX backend=bibtex,
(backend=biber,
Biblatex 与 Biber:配置我的编辑器以避免未定义的引用将帮助您进行编辑器配置)。
如果您必须坚持使用 BibTeX,则可以通过使用显式形式来避免 MWE 中出现的直接问题,即选项dataonly=true
未正确解析skipbib=true,skipbiblist=true,skiplab=true
。
代替
\newcommand*{\nhblx@writenametobib}[1]{%
\stepcounter{nhblx@name}%
\edef\nhblx@tmp@nocite{%
\noexpand\AfterPreamble{%
\noexpand\setbox0\noexpand\vbox{%
\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{#1}}, %
options = {dataonly=true},}%
}%
}
和
\newcommand*{\nhblx@writenametobib}[1]{%
\stepcounter{nhblx@name}%
\edef\nhblx@tmp@nocite{%
\noexpand\AfterPreamble{%
\noexpand\setbox0\noexpand\vbox{%
\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{#1}}, %
options = {skipbib=true,skipbiblist=true,skiplab=true},}%
}%
}
即使使用 BibTeX,以下 MWE 也能产生可接受的输出。
\documentclass[portuguese,a4paper,nologo]{europasscv}
\usepackage[utf8]{inputenc}
\usepackage[backend=bibtex,autolang=hyphen,sorting=none,style=numeric,maxbibnames=99,doi=true,isbn=false,maxcitenames=2]{biblatex}
\usepackage{csquotes}
\usepackage{europasscv-bibliography}
\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}[1]{%
\stepcounter{nhblx@name}%
\edef\nhblx@tmp@nocite{%
\noexpand\AfterPreamble{%
\noexpand\setbox0\noexpand\vbox{%
\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{#1}}, %
options = {skipbib=true,skipbiblist=true,skiplab=true},}%
}%
}
\AtEndDocument{%
\closeout\nhblx@bibfile}
\addbibresource{\nhblx@bibfile@name}
\newcommand*{\nhblx@boldhashes}{}
\DeclareNameFormat{nhblx@hashextract}{%
\xifinlist{\thefield{hash}}{\nhblx@boldhashes}
{}
{\listxadd{\nhblx@boldhashes}{\thefield{hash}}}}
\DeclareCiteCommand{\nhblx@getmethehash}
{}
{\printnames[nhblx@hashextract][1-999]{author}}
{}
{}
\newcommand*{\addboldnames}{\forcsvlist\nhblx@writenametobib}
\newcommand*{\resetboldnames}{\def\nhblx@boldhashes{}}
\newcommand*{\mkboldifhashinlist}[1]{%
\xifinlist{\thefield{hash}}{\nhblx@boldhashes}
{\mkbibbold{#1}}
{#1}}
\makeatother
\DeclareNameWrapperFormat{boldifhashinlist}{%
\renewcommand*{\mkbibcompletename}{\mkboldifhashinlist}%
#1}
\DeclareNameWrapperAlias{sortname}{default}
\DeclareNameWrapperAlias{default}{boldifhashinlist}
\resetboldnames\addboldnames{{Pedro Filipe Oliveira}, {Pedro Oliveira}}
\begin{filecontents}[overwrite]{\jobname.bib}
@article{oliveira2016blegen,
title={BLEGen—a code generator for bluetooth low energy services},
author={Oliveira, Pedro Filipe and Matos, Paulo},
journal={Lecture Notes on Software Engineering},
volume={4},
number={1},
pages={7--11},
year={2016},
publisher={Lecture Notes on Software Engineering}
}
@inproceedings{oliveira2016behaviour,
title={Behaviour analysis in smart spaces},
author={Oliveira, Pedro and Matos, Paulo and Novais, Paulo},
booktitle={2016 Intl IEEE Conferences on Ubiquitous Intelligence \& Computing, Advanced and Trusted Computing, Scalable Computing and Communications, Cloud and Big Data Computing, Internet of People, and Smart World Congress (UIC/ATC/ScalCom/CBDCom/IoP/SmartWorld)},
pages={880--887},
year={2016},
organization={IEEE}
}
@inproceedings{oliveira2017challenges,
title={Challenges in smart spaces: aware of users, preferences, behaviours and habits},
author={Oliveira, Pedro and Novais, Paulo and Matos, Paulo},
booktitle={International Conference on Practical Applications of Agents and Multi-Agent Systems},
pages={268--271},
year={2017},
organization={Springer, Cham}
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\begin{europasscv}
\section{Introduction}
\nocite{*}
\renewcommand{\section}[2]{\ecvsection{#2}}
\printbibtabular[title=Publicações]
\end{europasscv}
\end{document}