4

I am writing my thesis and I want to highlight my name in the publications using the \fullcite{} while keeping the main bibliography untouched (if not possible, the name can also be highlighted there). I tried the approaches in :

But I was not able to put it work. Thus I defined a command:

% Show me as author
%\newcommand*{\showme}[1]{\textbf{#1}}
\newcommand*{\showme}[1]{\mkbibbold{#1}}

To be used inside my biblio.bib. It seem to work. But them I noticed that the entry is not formated as the other authors' name. It was easy to see because I am using ieee style.

@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},
}

Which gives:

Carlos F. M. Silva, J. M. B. S. Jr., and T. F. Maciel, “Radio resource management for device-to-device communications in long term evolution networks”, in Resource Allocation and MIMO for 4G and Beyond, F. R. P. Cavalcanti, Ed., New York, USA: Springer Science+Business Media, 2014, pp. 105–156, isbn: 978-1-4614-8056-3. doi: 10.1007/978-1-4614-8057-0_3

As it can be seen, my first name appears full, while the correct entry would be C. F. M. Silva. I know this happens because anything inside {} is not formated by the bibliography style.

So my question is: how can I define such a command to let the bibliography style to format my name and put it on bold if a flag is on, i.e., \ifshowme=1. The MWE is below.

\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}
  • You should not alter the author list by wrapping certain names in macros, that destroys Biber's ability to parse them correctly, as you found out. My go-to solution is Make specific author bold using biblatex, you will have to try matching for \forcsvlist{\listadd\boldnames} {{Silva, C\bibinitperiod\bibinitdelim F\bibinitperiod\bibinitdelim M\bibinitperiod}} The modern solution would check against the hash which in your case is 5e1df516fe8816ee66169b8616522816. – moewe Oct 23 '15 at 7:34
  • Can you post a solution. Also I have my name written in different forms, how can I know this biblatex macros that I can use, I mean the \bibinitperiod and friends? – cacamailg Oct 23 '15 at 12:54
  • You have to have a look at the .bbl file. I will post a hash solution and explain how to extract the information from the .bbl. – moewe Oct 23 '15 at 12:59
  • 1
    There you are. If you can spare the time you might want to have a look at my recent answer to an ancient question of yours I attempted to get it off the unanswered list, let me know what you think. – moewe Oct 23 '15 at 13:12
10

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}
\usepackage{xpatch}

\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*{\hlblx@doboldhashes}[1]{%
  \iffieldequalstr{hash}{#1}
    {\bfseries\listbreak}
    {}}%

\newbibmacro*{name:bold}{%
  \forlistloop{\hlblx@doboldhashes}{\hlbxl@boldhashes}%
}

\xpretobibmacro{name:family}{\begingroup\usebibmacro{name:bold}}{}{}
\xpretobibmacro{name:given-family}{\begingroup\usebibmacro{name:bold}}{}{}
\xpretobibmacro{name:family-given}{\begingroup\usebibmacro{name:bold}}{}{}
\xpretobibmacro{name:delim}{\begingroup\normalfont}{}{}

\xapptobibmacro{name:family}{\endgroup}{}{}
\xapptobibmacro{name:given-family}{\endgroup}{}{}
\xapptobibmacro{name:family-given}{\endgroup}{}{}
\xapptobibmacro{name:delim}{\endgroup}{}{}

\addboldname{{Silva, Carlos F. M.}}

\usepackage{filecontents}

\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*{\doboldhashes}[1]{%
  \iffieldequalstr{hash}{#1}
    {\bfseries\listbreak}
    {}}%

\newbibmacro*{name:bold}{%
  \forlistloop{\doboldhashes}{\boldnames}%
}

\newcommand*{\boldnames}{}

\xpretobibmacro{name:family}{\begingroup\usebibmacro{name:bold}}{}{}
\xpretobibmacro{name:given-family}{\begingroup\usebibmacro{name:bold}}{}{}
\xpretobibmacro{name:family-given}{\begingroup\usebibmacro{name:bold}}{}{}
\xpretobibmacro{name:delim}{\begingroup\normalfont}{}{}

\xapptobibmacro{name:family}{\endgroup}{}{}
\xapptobibmacro{name:given-family}{\endgroup}{}{}
\xapptobibmacro{name:family-given}{\endgroup}{}{}
\xapptobibmacro{name:delim}{\endgroup}{}{}

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=5e1df516fe8816ee66169b8616522816}{Silva}{S\bibinitperiod}{Carlos\bibnamedelimb F.\bibnamedelimi M.}{C\bibinitperiod\bibinitdelim F\bibinitperiod\bibinitdelim M\bibinitperiod}{}{}{}{}}%
    {{hash=25312689babd7b2fcc1eb301692898cc}{Silva}{S\bibinitperiod}{Jos\'{e}\bibnamedelimb Mairton\bibnamedelima B.}{J\bibinitperiod\bibinitdelim M\bibinitperiod\bibinitdelim B\bibinitperiod}{}{}{Jr.}{J\bibinitperiod}}%
    {{hash=3288e5f9be7ec7c330203382f4e8d8ed}{Maciel}{M\bibinitperiod}{Tarcisio\bibnamedelima F.}{T\bibinitperiod\bibinitdelim F\bibinitperiod}{}{}{}{}}%
  }
  \name{editor}{1}{}{%
    {{hash=7fd042d9c8417f3a11acbedfe7b6f16c}{Cavalcanti}{C\bibinitperiod}{Francisco\bibnamedelimb Rodrigo\bibnamedelima Porto}{F\bibinitperiod\bibinitdelim R\bibinitperiod\bibinitdelim P\bibinitperiod}{}{}{}{}}%
  }
  \list{location}{1}{%
    {New York, USA}%
  }
  \list{publisher}{1}{%
    {Springer Science+Business Media}%
  }
  \strng{namehash}{1b7bebb71b65fb1826534c0c0970d44b}
  \strng{fullhash}{1b7bebb71b65fb1826534c0c0970d44b}
  \field{sortinit}{S}
  \field{sortinithash}{fd1e7c5ab79596b13dbbb67f8d70fb5a}
  \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 5e1df516fe8816ee66169b8616522816, for J. M. B Silva Jr. it is 25312689babd7b2fcc1eb301692898cc.

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.

You can then add a list of hashes to the \boldnames macro

\renewcommand*{\boldnames}{}
\forcsvlist{\listadd\boldnames}
  {{5e1df516fe8816ee66169b8616522816}}

MWE

\documentclass{article}
\usepackage[backend=biber,style=numeric]{biblatex}

\usepackage{filecontents}

\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}

