2

I would like to embolden certain author names in a BibTeX reference section. The list of highlighted authors should be controlled from the .tex source file.

This solution shows how to do this for a single author, whose name is defined in the \myname macro.

This solution shows how to do this for multiple authors, but the list of highlighted authors is contained in the .bib file.

1

You did not show us a MWE or a bib file, so I can only guess.

As I understand you, you wants the Lastname of one or more Authors be highlighted, for example printed bold. The Names should be defined in the tex code and you use program BibTeX to create the bibliography.

Because you gave no style I used plain.

With a little searching here you can find the answer of @egreg to this question similar to that what you want.

I did only small changes. The command to list the authors to be highlighted is

\highlightauthors{Studenta, Studentb, Studentc, Goossens, Mittelbach, Adams}

In line

  \regex_replace_all:NnN \g_hl_students_regex { \c{textbf}\cB\{ \1 \cE\} } \l_hl_data_tl
 %                                                 ^^^^^^

you can change bold printing (textbf) to emph or textsc or whatever you need.

So with the complete code

\RequirePackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@article{a,
  author={Studenta A. and Foo B.},
  title={Title},
  journal={Journal},
  year={2012},
}
@article{b,
  author={Studentb A. and Studentc B.},
  title={Title},
  journal={Journal},
  year={2012},
}
@article{c,
  author={Foo B. and Baz  B.},
  title={Title},
  journal={Journal},
  year={2012},
}
@Book{Goossens,
  author    = {Goossens, Michel and Mittelbach, Frank and
               Samarin, Alexander},
  title     = {The LaTeX Companion},
  edition   = {1},
  publisher = {Addison-Wesley},
  location  = {Reading, Mass.},
  year      = {1994},
}
@Book{adams,
  title     = {The Restaurant at the End of the Universe},
  author    = {Douglas Adams},
  series    = {The Hitchhiker's Guide to the Galaxy},
  publisher = {Pan Macmillan},
  year      = {1980},
}
\end{filecontents*}


\documentclass{article}

\usepackage{xparse,l3regex}
\ExplSyntaxOn
\regex_new:N \g_hl_students_regex
\seq_new:N \l_hl_students_seq
\tl_new:N \l_hl_data_tl
\NewDocumentCommand{\highlightauthors}{m}
 {
  \seq_set_split:Nnn \l_hl_students_seq { , } { #1 }
  \regex_gset:Nx \g_hl_students_regex
   { ( \seq_use:Nnnn \l_hl_students_seq { | } { | } { | } ) }
 }
\cs_generate_variant:Nn \regex_gset:Nn { Nx }

\cs_set_eq:NN \hl_bibitem:w \bibitem
\cs_set:Npn \bibitem #1#2\par
 {
  \hl_bibitem:w { #1 }
  \tl_set:Nn \l_hl_data_tl { #2 }
  \regex_replace_all:NnN \g_hl_students_regex { \c{textbf}\cB\{ \1 \cE\} } \l_hl_data_tl
  \tl_use:N \l_hl_data_tl \par
 }
\ExplSyntaxOff

\highlightauthors{Studenta, Studentb, Studentc, Goossens, Mittelbach, Adams}

\begin{document}
abc \cite{a} \cite{adams}
\nocite{*} 

\bibliographystyle{plain}
\bibliography{\jobname}
\end{document}

you will get the following result:

enter image description here

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.