6

I am using the standard article class and bib style unsrt with LaTeX and BibTeX. I would like to customize individual biblabels in my list of references, for instance starring certain items as follows:

[1] A. Uthor ...

*[2] B. Uthor ...

[3] C. Uthor ...

where the labels should be right-aligned so that the starred ones stand out. Thanks to this forum, I know how to customize all the labels with:

\makeatletter

\renewcommand\@biblabel[1]{\mbox{$\star \left[ \right.$}#1\mbox{$\left. \right]$}}

\makeatother

but how can I customize only specific ones? A solution based on BibTeX tags would be prefered, but others will be considered.

4

It mostly depends on how you decide what entries must be starred. I assume that you can decide via a substring of the key.

\begin{filecontents*}{\jobname.bib}
@article{gander2001,
 author={Gladstone Gander},
 title={How to be lucky},
 journal={Nature},
 pages={1-33},
 volume={42},
 year={2001},
}
@article{ducks2002,
 author={Donald Duck and Fethry Duck},
 title={How to be unlucky},
 journal={Nature},
 pages={34-44},
 volume={43},
 year={2002},
}
@book{scrooge1901,
 author={Scrooge McDuck},
 title={My first golden nugget in {Klondike}},
 publisher={Yukon Press},
 address={Whitehorse},
 year={1901},
}
@book{scrooge1990,
 author={Scrooge McDuck},
 title={How to manage zillion of dollars},
 publisher={McDuck Press},
 address={Duckburg},
 year={1990},
}
\end{filecontents*}

\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentCommand{\setspeciallist}{ m }
 {
  \seq_gset_split:Nnn \g_mmakster_special_list_seq { , } { #1 }
 }

\cs_set_eq:Nc \mmakster_original_bibitem:n { @bibitem }

\seq_new:N \g_mmakster_special_list_seq
\bool_new:N \l_mmakster_star_bool
\cs_set_protected:cpn { @bibitem } #1
 {
  \bool_set_false:N \l_mmakster_star_bool
  \seq_map_inline:Nn \g_mmakster_special_list_seq
   {
    \tl_if_in:nnT { #1 } { ##1 } 
     { \bool_set_true:N \l_mmakster_star_bool \seq_map_break: }
   }
  \mmakster_original_bibitem:n { #1 }
 }
\cs_set_protected:cpn { @biblabel } #1
 {
  \bool_if:NT \l_mmakster_star_bool { \leavevmode\llap{*} }[#1]
 }
\ExplSyntaxOff

\setspeciallist{gander,duck}

\begin{document}
\nocite{*}

\bibliographystyle{unsrt}
\bibliography{\jobname}

\end{document}

With this the two entries "Gander" and "Duck and Duck" have a key that has one of the strings in \setspeciallist as substring, so they will be starred.

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.