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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am writing my CV in LaTeX. I am using biblatex and want my name (and only my name) to be bold for every reference. Is there a magic way to do this?

A similar question Make one author's name bold every time it shows up in the bibliography was asked, but that answer used BibTeX. While I use the BibTeX backend, I use biblatex.

Any suggestions?

share|improve this question
4  
See: tex.stackexchange.com/questions/44200/… -- Of course this only one suggestion. You can also use DeclareSourcemap-- see for example here: tex.stackexchange.com/questions/62779/… – Marco Daniel Sep 19 '12 at 5:09
    
For my own CV, I use \mkbibbold. So the author field looks like this: author={A. Lastname, \mkbibbold{Your name}, A. Lastname} You should use biber though. – rowman Sep 19 '12 at 19:10
up vote 39 down vote accepted

You can patch the name:last, name:first-last and name:last-first macros defined in biblatex.def. These are used by all of the default name formatting directives and take four arguments:

{<last name>}{<first name>}{<name prefix>}{<name affix>}

or

{<last name>}{<first name (initials)>}{<name prefix>}{<name affix>}

In the following we match only on the first and last name parts.

\documentclass{article}
\usepackage{biblatex}
\usepackage{xpatch}% or use http://tex.stackexchange.com/a/40705

\newbibmacro*{name:bold}[2]{%
  \def\do##1{\ifstrequal{#1, #2}{##1}{\bfseries\listbreak}{}}%
  \dolistloop{\boldnames}}
\newcommand*{\boldnames}{}

