[pmwiki-users] Citation keys and BibTeX compatibility (Was: bibliographies rev...)

christian.ridderstrom at gmail.com christian.ridderstrom at gmail.com
Sun Oct 1 08:17:59 CDT 2006


On Wed, 27 Sep 2006, John Rankin wrote:

> I'm hoping that an author will be able to write (using this markup for 
> illustration and making no promises)
> 
> [[Cite:Hawking et al. (2006)]] 
> 
> and it will be able to deduce the ref-id page name from that, 
> where the page name might be Bibliography.HawkingOthers-2006.

As we are getting in to actually citing a key, I'll use this post to start 
a thread discussing the format of citation keys v.s. compatibility with 
BibTeX.

If we wish to maintain compatibility with BibTeX, allowing .bib-files to 
be imported as well as to be exported, we need to check what characters 
are valid for a citation key. This is probably documented in some LaTeX 
manual, although I know that that characters such as '+', '-' and ':' are 
allowed, where ':' is commonly used. In fact, the majority of my citation 
keys are in the format

        <First author> ':' <year> ':' <Three letters from title>

If we wish to keep compatibility with the BibTeX format we should consider 
this question carefully. I've spent a surprisingly large amount of time 
trying to figure out exactly what characters are allowed: BibTeX seems to 
allow a *lot* of (ASCII?) characters.

To be honest, I doubt we will be able to allow all characters that LaTeX 
and/or BibTeX consider valid for a citation key. We should however think 
it through, and try to allow the most commonly used characters.

>From the source of Emacs' BibTeX mode,
        http://www.netlib.org/bibnet/tools/emacs/bibtex.el

I think it uses the following regexp for a citation key:

        "[A-Za-z][]A-Za-z0-9.:;?!`'()/*@_+=-]*"

which allows quite a few characters... However, some bibliographic
software imposes restrictions. For instance, from the manual of BibDesk:

        http://bibdesk.sourceforge.net/manual/BibDesk%20Help_2.html

I find it is stricter and prohibits "@" or "'" in the citation key.

Some characters such as ':' are commonly used and should be allowed, or 
alternatively handled in some way that still allows compatibility with 
BibTeX. With compatibility I mean that a .bib-file can be imported to a 
wiki system, modified on the wiki and then exported as a valid .bib-file 
without a change to citations keys.

Emacs' BibTeX mode uses this regexp:

        "[A-Za-z][]A-Za-z0-9.:;?!`'()/*@_+=-]*"

We can probably disallow "'" and "@" as BibDesk do, but we are still left 
with quite a few characters.

Turning the problem around, what characters could we allow?

* Which characters are valid in a URI?

* Which characters are valid in a page name?

* Which characters are valid in an anchor tag?

* Which characters are allowed in something like "&cite-key=..."?

I suspect that the latter allows most flexibility when it comes to valid 
characters.

/Christian

-- 
Christian Ridderström, +46-8-768 39 44               http://www.md.kth.se/~chr


More information about the pmwiki-users mailing list