Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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:


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.

share|improve this question
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
You might also want to consider using amsrefs and this simple (though requiring some manual work) solution: mbork.pl/2009-04-14_List_of_publications_of_a_person_%28en%29 –  mbork Mar 11 '12 at 22:04

4 Answers 4

up vote 25 down vote accepted

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 :=


{ "\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\myname{Elmar Zander}%

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$
    { preamble$ write$ newline$ }
  "\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:

share|improve this answer
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

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$ * "}}" * }
  3. Create a function that highlights your name

    FUNCTION {highlight.if.cv.author}
    { duplicate$ purify$ cv.author purify$ =
        { highlight }
  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}

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

share|improve this answer
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

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

      {\expandafter\ifstrequal\tempname{Name}{\textbf{#1\addcomma\addspace #4\addcomma\isdot}}{#1\addcomma\addspace #4\addcomma\isdot}}
      {\expandafter\ifstrequal\tempname{Name}{\textbf{#1\addcomma\addspace #4}}{#1\addcomma\addspace #4}}}
      {\expandafter\ifstrequal\tempname{Name}{\textbf{\addcomma\addspace #1\addcomma\addspace #4}}{\addcomma\addspace #1\addcomma\addspace #4}}
      {\expandafter\ifstrequal\tempname{Name}{\textbf{\addcomma\addspace #1\addcomma\addspace #4\addcomma\isdot}}{\addcomma\addspace #1\addcomma\addspace #4\addcomma\isdot}}%

Just change Name to the Surname of the Author whose entries you want to be bold face. It is not difficult to adopt the code to situations where multiple authors have the same surname but only one of them should be highlighted.


In the comment below it was suggested to wrap this into a command. Yes, it can be done as follows:

      {\expandafter\ifstrequal\tempname{##1}{\textbf{##1\addcomma\addspace ##4\addcomma\isdot}}{##1\addcomma\addspace ##4\addcomma\isdot}}
      {\expandafter\ifstrequal\tempname{##1}{\textbf{##1\addcomma\addspace ##4}}{##1\addcomma\addspace ##4}}}
      {\expandafter\ifstrequal\tempname{##1}{\textbf{\addcomma\addspace ##1\addcomma\addspace ##4}}{\addcomma\addspace ##1\addcomma\addspace ##4}}
      {\expandafter\ifstrequal\tempname{##1}{\textbf{\addcomma\addspace ##1\addcomma\addspace ##4\addcomma\isdot}}{\addcomma\addspace ##1\addcomma\addspace ##4\addcomma\isdot}}%
share|improve this answer
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

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 template to <au.replace(J. W. Tukey,\textbf{J. W. Tukey})>. Thus, a complete template for articles would go from, say,

article = <au>, \enquote{<title.replace(Sunset,\color{red}Sunset\color{black})>,}{ }...
          <journal.replace(American,\textit{American})> \textbf{<volume>} (<year>).

to the new form

article = <au.replace(J. W. Tukey,\textbf{J. W. Tukey})>,{ }...
          \enquote{<title.replace(Sunset,\color{red}Sunset\color{black})>,}{ }...
          <journal.replace(American,\textit{American})> \textbf{<volume>} (<year>).

The change shown here is only applied to "article" type entries, and so similar changes to the other entrytype templates ("book", "inproceedings", etc.) would also be needed, in each case replacing <au> with <au.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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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