Edit Continuing updates for this methods are posted to https://tex.stackexchange.com/a/416416/35864.
The following solution automatically extracts the hashes for the given names. Everything else is based on the bit of the answer below.
Warning! The code will write a .bib
file called <your TeX file/\jobname>-boldnames.bib
, if it exists, it will be overwritten. You can change the name of that file by adjusting the value of \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}
We can use Audrey's approach to Make specific author bold using biblatex, but instead of string comparison we use the name hash produced by 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}
You can find out the hash
values for your name (and its versions) by looking at the .bbl
file produced by Biber, it will contain information for a cited entry like this
\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
The hash for the relevant name is shown right before the name, for C. F. M. Silva is 894de27062ab25d43f1d7b50fd923256
, for J. M. B Silva Jr. it is cc273ec4593222cb35c353d3f073214e
. (Note that the value of this hash may change between Biber version: Check that the names highlight correctly after an update.)
Since the hash
is different for different name inputs (the hash
for "Donald E. Knuth" will not equal the one for "D. E. Knuth" or "Donald Knuth")
you will have to find the correct hash for all the variants you use of your name.
With the help of
\newcommand*{\detokenizelistadd}[2]{%
\listeadd#1{\detokenize{#2}}}
you can then add a list of hashes to the \boldnames
macro
\forcsvlist{\detokenizelistadd\boldnames}
{{894de27062ab25d43f1d7b50fd923256}}
MWE
\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}
The answer has been updated to reflect the changes needed for biblatex
>= 3.3 (see biblatex
3.3 name formatting). All mentions of last
in name macros are now family
and first
becomes given
. Refer to the edit history for the pre-3.3 code.
edited to use a more elegant version to format complete names. \DeclareNameWrapperFormat
and \mkbibcompletename
are only available in biblatex
v3.12 (2018-10-30) and v3.13 (2019-08-17), respectively. Please refer to the edit history if you are using an older version of biblatex
.
Here is a solution for the references (way 1). For citations, I used the style authoryear-comp
which is not quite what you want, but is closer than what you have now.
\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[citestyle=authoryear-comp,
bibstyle=authoryear,
giveninits=true,
maxcitenames=2,
uniquelist=false,
sortcites,
maxbibnames=99,
sorting=ynt,
url=false,
eprint=false,
isbn =false
]{biblatex}
\renewcommand*{\nameyeardelim}{\addcomma\space}
\usepackage[none]{hyphenat}
\addbibresource{Example.bib}
%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewbibmacro{in:}{%
\ifentrytype{article}{}{\printtext{\bibstring{in}\intitlepunct}}}
\DeclareFieldFormat{journaltitle}{#1}
\DeclareSourcemap{% requires biber
\maps[datatype=bibtex]{
\map{
\step[fieldset=note, null]
}
}
}
\renewbibmacro*{volume+number+eid}{%
\printfield{volume}%
\printfield[parens]{number}%
\setunit{\addcomma\space}%
\printfield{eid}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%For italic et al. %%%
\renewbibmacro*{name:andothers}{
\ifboolexpr{
test {\ifnumequal{\value{listcount}}{\value{liststop}}}
and
test \ifmorenames
}
{\ifnumgreater{\value{liststop}}{1}
{\finalandcomma}
{}%
\andothersdelim\bibstring[\emph]{andothers}}
{}}
%%%
\DeclareNameAlias{sortname}{last-first}
\begin{document}
\parencite{Ho2012,Ho2012a,Ho2007}
\newrefcontext{sorting=nyt}
\printbibliography
\end{document}
Best Answer
You are trying to adjust the citation that appears with
\fullfootcite
, which is a citation, not a bibliography item. So the appropriate way to clear the fields as you desire is to includein the preamble of the document. You should also be able to include it in
biblatex.cfg
for a more universal application, but note that this will then affect any of your documents, and might be harder to find it once you've forgotten about this change. ;-)Edit
The extra functionality you are asking about can be done with this code in the preamble.