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.

For several documents I'm preparing, I need to highlight (or underline) occurences of my name within the bibliography.

Is there an easy way of doing this?

share|improve this question
add comment

3 Answers

It depends on how you prepare the bibliography. If you are preparing it with BibTeX, you can use a trick I mentioned earlier today, which requires you change the .bib files; this definition should go in the .tex file

\newcommand{\myname}[1]{\textit{Wurm, Y.}}

and an entry in the .bib file will have

author={{\myname{wurm}} and Zauthor, X.}

However this depends also on how you want the names displayed in the bibliography.

If you don't want to act on the bib files, a different approach might work:

\usepackage{xstring}

\let\originalbibitem\bibitem
\def\bibitem#1#2\par{%
  \noexpandarg
  \originalbibitem{#1}
  \StrSubstitute{#2}{Wurm}{\textit{Wurm}}\par}

This exploits the fact that BibTeX separates each \bibitem entry with empty lines. A different redefinition of \bibitem must be done if you use the abbrv bibstyle instead of plain.

For biblatex the situation is more involved; I got something with

\usepackage{xstring}
\noexpandarg\exploregroups
\makeatletter
\let\orig@blx@bbl@entry\blx@bbl@entry
\def\blx@bbl@entry#1\endentry{%
  \StrSubstitute{#1}{Wurm}{\textit{Wurm}}[\Result]%
  \expandafter\orig@blx@bbl@entry\Result\endentry}
\makeatother

for the standard style; but I don't know if there are side effects. Probably acting as Alan Munn suggested in a comment is best.

share|improve this answer
    
thanks for the quick reply greg. However, I was hoping to be able to only change something in my .tex file. Messing with .bib file (which may require having multiple copies) is something I would like to avoid... –  Yannick Wurm May 20 '11 at 11:30
    
@Yannick: see the edit –  egreg May 20 '11 at 11:58
    
Is there a biber/biblatex solution? –  Raphael May 20 '11 at 12:07
6  
The accepted answer to this question: Pass variable from LaTeX to bibtex (for easy anonymization)? gives you another way take on the multiple bibfile: you make your name a variable in the bib file and then alias it to a command. So you don't really have multiple bib files, just one line for the special formatting, and the other for not. –  Alan Munn May 20 '11 at 12:42
    
Thanks for all the replies. Problem with having a different bib file with different formatting is that the formatting will be applied in the main text as well, not only in the bibliography. (I want my name to be highlighted only in the list of references)... –  Yannick Wurm May 21 '11 at 13:39
show 1 more comment

If you are using biblatex you can override the formatting of the list of authors:

\usepackage[normalem]{ulem} %for \uline

\DeclareNameFormat{author}{%
\ifthenelse{\equal{#1}{YourLastName}}%
    {\uline{\ifblank{#4}{}{#4\space}#1}}%
    {\ifblank{#4}{}{#4\space}#1}%
\ifthenelse{\value{listcount}<\value{liststop}}%
    {\addcomma\space}
    {}}

This of course means you have to reproduce formatting of the backend you are using but it allows you to e.g. underline your initials and last name together[1]. The example above is fairly basic (for example it doesn't care about inserting "et al." or "and" as required by some guidelines).

[1] I might be wrong here (I couldn't make the attached example to work) but it seems to me that egreg's solution works at .bbl file level, where initials, first and last names are still kept separately.


(edit)

Below is a redefined default name formatting macro (based on definition of a name:first-last macro from a biblatex.def file). I'm sorry for my poor coding style. If someone could show me how to properly restructure this macro (to avoid repetition) that would be great.

\usepackage[normalem]{ulem} %for \uline

\renewbibmacro*{name:first-last}[4]{%
  \usebibmacro{name:delim}{#2#3#1}%
  \usebibmacro{name:hook}{#2#3#1}%
  \ifthenelse{\equal{#1}{YourLastName}}% matches last name against YourLastName
    {
      \uline{% wrapped with \uline
      \ifblank{#2}{}{\mkbibnamefirst{#2}\isdot\bibnamedelimd}%
      \ifblank{#3}{}{%
        \mkbibnameprefix{#3}\isdot%
        \ifpunctmark{'}%
          {}%
          {\ifuseprefix{\bibnamedelimc}{\bibnamedelimd}}}%
      \mkbibnamelast{#1}\isdot%
      \ifblank{#4}{}{\bibnamedelimd\mkbibnameaffix{#4}\isdot}}}%
    {% original
      \ifblank{#2}{}{\mkbibnamefirst{#2}\isdot\bibnamedelimd}%
      \ifblank{#3}{}{%
        \mkbibnameprefix{#3}\isdot%
        \ifpunctmark{'}%
          {}%
          {\ifuseprefix{\bibnamedelimc}{\bibnamedelimd}}}%
      \mkbibnamelast{#1}\isdot%
      \ifblank{#4}{}{\bibnamedelimd\mkbibnameaffix{#4}\isdot}}}
share|improve this answer
add comment

I am using Mendeley to manage my references. It can output a bibtex file but LaTeX has problems with lines that are too long (abstracts). I use a simple shell script to strip abstracts in a new .bib file, and following egreg's advice, included the {\myname{wurm}} change to the .bib file. I am also using the bibliography style ieeetr and my name is underlined as expected.

For me, the shell script contains:

sed "/^abstract/d" library.bib | sed "s|Hurvitz, P. M.|{\\\myname{hurvitz}}|" > library_noabstract.bib

and in my .tex file:

\usepackage[normalem]{ulem}
\newcommand{\myname}[1]{\uline{P. M. Hurvitz}}
share|improve this answer
    
Welcome to TeX.sx! –  Peter Jansson Mar 13 '13 at 15:46
add comment

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.