3

I want to make bold specific author, wherever it placed (i.e., 1st, 2nd does not matter) when only citing at the text area (i.e., should not get bold in reference section).

For full citation in the text/normal section, I used the method described here. For changing it to bold, I found this answer might be useful, but don't how to incorporate it in the \printpublication command.

MWE:

\documentclass{article}
\usepackage[backend=biber,natbib=true,style=ieee,
   citestyle=numeric-comp,sorting=none,doi=false,isbn=false,url=true,]{biblatex}

\usepackage{filecontents}

\begin{filecontents}{\cite.bib}
@misc{A01,
  author = {Author, Arik and Author, Jaz and Author, Ricky},
  year = {2100},
  title = {An unnecessary long title},
}
@book{A02,
  author = {Author, Jaz and Author, Arik and Author, Ricky},
  year = {2100},
  title = {An unnecessary long title},
}
\end{filecontents}
\addbibresource{\cite.bib}


\newcommand{\printpublication}[1]{\AtNextCite{\defcounter{maxnames}{3}\defcounter{minnames}{1}}\fullcite{#1}}

\begin{document}
    \printpublication{A01}
    \printpublication{A02}

\printbibliography
\end{document}
  • Please mark the question as solved if the given answer suits your needs (see check mark next to the answer) – bonanza Apr 29 at 13:11
2

Building on my answer to Make specific author bold using biblatex, which has a slightly more convenient user interface for the bold names, we can define the new command \printpublication.

The exact working of the code for bold names is explained in the linked answer: The gist is that we write the names to an external .bib and can then extract the hash automatically from the .bbl file. With the hashes we can then go on to highlight the names, the hashes of interest are stored in a list.

The name format given-family:bold is a copy of biblatex.def's given-family name format, just with a wrapper command (in the style of the second part of my answer to Indicating joint first authorship through special markup in biblatex/biber). That wrapper command \mkbibcompletename highlights exactly those names for which the hashes are in the list of interest.

\printpublication is a copy of \fullcite with the \defcounters as well as the new bold name format thrown directly into the precode of \usedriver.

\documentclass{article}
\usepackage[backend=biber, natbib=true, style=ieee, sorting=none,
  doi=false, isbn=false, url=true]{biblatex}

\makeatletter
% auxiliary bibfile
\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}}
  {}
  {}

% user-level macros
\newcommand*{\addboldnames}{\forcsvlist\hlblx@writenametobib}
\newcommand*{\resetboldnames}{\def\hlbxl@boldhashes{}}

\DeclareNameFormat{given-family:bold}{%
  \ifgiveninits
    {\usebibmacro{name:given-family:bold}
      {\namepartfamily}
      {\namepartgiveni}
      {\namepartprefix}
      {\namepartsuffix}}
    {\usebibmacro{name:given-family:bold}
      {\namepartfamily}
      {\namepartgiven}
      {\namepartprefix}
      {\namepartsuffix}}%
  \usebibmacro{name:andothers}}

\newbibmacro*{name:given-family:bold}[4]{%
  \usebibmacro{name:delim}{#2#3#1}%
  \usebibmacro{name:hook}{#2#3#1}%
  \mkbibcompletename{%
    \ifdefvoid{#2}{}{\mkbibnamegiven{#2}\isdot\bibnamedelimd}%
    \ifdefvoid{#3}{}{%
      \mkbibnameprefix{#3}\isdot
      \ifprefchar
        {}
        {\ifuseprefix{\bibnamedelimc}{\bibnamedelimd}}}%
    \mkbibnamefamily{#1}\isdot
    \ifdefvoid{#4}{}{\bibnamedelimd\mkbibnamesuffix{#4}\isdot}}}

\newcommand*{\mkbibcompletename}[1]{%
  \xifinlist{\thefield{hash}}{\hlbxl@boldhashes}
    {\mkbibbold{#1}}
    {#1}}
\makeatother

\DeclareCiteCommand{\printpublication}
  {\usebibmacro{prenote}}
  {\usedriver
     {\DeclareNameAlias{sortname}{default}%
      \DeclareNameAlias{default}{given-family:bold}%
      \defcounter{maxnames}{3}%
      \defcounter{minnames}{1}}
     {\thefield{entrytype}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\addboldnames{{Author, Arik}}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@misc{A01,
  author = {Author, Arik and Author, Jaz and Author, Ricky},
  year   = {2100},
  title  = {An unnecessary long title},
}
@book{A02,
  author = {Author, Jaz and Author, Arik and Author, Ricky},
  year   = {2100},
  title  = {An unnecessary long title},
}
\end{filecontents}
\addbibresource{\jobname.bib}


\begin{document}
  \printpublication{A01}

  \printpublication{A02}

  \printbibliography
\end{document}

"**A. Author**, J. Author, and R. Author, An unnecessary long title, 2100"//"J. Author, **A. Author**, and R. Author, An unnecessary long title. 2100." Bibliography the same but without bold highlights for names.

  • Thanks so much its working great in general. However, I have a problem for publications with four or more authors: It prints "A. Author et al." instead of all authors. Unfortunately, the author I would like to highlight is not the first author. How to fix this? I have seen that maxcitenames might be a related option. How to apply this to \printpublcation only? – bonanza Apr 23 at 7:19
  • 1
    @bonanza Try changing the \defcounter{maxnames}{3}% in the code above to to \defcounter{maxnames}{999}% or whatever you want. If that does not help, please consider asking a new question with an MWE and more details about your setup. – moewe Apr 23 at 7:30

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.