1

This is a variation of the question posted here:

Now I want to highlight multiple names in a bibliography. Here is the erroneous solution that I tried.

\documentclass[11pt,letter]{article} 
\usepackage[usenames,dvipsnames]{xcolor}  
\usepackage{xstring} 
\let\originalbibitem\bibitem  
\def\bibitem#1#2\par{  
\noexpandarg 
\originalbibitem{#1} 
\StrSubstitute{#2}{Author1}{{\color{blue}\textbf{Author1}}}[\x]
\expandafter\StrSubstitute\expandafter{\x}{Author2}{{\color{blue}\textbf{Author2‌​}}}{\x}
\par}

\begin{document} 
\cite{CiteKey1,CiteKey2,CiteKey3,CiteKey4} 
\bibliographystyle{IEEEtran} 
\bibliography{library} 
\end{document} 

The problem is that for each reference it makes two copies. In the first copy, it makes blue and bold Author1 and Author2, and in the second copy, it makes blue and bold Author1 only.

Any ideas on how to fix this so that the reference only has a single name being made blue and bold? Also whatever solution you propose should be made extensible to up to N authors.

Thanks!

  • 1
    Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. Cutting and pasting your code in to a standard document gives me the expected behaviour, not that you report. – Andrew Swann Apr 19 '14 at 14:48
  • This is a standard minimal example that shows what I'm after. You will find that the reference list (using BibTeX) is totally not correct. – Amro Apr 19 '14 at 17:10
  • I get output that looks like: Author3, Author1BlueBold, and Author2BlueBold, “My Title” in My Conference. Author3, Author1BlueBold, and Author2PLAIN, “My Title” in My Conference. – Amro Apr 19 '14 at 17:13
  • Here Author1BlueBold means the name of Author1 appears in Blue and Bold. – Amro Apr 19 '14 at 17:16
  • You should add your code to your original question, via the edit button, rather than to the comments. Also include the relevant part of your bibliography file. – Andrew Swann Apr 20 '14 at 14:45
1

You have a coding error in your macros. The second \StrSubstitute should not have your \x temporary macro at the end - a final argument to \StrSubstitute should be in square brackets [..] to assign the output to \x, but at this stage you no longer need to save its output.

Sample output

\documentclass{article}

\usepackage{xcolor}
\usepackage{xstring}
\let\originalbibitem\bibitem
\def\bibitem#1#2\par{%
\noexpandarg \originalbibitem{#1}
\StrSubstitute{#2}{Lipcoll}{{\color{blue}\textbf{Lipcoll}}}[\mytmpa]
\expandafter\StrSubstitute\expandafter{\mytmpa}{Sameh}{{\color{blue}\textbf{Sameh}}} \par}

\begin{document}

\nocite{*}
\bibliographystyle{IEEEtran}
\bibliography{xampl}

\end{document}

The above uses a bibliography file found in standard distributions (in the documentation for bibtex) with a couple of different author names chosen to show the effect. Note that the dashes used for repeated authors partly defeats what you are trying to achieve.

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.