wtorek, 26 marca 2013

LaTeX: how to highlight some bibliography entries by adding an asterisk before the entry?

Author-year citation style is assumed.

If a bibliography is prepared manually it is as easy as to precede each entry with say \bibAst command. Example:

\newcommand\bibAst{\leavevmode\hbox to0pt{\hss$^\ast$}}

\harvarditem[Bagozzi and Dholakia]{Bagozzi and
Dholakia}{2006}{bagozzidholakia06}
\bibAst\textsc{Bagozzi, R.~P., {\small and} U.~M. Dholakia} (2006): ``Open
Source Software User Communities: A Study Of Participation In {L}inux {U}ser
{G}roups,'' \emph{Management Science}, 52(7), 1099--1115.

If one insists on using BiBTeX one has to mark records which are to be highlighted. It can be done with an extra field (named highlight in the example below):


@Article{bagozzidholakia06,
title = "Open Source Software User Communities: A Study Of
Participation In {L}inux {U}ser {G}roups",
author = "Bagozzi, Richard P. and Dholakia, Utpal M.",
journal = j-msci,
pages = "1099--1115",
number = "7",
volume = "52",
year = "2006",
highlight = "Y"
}

Fields unknown to BiBTeX's particular style are omitted, so highlight cause no harm when processed with standard BiBTeX style.

One need to modify BiBTeX style now. This is a two-step procedure. First one has to add highlight to the body of ENTRY function:


ENTRY
{
...
highlight
}

Next one has to modify format.authors function. Exact form of a format.authors function is style-dependent. In case of apalike the code looks like:


%FUNCTION {format.authors}
%{ author empty$
% { "" }
% { author format.names }
% if$
%}
% change to:
FUNCTION {format.authors}
{ author empty$
{ "" }
{ highlight empty$
{ author format.names }
{ "{\bibAst}" author format.names * }
if$
}
if$
}

BTW: the meaning of some BiBTeX expressions are as follows: S1 S2 * denotes S1 S2 strings concatenation; L F1 F2 if$ denotes logical if (execute F1 if L is true otherwise execute F2).

The contents of highlight is irrelevant. Sole existence of highlight denotes that the record is highlighted.

NOTE: the style should be more elaborate if some BiBTeX entries starts with something other than authors names.

Brak komentarzy:

Prześlij komentarz