\xpretobibmacro{name:last}{\begingroup\usebibmacro{name:bold}{#1}{#2}}{}{}
\xpretobibmacro{name:first-last}{\begingroup\usebibmacro{name:bold}{#1}{#2}}{}{}
\xpretobibmacro{name:last-first}{\begingroup\usebibmacro{name:bold}{#1}{#2}}{}{}
\xpretobibmacro{name:delim}{\begingroup\normalfont}{}{}

\xapptobibmacro{name:last}{\endgroup}{}{}
\xapptobibmacro{name:first-last}{\endgroup}{}{}
\xapptobibmacro{name:last-first}{\endgroup}{}{}
\xapptobibmacro{name:delim}{\endgroup}{}{}

% just for demonstration
\ExecuteBibliographyOptions{maxnames=99,firstinits}
\DeclareNameAlias{default}{last-first/first-last}

\addbibresource{biblatex-examples.bib}
\forcsvlist{\listadd\boldnames}
  {{Herrmann, Wolfgang~A.}, {Herrmann, W.~A.}, {Herrmann, Wolfgang\bibnamedelima A.},
   {Herrmann, W\bibinitperiod\bibinitdelim A\bibinitperiod}}

\setlength{\parindent}{0pt}
\setlength{\parskip}{\baselineskip}
\begin{document}
\fullcite{herrmann}

\forcsvlist{\listadd\boldnames}
  {{{\"O}fele, Karl}, {{\"O}fele, K.}, {{\"O}fele, K\bibinitperiod}}
\fullcite{herrmann}

\renewcommand*{\boldnames}{}
\forcsvlist{\listadd\boldnames}
  {{Hoffmann, Stephan~D.}, {Hoffmann, S.~D.}, {Hoffmann, Stephan\bibnamedelima D.},
   {Hoffmann, S\bibinitperiod\bibinitdelim D\bibinitperiod}}
\fullcite{herrmann}
\end{document}

enter image description here

Note that the name parts in the \boldnames etoolbox internal list should follow the format of the bbl file, which is backend-dependent. The example here covers both biber and BibTeX. With biber you can also perform matching using the hash field:

\iffieldequalstr{hash}{<hash string>}

where <hash string> can also be found in the bbl file.

If your name is consistently formatted in the bib file an alternative approach is to normalize name punctuation before matching. This example allows you to specify your name in BibTeX's format regardless of the backend.

\documentclass{article}
\usepackage{biblatex}
\usepackage{xpatch}% or use http://tex.stackexchange.com/a/40705

\def\makenamesetup{%
  \def\bibnamedelima{~}%
  \def\bibnamedelimb{ }%
  \def\bibnamedelimc{ }%
  \def\bibnamedelimd{ }%
  \def\bibnamedelimi{ }%
  \def\bibinitperiod{.}%
  \def\bibinitdelim{~}%
  \def\bibinithyphendelim{.-}}    
\newcommand*{\makename}[3]{\begingroup\makenamesetup\xdef#1{#2, #3}\endgroup}

\newbibmacro*{name:bold}[2]{%
  \makename{\currname}{#1}{#2}%
  \makename{\findname}{\lastname}{\firstname}%
  \makename{\findinit}{\lastname}{\firstinit}%
  \ifboolexpr{ test {\ifdefequal{\currname}{\findname}}
            or test {\ifdefequal{\currname}{\findinit}} }{\bfseries}{}}

\newcommand*{\boldname}[3]{%
  \def\lastname{#1}%
  \def\firstname{#2}%
  \def\firstinit{#3}}
\boldname{}{}{}

\xpretobibmacro{name:last}{\begingroup\usebibmacro{name:bold}{#1}{#2}}{}{}
\xpretobibmacro{name:first-last}{\begingroup\usebibmacro{name:bold}{#1}{#2}}{}{}
\xpretobibmacro{name:last-first}{\begingroup\usebibmacro{name:bold}{#1}{#2}}{}{}
\xpretobibmacro{name:delim}{\begingroup\normalfont}{}{}

\xapptobibmacro{name:last}{\endgroup}{}{}
\xapptobibmacro{name:first-last}{\endgroup}{}{}
\xapptobibmacro{name:last-first}{\endgroup}{}{}
\xapptobibmacro{name:delim}{\endgroup}{}{}

% just for demonstration
\ExecuteBibliographyOptions{maxnames=99,firstinits}
\DeclareNameAlias{default}{last-first/first-last}

\addbibresource{biblatex-examples.bib}
\boldname{Herrmann}{Wolfgang~A.}{W.~A.}

\setlength{\parindent}{0pt}
\setlength{\parskip}{\baselineskip}
\begin{document}
\fullcite{herrmann}

\boldname{{\"O}fele}{Karl}{K.}
\fullcite{herrmann}

\boldname{Hoffmann}{Stephan~D.}{S.~D.}
\fullcite{herrmann}
\end{document}

enter image description here

share|improve this answer
    
So this answer looks good (I haven't tried it yet, but I will). But now I have changed to using the biber backend. Will this make it easier? – Jeremy Sep 19 '12 at 21:39
    
@Jeremy Not really. You can do pattern matching with biber via \DeclareSourceMap, but it's the processed data that really matters - initials, location in the name list, etc. Biber also creates a hash string to identify each name, but its value isn't very meaningful. – Audrey Sep 20 '12 at 13:52
    
I'm sorry but this totally confuses me, possibly related to the fact that it just doesn't work for me. :( In your example you say that I can do the search via the hash string, but it's not clear where and how. Then in this last comment you state that it's not very meaningful. What do you mean by that? Just that it's abstract, but your suggestion should still be safe? – K.-Michael Aye Nov 24 '12 at 4:34
2  
@K.-MichaelAye Yes, it provides a quick method for identifying a name but the identifier carries no meaning to us. In the above example \newbibmacro*{name:bold}[2]{\iffieldequalstr{hash}{aa1a2c66bf52b23789b077a79ac3‌​‌​4863}{\bfseries}{}} would bold the first author's name. I pulled this hash string from the bbl file. – Audrey Nov 25 '12 at 22:30
1  
@K.-MichaelAye With hash field matching all you need are the patches - prefix the name:* macros with \begingroup\iffieldequalstr{hash}{aa1a2c66bf52b23789b077a79ac3‌​‌​4863}{\bfseri‌​es}{} and append with \endgroup. – Audrey Nov 26 '12 at 3:04

With biblatex 3.4/biber 2.5 (both current in DEV), there is a general "annotation" functionality to do things like this, for example:

\documentclass{article}
\usepackage{biblatex}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@MISC{test,
  AUTHOR    = {Last1, First1 and Last2, First2 and Last3, First3},
  AUTHOR+an = {2=highlight},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\nocite{*}

\renewcommand*{\mkbibnamegiven}[1]{%
  \ifitemannotation{highlight}
    {\textbf{#1}}
    {#1}}

\renewcommand*{\mkbibnamefamily}[1]{%
  \ifitemannotation{highlight}
    {\textbf{#1}}
    {#1}}

\begin{document}
\nocite{*}
\printbibliography

\end{document}

enter image description here

You can also annotate at the name part level and the top-level field level. See the biblatex PDF manual for details.

share|improve this answer
    
Interesting feature, indeed! Hope they also did something on the performance issues of biber, which recently made me to switch back to bibtex8. – Daniel Apr 18 at 15:36
1  
"They" is me ... I did indeed. I spent some time on biber performance and while biber is never going to be as fast as bibtex (partly because it does a lot more than bibtex in the biblatex use case), it currently shows, in version 2.5, 400% speed improvement in the large test cases I used for tuning compared with any previous versions. – PLK Apr 18 at 16:17
    
Oh :-) Thanks so much! – Daniel Apr 18 at 21:48

Your Answer

 
discard

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.