5

I am using biblatex with the following setup:

\usepackage[style=nejm,hyperref,natbib,backend=biber,maxnames=2,minnames=1]{biblatex}

Let us consider, as an example, this citation. (

@article{RefWorks:41,
    author={K. J. Koval and J. J. Harrast and J. O. Anglen and J. N. Weinstein},
    year={2008},
    month={Sep},
    title={Fractures of the distal part of the radius. The evolution of practice over time. Where's the evidence?},
    journal={The Journal of bone and joint surgery.American volume},
    volume={90},
    number={9},
    pages={1855-1861},
}

When I am citing with \textcite{RefWorks:41}, I would like to make the name part Koval et al. appearing such as \textbf{\textsf{\textsc{Koval et al.}}}. In the meantime, the bibstyle should remain unchanged. In addition, it should be applied to selected citations (not to all, but to some specific ones depending the context.) Any ideas?Suggestions?

Edit: Further explanation: given the author key in the bib file author={K. J. Koval and J. J. Harrast and J. O. Anglen and J. N. Weinstein}, I would like to make the the "author" part of the output of \textcite bold whatever it is. I mean, with maxnames=2,minnames=1, the output should be Koval et al. [25], with maxnames=6,minnames=3 it should be Koval, Harrast, Anglen e Weinstein [25] with the latter part (25) left unchanged.

Also, if a reference is cited more than one time, i would like to choose which citation should be bolded (not all of them).

  • possible duplicate of Make specific author bold using biblatex – Alan Munn Jul 28 '14 at 22:28
  • 1
    No, i think it is not. I am not searching to make bold a specific name or author,but to have the possibility of making the citations bold when I think it is necessary (that is much more general). Second, the question was specific to the bibliography, but I want to modify the behaviour in the text – Pierpaolo Jul 28 '14 at 23:15
  • 1
    Ok, sorry about that. Yes, you're right this is not a duplicate. Other voters: please do NOT vote to close! – Alan Munn Jul 28 '14 at 23:16
  • Do you just need a single particular name to be bolded or an arbitrary list of names? – Alan Munn Jul 29 '14 at 0:41
  • why is the duplicate banner still at the top? – Pierpaolo Jul 29 '14 at 8:37
5

Normally, this would not take more than a few lines of code, the nejm style is based on numeric-comp though, and numeric-comp has a very peculiar handling of textcite to make sure everything looks nice. So we will have to copy quite some code for a very minor modification.

Our new bibmcaro boldtextcite is a verbatim copy of textcite's bibmacro with the \mkbibbold wrapper added around \printnames{labelnames}. \cbx@boldtextcite is a helper to define \boldtextcite in \DeclareCiteCommand{\boldtextcite}.

\makeatletter
\newbibmacro*{boldtextcite}{%
  \iffieldequals{namehash}{\cbx@lasthash}
    {\usebibmacro{cite:comp}}
    {\usebibmacro{cite:dump}%
     \ifbool{cbx:parens}
       {\bibclosebracket\global\boolfalse{cbx:parens}}
       {}%
     \iffirstcitekey
       {}
       {\textcitedelim}%
     \usebibmacro{cite:init}%
     \ifnameundef{labelname}
       {\printfield[citetitle]{labeltitle}}
       {\mkbibbold{\printnames{labelname}}}%
     \global\booltrue{cbx:parens}%
     \addspace\bibopenbracket%
     \ifnumequal{\value{citecount}}{1}
       {\usebibmacro{prenote}}
       {}%
     \usebibmacro{cite:comp}%
     \stepcounter{textcitecount}%
     \savefield{namehash}{\cbx@lasthash}}}

\DeclareCiteCommand{\cbx@boldtextcite}
  {\usebibmacro{cite:init}}
  {\usebibmacro{citeindex}%
   \usebibmacro{boldtextcite}}
  {}
  {\usebibmacro{cite:dump}%
   \usebibmacro{postnote}%
   \ifbool{cbx:parens}
     {\bibclosebracket\global\boolfalse{cbx:parens}}
     {}}

\DeclareCiteCommand{\boldtextcite}[\cbx@textcite@init\cbx@boldtextcite]
  {\gdef\cbx@savedkeys{}%
   \citetrackerfalse%
   \pagetrackerfalse%
   \DeferNextCitekeyHook%
   \usebibmacro{cite:init}}
  {\ifthenelse{\iffirstcitekey\AND\value{multicitetotal}>0}
     {\protected@xappto\cbx@savedcites{()(\thefield{multipostnote})}%
      \global\clearfield{multipostnote}}
     {}%
   \xappto\cbx@savedkeys{\thefield{entrykey},}%
   \iffieldequals{namehash}{\cbx@lasthash}
     {}
     {\stepcounter{textcitetotal}%
      \savefield{namehash}{\cbx@lasthash}}}
  {}
  {\protected@xappto\cbx@savedcites{%
     [\thefield{prenote}][\thefield{postnote}]{\cbx@savedkeys}}}
\makeatother

We now have to cite commands, the standard \textcite and \boldtextcite that turns the names bold.

MWE

\documentclass{article}
\usepackage{filecontents}
\usepackage[style=nejm,hyperref,natbib,backend=biber,maxnames=2,minnames=1]{biblatex}


\makeatletter
\newbibmacro*{boldtextcite}{%
  \iffieldequals{namehash}{\cbx@lasthash}
    {\usebibmacro{cite:comp}}
    {\usebibmacro{cite:dump}%
     \ifbool{cbx:parens}
       {\bibclosebracket\global\boolfalse{cbx:parens}}
       {}%
     \iffirstcitekey
       {}
       {\textcitedelim}%
     \usebibmacro{cite:init}%
     \ifnameundef{labelname}
       {\printfield[citetitle]{labeltitle}}
       {\mkbibbold{\printnames{labelname}}}%
     \global\booltrue{cbx:parens}%
     \addspace\bibopenbracket%
     \ifnumequal{\value{citecount}}{1}
       {\usebibmacro{prenote}}
       {}%
     \usebibmacro{cite:comp}%
     \stepcounter{textcitecount}%
     \savefield{namehash}{\cbx@lasthash}}}

\DeclareCiteCommand{\cbx@boldtextcite}
  {\usebibmacro{cite:init}}
  {\usebibmacro{citeindex}%
   \usebibmacro{boldtextcite}}
  {}
  {\usebibmacro{cite:dump}%
   \usebibmacro{postnote}%
   \ifbool{cbx:parens}
     {\bibclosebracket\global\boolfalse{cbx:parens}}
     {}}

\DeclareCiteCommand{\boldtextcite}[\cbx@textcite@init\cbx@boldtextcite]
  {\gdef\cbx@savedkeys{}%
   \citetrackerfalse%
   \pagetrackerfalse%
   \DeferNextCitekeyHook%
   \usebibmacro{cite:init}}
  {\ifthenelse{\iffirstcitekey\AND\value{multicitetotal}>0}
     {\protected@xappto\cbx@savedcites{()(\thefield{multipostnote})}%
      \global\clearfield{multipostnote}}
     {}%
   \xappto\cbx@savedkeys{\thefield{entrykey},}%
   \iffieldequals{namehash}{\cbx@lasthash}
     {}
     {\stepcounter{textcitetotal}%
      \savefield{namehash}{\cbx@lasthash}}}
  {}
  {\protected@xappto\cbx@savedcites{%
     [\thefield{prenote}][\thefield{postnote}]{\cbx@savedkeys}}}
\makeatother

\addbibresource{biblatex-examples.bib}
\begin{document}
\textcite{wilde,companion}

\boldtextcite{wilde,companion}

\printbibliography
\end{document}

enter image description here

| improve this answer | |
  • Thank you!. Any ideas about \adding \textsf{\textsc{ to the bold? The desired result should be\textbf{\textsf{\textsc{Koval et al.}}} – Pierpaolo Jul 29 '14 at 13:50
  • 2
    @thunder1123 In the first macro you will find the line {\mkbibbold{\printnames{labelname}}}. You can add any mark-up modifications you like there. But as far as I know, the lmodern fonts cannot deal with \textbf{\textsf{\textsc - there is no bold small caps version. I'm not too sure that you will actually find a font that has all the three features together. (Linux Libertine and its companion maybe?) – moewe Jul 29 '14 at 13:55
  • @thunder1123 I just had a look, lmodern and the standard font do not support this font combination (Some font shapes were not available, defaults substituted.), but libertine is fine with it. I used {\textsf{\textsc{\mkbibbold{\printnames{labelname}}}}}%. Since \textsf and \textsc do not have a biblatex-y equivalent. – moewe Jul 29 '14 at 14:07

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.