[[!meta title="BibTeX"]]
-[BibTeX][] is a bibliographic database format and processing tool often
-used with LaTeX.
-
-[BibTeX]: http://www.bibtex.org/
-
+[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
===========
$ 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.
-
+See [Tame the BeaST][TTB] for details.
Natbib
======
-The [Natbib][] package adds support for other citation styles & link
-formats.
+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.
[Natbib]: http://www.ctan.org/tex-archive/help/Catalogue/entries/natbib.html
-
Makebst
=======
[custom-bib][]), makes `.bst` (bib-style) format files according to
your specifications.
-[custom-bib]: http://www.ctan.org/tex-archive/help/Catalogue/entries/custom-bib.html
-
-
-Pybtex
-======
-
-[Pybtex][] is a bibtex processor written in [[Python]]. I've
-[[modified the trunk code|Pybtex]] a bit and use it to keep my
-BibTeX databases neat and tidy.
-
-[Pybtex]: http://pybtex.sourceforge.net/
-
+Cross-references (more like sub-references)
+===========================================
+
+[Don't repeat yourself][DRY]! 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][wikipedia]:
+
+> 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][MC] (who has also
+[contributed][MC-rss2email] to [[rss2email]]) ran into [the same
+issue][lyx-2000-11-07] back in 2000. It's a small world ;).
References
==========
There are a number of good resources to get you going:
* [very basic tutorial](http://cmtw.harvard.edu/Documentation/TeX/Bibtex/Example.html)
-* really awesome explaination of how BibTeX works:
- [Tame the BeaST](http://www.ctan.org/tex-archive/info/bibtex/tamethebeast/)
+* really awesome explanation of how BibTeX works: [Tame the
+ BeaST][TTB]
* [process overview](http://www.andy-roberts.net/misc/latex/latextutorial3.html)
* [entry types reference](http://newton.ex.ac.uk/tex/pack/bibtex/btxdoc/node6.html)
* [fields reference](http://newton.ex.ac.uk/tex/pack/bibtex/btxdoc/node7.html)
* Nelson Beebe's
[GNU bibliography](http://www.math.utah.edu/pub/tex/bib/gnu.html)
+[BibTeX]: http://www.bibtex.org/
+[PubMed]: http://www.ncbi.nlm.nih.gov/pubmed/
+[TTB]: http://www.ctan.org/tex-archive/info/bibtex/tamethebeast/
+[Natbib]: http://merkel.zoneo.net/Latex/natbib.php
+[custom-bib]: http://www.ctan.org/tex-archive/help/Catalogue/entries/custom-bib.html
+[DRY]: http://en.wikipedia.org/wiki/Don%27t_repeat_yourself
+[wikipedia]: https://en.wikipedia.org/wiki/BibTeX#Cross-referencing
+[MC]: http://luther.ceplovi.cz/blog/
+[MC-rss2email]: http://search.gmane.org/?query=&author=Cepl&group=gmane.mail.rss2email&sort=relevance&DEFAULTOP=and&xFILTERS=Gmail.rss2email-Acepl---A
+[lyx-2000-11-07]: http://www.mail-archive.com/lyx-users@lists.lyx.org/msg07511.html
[[!tag tags/latex]]
[[!tag tags/programming]]