![]() ![]() ![]() ![]() |
BibTool Manual![]() ![]() |
The key generation facility provides a mean to uniformly replace the reference keys by generated values. Some algorithms are hardwired, namely the generation of short keys or long keys either unconditionally or only when they are needed. Additionally a free formatting facility is provided. This can be used to specify your own algorithm to generate keys. The generation of new keys can be enabled using the command line option -f in the following way:
bibtool -f format
This command adds format disjunctively to the formatting instructions already given. The same effect can be achieved with the resource key.format.
key.format = {format}
Some values of format have a special meaning. Fixed formatting rules are used when one of them is in effect. The special values are described below. To illustrate their results we consider the following BibTeX database entries:
@Unpublished{unpublished-key, author = "First A. U. Thor and Seco N. D. Author and Third A. Uthor and others", title = "This is a rather long title of an unpublished entry which exceeds one line", ... } @Article{, author = {L[eslie] A. Aamport}, title = {The Gnats and Gnus Document Preparation System}, ... } @BOOK{whole-collection, editor = "David J. Lipcoll and D. H. Lawrie and A. H. Sameh", title = "High Speed Computer and Algorithm Organization", ... } @MISC{misc-minimal, key = "Missilany", note = "This is a minimal MISC entry" }
key
is present then its value is
used. Otherwise if an author or editor field are present, then this field
is used. The short version uses last names only. Afterwards a title or
booktitle field is appended, after the fmt.name.title separator has
been inserted. Finally if all else fails then the default key
default.key is used. The result is disambiguated (cf. key.base).
To see the effect we apply BibTool to the example entries given earlier
with the command line argument -- key.format=short
. This results in
the following keys (remaining lines skipped):
@Unpublished{ thor.author.ea:this, @Article{ aamport:gnats, @Book{ lipcoll.lawrie.ea:high, @Misc{ missilany,
If BibTool is applied to the example entries given earlier with the
command line argument -- key.format=long
we get the following keys:
@Unpublished{ thor.fau.author.snd.ea:this, @Article{ aamport.la:gnats, @Book{ lipcoll.dj.lawrie.dh.ea:high, @Misc{ missilany,
If BibTool is applied to the example entries given earlier with the
command line argument -- key.format=short.need
we get the following
keys:
@Unpublished{ unpublished-key, @Article{ aamport:gnats, @Book{ whole-collection, @Misc{ misc-minimal,
If BibTool is applied to the example entries given earlier with the
command line argument -- key.format=short.need
we get the following
keys:
@Unpublished{ unpublished-key, @Article{ aamport.la:gnats, @Book{ whole-collection, @Misc{ misc-minimal,
If BibTool is applied to the example entries given earlier with the
command line argument -- key.format=empty
we get the following
keys:
@Unpublished{ , @Article{ , @Book{ , @Misc{ ,
In contrast to the command line option, the resource instruction only modifies the formatting specification. The key generation has to be activated explicitly. This can be done using the command line option -F as in
bibtool -F
Alternatively the boolean resource key.generation can be used in a resource file:
key.generation = on
Usually all keys are regenerated. This can have the unpleasant side-effect to
invalidate citations in old documents. For this situation the resource
preserve.keys is meant. This resource is usually off
. If it is
turned on
then only those entries receive new keys if they do not have
a key already. This means that the input contains only a sequence of
whitespace characters (which is not accepted by BibTeX) as in the following
example:
@Article{,
author = {L[eslie] A. Aamport},
title = {The Gnats and Gnus Document Preparation System},
journal = {\mbox{G-Animal's} Journal},
year = 1986,
volume = 41,
number = 7,
pages = "73+",
month = jul,
note = "This is a full ARTICLE entry",
}
Even if preserve.keys is on
, BibTool still changes all keys to
lower case by default. This can be suppressed by switching
preserve.key.case to on
(see section Parsing and Pretty Printing).
When the key.format is not empty then the keys are disambiguated by appending letters or numbers. Thus there can not occur a conflict which would arise when two entries have the same key. The disambiguation uses the resource key.number.separator. If a key is found (during the generation) which is already been used then the valid characters from the value of this resource is appended. Additionally a number is added. The appearance of the number can be controlled with the resource key.base. This resource can take the values upper, lower, and digit. The effect can be seen in the following table:
generated key | digit | lower | upper |
key | key | key | key |
key | key*1 | key*a | key*A |
key | key*2 | key*b | key*B |
key | key*3 | key*c | key*C |
key | key*4 | key*d | key*D |
As we have seen there are options to adapt the behavior of formatting. Before we explain the free formating specification in section Format Specification we will present the formatting options. Those options can be activated from a resource file or with the corresponding feature to specify resource instructions on the command line.
off
.
off
.
**key*
.
*
.
off
.
:
.
:
.
and
) when formatting names.
The default value is .
.
-
.
.
.
and others
parts
of a name list.
The default value is .ea
.
The key style short can be formulated in terms of the format specification given in section Format Specification as follows:
{
{ %-2n(author)
# %-2n(editor)
}
{ %s($fmt.name.title) %-1T(title)
# %s($fmt.name.title) %-1T(booktitle)
#
}
}
#
{ { %s($fmt.name.title) %-1T(title)
# %s($fmt.name.title) %-1T(booktitle)
}
}
# %s($default.key)
The syntax and meaning of such format specifications is explained in section
Format Specification.
![]() ![]() ![]() ![]() |
BibTool Manual![]() ![]() |