![]() ![]() ![]() ![]() |
BibTool Manual![]() ![]() ![]() |
To end this section we should have a look at a complete example of key generation specification. For this purpose we define a rule according to which the keys should be generated:
The disambiguation should be done by appending upper case letters without a preceding string. If everything else fails three question marks should be inserted as key.
To implement this scheme we write the following specification into a
resource file:
key.expand.macros = on
key.base = upper
key.number.separator = {}
key.format =
{
%s(bibkey)
#
%0w(@book)
{ %-2.4n(author): # %-2.4n(editor): # }
{ %4d(year) # }
#
%0w(@article)
{ %-2.4n(author): # }
{ %-.1W(journal). # }
{ %4d(year) # }
#
%0w(@proceedings)
{ %-2.4n(editor): # }
{ %-.1W(title). # %-.1W(booktitle). # }
{ %4d(year) # }
#
%0w(@inproceedings)
{ %-2.4n(author): # }
{ %-.1W(booktitle). # }
{ %4d(year) # }
#
%3s($type)-
{ %-2.4n(author):
# %-6.1W(title).
}
{%4d(year) # }
#
%3s($type)-
%4d(year)
# ???
}
Since each part has been explained before we just need some overall remarks.
I prefer to use the backtracking-based disjunctions instead of nested
if-then-else constructs because they save some braces. They can be read as a
switch statement, or even better as a cond statement in Lisp. This
means they describe cases. The first successful case terminates the evaluation
of the whole cascade.
The constructions like %0w(@book)
are use to distinguish the different
types. This construction does not produce any output. It just succeeds or
fails depending on the type of the current entry. The %0w
could also
be replaced by other specifiers which serve the same purpose.
The constructions like {%4d(year) # }
always succeed. The hash sign
(#
) catches the failure and inserts the second alternative---which
happens to be empty---if the requested field does not exist.
![]() ![]() ![]() ![]() |
BibTool Manual![]() ![]() ![]() |