# Make one author's name bold every time it shows up in the bibliography

I'm working on a CV. I'd like to highlight my name in every entry in the bibliography. I've tried simply replacing {myname} with {\bf myname} or {{\bf myname}}, but they fail with various errors, particularly when sorting.

This post gives a solution that's nearly what I'm looking for. The solution in the linked post is to use:

\newcommand{\myname}[1]{\textbf{#1}}


to wrap all instances of the name in question.

EDIT: Removed error example because it was caused by an unassociated error in a .bst file. The answer selected below now directly answers the only question posed above.

• Maybe you can simply modify the .bib database to change your name to be a macro and use \providecommand to provide a default value for the macro. – Leo Liu Nov 1 '11 at 16:12
• It is always best to compose a MWE that illustrates the problem including the \documentclass so that those trying to help don't have to recreate it. – Peter Grill Nov 1 '11 at 16:56
• Do you use bibtex or biblatex? – Mico Nov 1 '11 at 16:57
• Mico: bibtex. Peter: I'll work on that. – keflavich Nov 1 '11 at 17:11
• cfr: to make it easier for readers to see where you are in the author list. In my field, at least, it makes a big difference if you're first or n'th author, and it can matter (though honestly, probably not...) whether n=2 or n=100 – keflavich Apr 2 '15 at 8:15

In the solution I found, you need to modify your bibtex style file for this and implement a new TeX macro. Suppose you use the plain bibliography style. Locate plain.bst (you can use the command kpsewhich plain.bst for that) and copy it to your local tex directory as, say, myplain.bst. In myplain.bst locate the function format.names. In this function replace the line

{ s nameptr "{ff~}{vv~}{ll}{, jj}" format.name$'t :=  by { "\FormatName{" s nameptr "{ff~}{vv~}{ll}{, jj}" format.name$ * "}" * 't :=


Now in your tex file, first change the style to myplain.bst and insert the following macro definitions:

\def\FormatName#1{%
\def\myname{Elmar Zander}%
\edef\name{#1}%
\ifx\name\myname
\textbf{#1}%
\else
#1%
\fi
}


This should work now. (And, of course, don't forget do replace my name by yours ;-)

Note1: format.name$ is a builtin function that takes the preceding three arguments, which are: a string with the author names (s), the number of the name to be formatted (nameptr) and a formatting string ("{ff~...") and formats the author name according to this format string. As bibtex is stack oriented the arguments need to be pushed first on the stack, then format.name$ pops them off the stack, computes the result and pushes it back onto the stack. The "ff,ll,vv,jj" in the format string stand for first name(s), last name, stuff like "von" or "de", and stuff like "jr./junior" respectively (see btxhak.pdf included in the bibtex distribution). The single letter versions "f", "l" etc. would give you abbreviated forms. The * operator in bibtex concatenates two strings. Again, the strings need to be on the stack first, and the result is pushed back on the top of the stack.

Note2: You can have the FormatName macro in your bst file: modify the begin.bib function in myplain.bst in the following way

FUNCTION {begin.bib}
{
"\def\FormatName#1{%" write$" \edef\name{#1}%" write$
"  \ifx\name\myname" write$" \textbf{#1}%" write$
"  \else%" write$" #1%" write$
"  \fi" write$"}" write$
preamble$empty$
'skip${ preamble$ write$newline$ }
if$"\begin{thebibliography}{" longest.label * "}" * write$ newline$}  Just keep the \def\myname{...} macro in your tex file. So that you can change the name to be highlighted (if any) easily. Note3: the FormatName command can have problems with the spaces between a first name and last name, and it will also not find both 'Elmar Zander' and 'E. Zander'. If the above does not work for you, you can use the xstring package and then define FormatName as follows: \def\FormatName#1{% \IfSubStr{#1}{Zander}{\textbf{#1}}{#1}% }  • That may be an alternate solution, but I like the simpler one I've seen that simply requires replacing elements in the .bib file; since I am more fluent in .bib and .tex than .bst, I trust editing those files more. Still, I like the example... it helps me understand what the bst file does. – keflavich Nov 1 '11 at 22:57 • Well, I prefer separating the formatting from the content and this solution does. I wouldn't want to put formatting commands into one of my bib files. If you ever decide e.g. you want another name emphasized with this solution it will be easy. I agree that fiddling with bst files ist not to everyones liking (in fact they're really horrible), but you don't need to understand the bibtex style file language in order to apply the patch given. Whatever, its yours to decide and what you're more comfortable with. – Elmar Zander Nov 2 '11 at 10:09 • That's a fair point - with any other language, I'd go the route you suggested. Can you explain what that line is, though? i.e., what does nameptr, format.name$, {ff~}, etc. mean? Also, is it possible to put the \FormatName command into the .bst file or does it have to be in the .tex file? – keflavich Nov 2 '11 at 15:08
• Please see the two notes I've added to my post, since they would not have fitted into the comment field. – Elmar Zander Nov 2 '11 at 16:03
• the first solution seems to insert a lot of whitespace. Is there a way to trim it? There's a trimspaces package but I can't get it to work with the provided macro. – user10226 Dec 22 '11 at 19:39

You can do this with BibLaTeX without much hackery by putting the following in your preamble:

\newcommand{\makeauthorbold}[1]{%
\DeclareNameFormat{author}{%
\ifnumequal{\value{listcount}}{1}
{\ifnumequal{\value{liststop}}{1}
{\ifnumless{\value{listcount}}{\value{liststop}}
}%
}%
}
\makeauthorbold{Smith}


By using \IfSubStr from the xstring package in place of \ifstrequal one can also make multiple names bold with something like the following:

\usepackage{xstring}
\newcommand{\makeauthorsbold}[1]{%
\DeclareNameFormat{author}{%
\ifnumequal{\value{listcount}}{1}
{\ifnumequal{\value{liststop}}{1}
{\ifnumless{\value{listcount}}{\value{liststop}}
}%
}%
}
\makeauthorsbold{Smith,Doe}


The only caveat is that this will also make authors bold whose name is a sub string of one of the given names. For example "Do" will also end up being bold.

Update: For biblatex 3.3 and above use the answer by Lawrence Crosby below.

• Could you 'wrap' this in a macro, so it is possible to add \makeauthorbold{Smith} and \makeauthorbold{Williams} in the preamble? I am not sure how that works, since it already uses #1 and such. – Andy Nov 12 '14 at 12:33
• You can use ##1 in nested \newcommand like constructs. Aparently this also works with \DeclareNameFormat. See also tex.stackexchange.com/questions/39339/… – cgogolin Nov 19 '14 at 12:13
• \makeauthorbold works with non latin script, but \makeauthorsbold doesn't. Any idea why and how to fix it? – Theo Nov 20 '15 at 20:41
• This seems to mess up (in the bibliography) the detection of the last author in the list, whose name should be preceded by "and" and not followed by a comma. So instead of "Smith and Doe (1990)" I get "Smith, Doe, (1990)", even when the author printed in bold is Darwin. I use style=authoryear-comp,natbib=true in biblatex... maybe I should open a new question? – Jos Dec 14 '15 at 13:40
• Without having tested anything I suspect that either the authoryear-comp style or the option natbib=true also sets the format for printing names by calling \DeclareNameFormat. This is then overwritten when the above macro is called. I guess the only solution is to look into how this combination affects the name format and replicate this behavior in the macro defined above. – cgogolin Dec 15 '15 at 11:18

As of biblatex 3.3 cgogolin's answer no longer works. This is due to changes in the \DeclareNameFormat macro (see https://github.com/plk/biblatex/issues/372 for a discussion). I was eventually able to modify cgogolin's macro to work, with the following as the solution:

\newcommand{\makeauthorbold}[1]{%
\DeclareNameFormat{author}{%
\ifthenelse{\value{listcount}=1}
{%
%
}{\ifnumless{\value{listcount}}{\value{liststop}}
}
\ifthenelse{\value{listcount}<\value{liststop}}
}
}


This is my first attempt to write LaTeX macros, so I hope the code style doesn't deviate too far from convention. Hopefully this will help those who are using newer versions of the biblatex package.

• I did try your solution in a small document and everything was working fine. After putting it into a huge document with multiple \include{}-commands it did not work anymore and the error message was not useful for me at all. I suspected, the reason was because I use multiple bibliographies as explained here: tex.stackexchange.com/questions/35279/… . But this was not the case. As soon, as I had the \printbibliography-command in my main file, everything worked again. Does anybody have an idea, what the reason could be? – bene Apr 16 '17 at 9:31
• I tried this solution but it just removed the list of authors in the bibliography :-(. – Matthieu Moy Oct 3 '17 at 8:47
• When I want the bibliography to stop listing names after the first 20, using [minbibnames=5, maxbibnames=20], this macro deletes the "et al" part. – K.-Michael Aye Nov 23 '17 at 2:03
• This macro deletes all the "et al" parts not with maxbibnames=20 but with maxnames=2 also and even without maxnames... It deletes this part anyway as far as I checked (but not sure) – koleygr Mar 18 '19 at 18:14
• Like cgogolin's answer this suggestion does not take prefixes and suffixes into account. It also drops "et al." handling and hard-codes things that are otherwise customisable. Furthermore the last \ifthenelse misses the <false> branch and produces a weird error in newer biblatex versions (similar in structure to github.com/plk/biblatex/issues/874). tex.stackexchange.com/q/73136/35864 has alternatives that keep underlying biblatex macros alive. – moewe Mar 19 '19 at 16:08

I think a simpler method contained within the .bst file works as follows (i.e., take your favorite .bst, create a duplicate, and add this code to that as in the previous answer).

1. Create a function that returns your name:

FUNCTION {cv.author}
{ "Doe, J." }

2. Create a function that highlights stuff (here, bold and small caps)

FUNCTION {highlight}
{ duplicate$empty$
{ pop$"" } { "\textbf{\textsc{" swap$ * "}}" * }
if$}  3. Create a function that highlights your name FUNCTION {highlight.if.cv.author} { duplicate$ purify$cv.author purify$ =
{ highlight }
'skip$if$
}

4. Finally, in the function FUNCTION {format.names}, add a call to this new function after the line format.name$, i.e.  FUNCTION {format.names} ... format.name$
highlight.if.cv.author
remove.dots
...


Run bibtex as normal and your name should be highlighted in any way you want.

• Works great, thanks! (although bold fonts seem to be ignored when using \textsc or \sc, but that might be related to something else I do in my bst) – Anthony Labarre Apr 15 '13 at 11:40
• Many fonts don't have bold small caps glyphs, so I guess that's why you can't combine the two styles. – Supernormal Jun 23 '14 at 13:17
• For those preparing a moderncv using IEEE bst files and don't use biblatex tis the way to go, and very EZ. I don't understand how it did but it even automatically accounts for LaTeX accents, for example if your name appears as Ötiker and Otiker differently in a number of documents within your bib fıle, if you just enter define cv.author as Otiker it finds them all! (note that it cannot find the UTF-8 Ötiker, you still have to use {\"O}tiker for tis to work). Brilliant solution! – nonKreon Dec 25 '19 at 19:13

user2087764's multiauthor case needs to be updated, combining with Lawrence Crosby and Werner's correction:

\usepackage{xstring}
\usepackage{etoolbox}
\newboolean{bold}
\newcommand{\makeauthorsbold}[1]{%
\DeclareNameFormat{author}{%
\setboolean{bold}{false}%
\renewcommand{\do}[1]{\expandafter\ifstrequal\expandafter{\namepartfamily}{####1}{\setboolean{bold}{true}}{}}%
\docsvlist{#1}%
\ifthenelse{\value{listcount}=1}
{%
}{\ifnumless{\value{listcount}}{\value{liststop}}
}
\ifthenelse{\value{listcount}<\value{liststop}}
}
}

\makeauthorsbold{Smith,Doe}

• Like cgogolin's answer this suggestion does not take prefixes and suffixes into account. It also drops "et al." handling and hard-codes things that are otherwise customisable. Furthermore the last \ifthenelse misses the <false> branch and produces a weird error in newer biblatex versions (similar in structure to github.com/plk/biblatex/issues/874). tex.stackexchange.com/q/73136/35864 has alternatives that keep underlying biblatex macros alive. – moewe Mar 19 '19 at 16:10

It is possible to do this without introducing any special commands and just changing how the name is entered in the bibtex file.

You can simply use ... and {\bf first name} {\bf last name} in the author list in the bibtex file or ... and {\bf last name}, {\bf first name}.

You mentioned errors occurring during sorting. I suspect this is because you did {\bf first name last name}, in which case it treats this as if it's just your last name. In my experience (at least using natbib) I don't see any errors.

If you do have error in sorting, then use \noopsort: at the very beginning of your bibtex file, put

@PREAMBLE{"\providecommand{\noopsort}[1]{}"}


then do something like this in the author name:

author =     {{\noopsort{Hofstad}}{\bf van der Hofstad}, {\bf R.}}


This would cause the name to be alphabetized by "Hofstad" and then put the name in bold

I have to use \noopsort often because many Dutch authors write in my field, and by Dutch convention, "van der Hofstad" is alphabetized with "H". See for example https://www.nas.ewi.tudelft.nl/people/Piet/Eigennamen.html (note - there are exceptions to this rule, particularly if the name is actually Belgian)

• In case you are using alpha-style or similar you may need to enclose the first letter a separe bold to theuse it show correly as {\bf L}{\bf astname}, {\bf Firstname.} and Name, Second – Mikael Fremling Dec 12 '17 at 13:48
• Great! It seems to work with \bf and not with \textbf. – Karlo Nov 27 '20 at 16:04

Iterating on the great answer by cgogolin, here is a macro to put in bold multiple authors. I solved the caveat of "Do" ending bold if "Doe" is in the author list by using the package etoolbox that allows to loop over items in a comma separated list.

\usepackage{xstring}
\usepackage{etoolbox}
\newboolean{bold}
\newcommand{\makeauthorsbold}[1]{%
\DeclareNameFormat{author}{%
\setboolean{bold}{false}%
\renewcommand{\do}[1]{\ifstrequal{##1}{####1}{\setboolean{bold}{true}}{}}%
\docsvlist{#1}%
\ifnumequal{\value{listcount}}{1}%
{\ifnumequal{\value{liststop}}{1}%Single author
%first author
%last author
{\ifnumless{\value{listcount}}{\value{liststop}}
%middle author
}%
}%
}
\makeauthorsbold{Smith,Doe}

• Like cgogolin's answer this suggestion does not take prefixes and suffixes into account. It also drops "et al." handling and hard-codes things that are otherwise customisable. Furthermore this code still uses the pre-3.3 name format and can not be used with modern biblatex versions (cf. tex.stackexchange.com/q/299036/35864). tex.stackexchange.com/q/73136/35864 has alternatives that keep underlying biblatex macros alive. – moewe Mar 19 '19 at 16:11

For reference, another approach to doing this is with Bibulous in place of BibTeX or Biblatex, and is worth noting because the implementation is straightforward. In order make a given author bold, all that is needed is to apply a "substring replace" operator into the author list variable. For example, to replace the author "J. W. Tukey" with its bold version "\textbf{J. W. Tukey}" we can change the <au> variable in the Bibulous templates. Thus, in the "SPECIAL TEMPLATES" section of the *.bst file, we can change the <au> and <ed> variable definitions from their defaults of

au = <authorlist.format_authorlist()>
ed = <editorlist.format_editorlist()>


to their new forms of

au_orig = <authorlist.format_authorlist()>
au = <au_orig.replace(J. W. Tukey,\textbf{J. W. Tukey})>
ed_orig = <editorlist.format_editorlist()>
ed = <ed_orig.replace(J. W. Tukey,\textbf{J. W. Tukey})>


Note that this approach closely follows that of the answer posted here, where the OP aims to underline an author name rather than use boldface.

• But this needs to be done for every type of bibliography entry as opposed to only once for the biblatex solution. So it is not really straightforward, and will be fragile if additional kinds of entries are used in the future. – cfr Apr 1 '15 at 23:51
• @cfr: The above change is to the style template and not to any database entries, and so it only needs the one change shown to make the author's name in bold everywhere it occurs in the output reference list. – nzh Apr 2 '15 at 15:07
• Yes, the example shown above is specific to article-type entries. And, although this is easy to copy into all of the entrytype templates, it will make them hard to read. So that's a good point. An alternative is to override the default definition of the au variable, so that the same applies to all entry types. For example, in the SPECIAL-TEMPLATES section of the template file, one can define au_orig = <authorname.0>, ..., <authorname.9> and then <au> = <au_orig.replace(J. W. Tukey,\textbf{J. W. Tukey})>. This applies the change to every instance of <au> in every entrytype template. – nzh Apr 3 '15 at 17:52
• (+1) But I think that information would be more useful in your answer ;). – cfr Apr 3 '15 at 18:24
• Good idea! I've changed the answer to reflect your suggestion. – nzh Sep 4 '15 at 15:09

You can try a simple search and replace it as \textbf{A. Name} in your BibTeX file as below I have to bold the first author named Prateek Raj Gautam

in BibTeX entry, it is written as Gautam, Prateek Raj or some times as P. R. Gautam

and in the final output it is shown as P. R. Gautam so take this name and enclose it in \textbf{} as\textbf{P. R. Gautam}

original BibTeX entry

@article{Gautam2019,
author = {P. R. Gautam and Kumar, Sunil and Verma, Akshay and Rashid, Tarique and Kumar, Arvind},
doi = {10.1109/TII.2019.2908437},
journal = {IEEE Transactions on Industrial Informatics},
number = {11},
pages = {5827--5836},
publisher = {IEEE},
title = {Energy-Efficient Localization of Sensor Nodes in WSNs Using Beacons From Rotating},
volume = {15},
year = {2019}
}


edited BibTeX entry

@article{Gautam2019,
author = {\textbf{P. R. Gautam} and Kumar, Sunil and Verma, Akshay and Rashid, Tarique and Kumar, Arvind},
doi = {10.1109/TII.2019.2908437},
journal = {IEEE Transactions on Industrial Informatics},
number = {11},
pages = {5827--5836},
publisher = {IEEE},
title = {Energy-Efficient Localization of Sensor Nodes in WSNs Using Beacons From Rotating},
volume = {15},
year = {2019}
}


for me, it works like charm no fuzz with bst file or complex macro needed