TeX - LaTeX Asked by Pedro Oliveira on January 30, 2021
Im using this code from Make specific author bold using biblatex to highlight authors with First Name Last Name and First Name Middle Name Last Name in this way:
makeatletter
defnhblx@bibfile@name{jobname -nhblx.bib}
newwritenhblx@bibfile
immediateopenoutnhblx@bibfile=nhblx@bibfile@name
immediatewritenhblx@bibfile{%
@comment{Auto-generated file}blx@nl}
newcounter{nhblx@name}
setcounter{nhblx@name}{0}
newcommand*{nhblx@writenametobib}[1]{%
stepcounter{nhblx@name}%
edefnhblx@tmp@nocite{%
noexpandAfterPreamble{%
noexpandsetbox0noexpandvbox{%
noexpandnhblx@getmethehash{nhblx@name@thevalue{nhblx@name}}}}%
}%
nhblx@tmp@nocite
immediatewritenhblx@bibfile{%
@misc{nhblx@name@thevalue{nhblx@name}, author = {unexpanded{#1}}, %
options = {dataonly=true},}%
}%
}
AtEndDocument{%
closeoutnhblx@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}{forcsvlistnhblx@writenametobib}
newcommand*{resetboldnames}{defnhblx@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}
resetboldnamesaddboldnames{{Pedro Filipe Oliveira}, {Pedro Oliveira}}
bibliography{info_extra_files/PFO_Publications}
The highlight is correct, but at references the first two publications printed are the boldnames defined before, like you can see in the picture attached.
The complete code is:
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
defnhblx@bibfile@name{jobname -nhblx.bib}
newwritenhblx@bibfile
immediateopenoutnhblx@bibfile=nhblx@bibfile@name
immediatewritenhblx@bibfile{%
@comment{Auto-generated file}blx@nl}
newcounter{nhblx@name}
setcounter{nhblx@name}{0}
newcommand*{nhblx@writenametobib}[1]{%
stepcounter{nhblx@name}%
edefnhblx@tmp@nocite{%
noexpandAfterPreamble{%
noexpandsetbox0noexpandvbox{%
noexpandnhblx@getmethehash{nhblx@name@thevalue{nhblx@name}}}}%
}%
nhblx@tmp@nocite
immediatewritenhblx@bibfile{%
@misc{nhblx@name@thevalue{nhblx@name}, author = {unexpanded{#1}}, %
options = {dataonly=true},}%
}%
}
AtEndDocument{%
closeoutnhblx@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}{forcsvlistnhblx@writenametobib}
newcommand*{resetboldnames}{defnhblx@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}
resetboldnamesaddboldnames{{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_Publications.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}
}
The code you are using assumes you run Biber as backend (backen=bibtex,
), but you are running the legacy BibTeX backend (backend=bibtex,
) which does not support all biblatex
features.
Most importantly, BibTeX does not actually calculate name hashes to the same level Biber does, so I'm not sure if correct name detection is guaranteed to work in all circumstances.
If at all possible, you should consider switching to Biber by changing backend=bibtex,
to backend=biber,
and running Biber on your document instead of BibTeX (Biblatex with Biber: Configuring my editor to avoid undefined citations will help with your editor configuration).
If you must stick with BibTeX, you can avoid the immediate problem in your MWE, namely that the option dataonly=true
is not resolved correctly, by using the explicit form skipbib=true,skipbiblist=true,skiplab=true
.
Replace
newcommand*{nhblx@writenametobib}[1]{%
stepcounter{nhblx@name}%
edefnhblx@tmp@nocite{%
noexpandAfterPreamble{%
noexpandsetbox0noexpandvbox{%
noexpandnhblx@getmethehash{nhblx@name@thevalue{nhblx@name}}}}%
}%
nhblx@tmp@nocite
immediatewritenhblx@bibfile{%
@misc{nhblx@name@thevalue{nhblx@name}, author = {unexpanded{#1}}, %
options = {dataonly=true},}%
}%
}
with
newcommand*{nhblx@writenametobib}[1]{%
stepcounter{nhblx@name}%
edefnhblx@tmp@nocite{%
noexpandAfterPreamble{%
noexpandsetbox0noexpandvbox{%
noexpandnhblx@getmethehash{nhblx@name@thevalue{nhblx@name}}}}%
}%
nhblx@tmp@nocite
immediatewritenhblx@bibfile{%
@misc{nhblx@name@thevalue{nhblx@name}, author = {unexpanded{#1}}, %
options = {skipbib=true,skipbiblist=true,skiplab=true},}%
}%
}
The following MWE produces acceptable output even with BibTeX.
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
defnhblx@bibfile@name{jobname -nhblx.bib}
newwritenhblx@bibfile
immediateopenoutnhblx@bibfile=nhblx@bibfile@name
immediatewritenhblx@bibfile{%
@comment{Auto-generated file}blx@nl}
newcounter{nhblx@name}
setcounter{nhblx@name}{0}
newcommand*{nhblx@writenametobib}[1]{%
stepcounter{nhblx@name}%
edefnhblx@tmp@nocite{%
noexpandAfterPreamble{%
noexpandsetbox0noexpandvbox{%
noexpandnhblx@getmethehash{nhblx@name@thevalue{nhblx@name}}}}%
}%
nhblx@tmp@nocite
immediatewritenhblx@bibfile{%
@misc{nhblx@name@thevalue{nhblx@name}, author = {unexpanded{#1}}, %
options = {skipbib=true,skipbiblist=true,skiplab=true},}%
}%
}
AtEndDocument{%
closeoutnhblx@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}{forcsvlistnhblx@writenametobib}
newcommand*{resetboldnames}{defnhblx@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}
resetboldnamesaddboldnames{{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}
Answered by moewe on January 30, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP