BibTex is system (tools and file format) for managing references
in LaTeX documents. Forget about formatting your bibliography (is
it “publisher (year)” or “publisher: year”?), just add entries for the
works you're referencing, and drop in a \cite{key}
. I also use my
entrez script to pull nicely detailed citations off PubMed and
its related databases. Once you've added the citation to your
database the first citation, you can reuse that data in any future
paper just by reusing your BibTeX database. It's wonderful.
Basic usage
At some point in your LaTeX document:
\bibliographystyle{prsty} % Phys. Rev. style
other syles include abbrv
, alpha
, plain
, unsrt
, ...
In your LaTeX document where you want the bibliography:
\bibliography{wtk} % wtk.bib is the name of the database
compile (using latex
for example) with:
$ latex example
$ bibtex example
$ latex example
$ latex example
Formatting names
There are many possible author name formats, but the least ambiguous
is von Last, Jr., First Middle
. If the von
is capitalized
(e.g. "Emanuela Di Cola"), use \uppercase
:
@String{EDCola = "{\uppercase{d}}i Cola, Emanuela"}
See Tame the BeaST for details.
Natbib
I don't actually use LaTeX's \cite{key}
command as I claimed above.
That works, but the Natbib package adds support for other citation
styles & link formats. I actually use \citep{key}
(parenthetical
citations), \citet{key}
(textual citations), and other more
specialized Natbib commands. That way I don't have to worry about
misspelling author names or remembering “et al.” when I cite a source
in the text.
Makebst
Customize bibliography with Makebst (latex makebst
, from
custom-bib), makes .bst
(bib-style) format files according to
your specifications.
Cross-references (more like sub-references)
Don't repeat yourself! BibTeX lets you piggyback low level
references (@inbook
, @inproceedings
) underneath higher level
references (@book
, @proceedings
) without duplicationg information
from the parent entry (via crossref
). However, this can be a bit
tricky.
Like a number of TeX tools, BibTeX tries to accomplish as much as possible with a single pass through your data. This makes things more memory efficient (if you really can't spare that extra MB ;), but it also makes for some odd errors. While working on my thesis, I ran into:
$ bibtex root
…
Database file #9: root.bib
Warning--string name "nist:esh" is undefined
--line 1175 of file root.bib
A bad cross reference---entry "NIST:gumbel"
…
The problem is due to the @inbook
entries occuring after the @book
they reference:
@book{ NIST:ESH,
…
}
@inbook{ NIST:gumbel,
crossref = {NIST:ESH},
…
}
When it's reading your bibliography, BibTeX hits the @book
entry
(NIST:ESH
), and says to itself, “Hmm, it doesn't look like anyone's
referencing NIST:ESH
. I'll save some memory by forgetting I've seen
it.” Then when BibTeX hits the @inbook
entry (NIST:gumbel
), it
says, “Ahh, this references NIST:ESH
. I'd better keep an eye out
for that.” Unfortunately, this is too late, because it's already past
that entry. BibTeX hits the end of the database without finding a
(second) NIST:ESH
definition, and complains about the missing
reference.
The solution is just to order your @inbooks
(and other crossref
consumers) so they occur before the entry they reference:
@inbook{ NIST:gumbel,
crossref = {NIST:ESH},
…
}
@book{ NIST:ESH,
…
}
Embarassingly, this information is spelled out on Wikipedia's BibTeX page:
The referred entry must stand below the referring one.
That's the kind of thing you'll only remember after you've been bitten
by it ;). Hopefully putting the bad cross reference
error message
in the surrounding text will help the rest of you searching for
solutions.
It looks like Matěj Cepl (who has also contributed to rss2email) ran into the same issue back in 2000. It's a small world ;).
References
There are a number of good resources to get you going:
- very basic tutorial
- really awesome explanation of how BibTeX works: Tame the BeaST
- process overview
- entry types reference
- fields reference
- entry and fields reference, but with little discussion
- examples of assorted styles
- assorted tools
- Nelson Beebe's list of bibliographies
- Nelson Beebe's GNU bibliography