\usepackage{xpatch}% or use https://tex.stackexchange.com/a/40705

\newcommand*{\doboldhashes}[1]{%
  \iffieldequalstr{hash}{#1}
    {\bfseries\listbreak}
    {}}%

\newbibmacro*{name:bold}{%
  \forlistloop{\doboldhashes}{\boldnames}%
}

\newcommand*{\boldnames}{}

\xpretobibmacro{name:family}{\begingroup\usebibmacro{name:bold}}{}{}
\xpretobibmacro{name:given-family}{\begingroup\usebibmacro{name:bold}}{}{}
\xpretobibmacro{name:family-given}{\begingroup\usebibmacro{name:bold}}{}{}
\xpretobibmacro{name:delim}{\begingroup\normalfont}{}{}

\xapptobibmacro{name:family}{\endgroup}{}{}
\xapptobibmacro{name:given-family}{\endgroup}{}{}
\xapptobibmacro{name:family-given}{\endgroup}{}{}
\xapptobibmacro{name:delim}{\endgroup}{}{}

\renewcommand*{\boldnames}{}
\forcsvlist{\listadd\boldnames}
  {{5e1df516fe8816ee66169b8616522816}}

\begin{document}
\fullcite{Silva:2014a}

\printbibliography
\end{document}

Output

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.

  • 1
    In my MWE above I swithced the style to numeric for some reason, but you will find that it works with ieee just as well. You will also find that I have entered the second name as Silva, Jr., Jos\'{e} Mairton B., if it is entered as Jos\'{e} Mairton B. Silva Jr. Biber will think the last name is "Jr." and the first name is "Jos\'{e} Mairton B. Silva" which is obviously nonsense. – moewe Oct 23 '15 at 13:17
  • 1
    Alternative you can use the second solution in Audrey's post with \boldname{Silva}{Carlos F.~M.}{C.~F.~M.} (though that will break down if you leave out any initials in any of your .bib entries). – moewe Oct 23 '15 at 13:26
  • The MWE no longer seems to work in biblatex 3.4/ biber 2.5, my most recent TeX-dist upgrade seems to have broken this. At least with these I see no bold face in the MWE at all. Can anyone else confirm this or, preferably, has a work-around? – bjoseru Feb 12 '17 at 9:19
  • My issues seems to have been the ordering of firstname-lastname and that name:first-last and name:last-first have been renamed. With \xpretobibmacro{name:family-given}{\begingroup\usebibmacro{name:bold}{#1}{#2}}{}{} \xapptobibmacro{name:family-given}{\endgroup}{}{} \xpretobibmacro{name:given-family}{\begingroup\usebibmacro{name:bold}{#1}{#2}}{}{} \xapptobibmacro{name:given-family}{\endgroup}{}{} I seem to catch both variants and everything seems to work. – bjoseru Feb 12 '17 at 10:06
  • 1
    @bjoseru Indeed, the changes in 3.3 require those little changes, I have edited the answer accordingly. – moewe Feb 12 '17 at 10:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.