Managing Bibliographies with LATEX Lapo F
Total Page:16
File Type:pdf, Size:1020Kb
36 TUGboat, Volume 30 (2009), No. 1 Multiple citations can be added by separating Bibliographies with a comma the bibliographic keys inside the same \cite command; for example \cite{Goossens1995,Kopka1995} Managing bibliographies with LATEX Lapo F. Mori gives Abstract (Goossens et al., 1995; Kopka and Daly, 1995) The bibliography is a fundamental part of most scien- Bibliographic entries that are not cited in the tific publications. This article presents and analyzes text can be added to the bibliography with the the main tools that LATEX offers to create, manage, \nocite{key} command. The \nocite{*} com- and customize both the references in the text and mand adds all entries to the bibliography. the list of references at the end of the document. 2.2 Automatic creation with BibTEX A 1 Introduction BibTEX is a separate program from LTEX that allows creating a bibliography from an external database Bibliographic references are an important, sometimes (.bib file). These databases can be conveniently fundamental, part of academic documents. In the shared by different LATEX documents. BibTEX, which past, preparation of a bibliography was difficult and will be described in the following paragraphs, has tedious mainly because the entries were numbered many advantages over the thebibliography envi- and ordered by hand. LATEX, which was developed ronment; in particular, automatic formatting and with this kind of document in mind, provides many ordering of the bibliographic entries. tools to automatically manage the bibliography and make the authors’ work easier. How to create a 2.2.1 How BibTEX works A bibliography with LTEX is described in section2, BibTEX requires: starting from the basics and arriving at advanced 1. one or more bibliographic databases .bib; customization. Bibliographic styles for both the list of references and in-text-citations are analyzed in 2. a bibliographic style .bst; section3. The last two sections (4 and5) analyze 3. that the .tex file contains: commands that spec- two of the most powerful packages available: natbib ify what style .bst and database .bib to use, and BibLATEX. and citations in the text with the \cite and similar commands, as in: 2 Bibliography with LATEX \documentclass{...} ... There are two main ways to compose a bibliography \begin{document} with LATEX: automatically with the BibTEX pro- See \citet{Kopka1995}. gram that uses external bibliographic databases (sec- .. \bibliographystyle{plainnat} tion 2.2), or manually with the thebibliography en- \bibliography{database} vironment that allows to include all the bibliographic \end{document} information in the source .tex file (section 2.3). Re- gardless from the strategy chosen, citations can be 4. that the document is compiled in the following added to the text with the same commands, as shown order (let’s assume that the principal file is called in section 2.1. document.tex): latex document 2.1 References in the text bibtex document latex document Citations can be added to the text with the com- latex document mand \cite{key} (and its variants), where key cor- responds to the citekey field in the .bib file (if using The first time LATEX runs, the \bibliographystyle BibTEX, section 2.2) or the key of \bibitem (if us- command writes the name of the style .bst to be ing the thebibliography environment, section 2.3). used into the .aux file, each \cite command writes When compiling the source, \cite{key} is linked a note into the .aux file, and the \bibliography to the respective \bibitem and substituted by the command writes into the .aux file the name of the appropriate reference (numbered, author-year, or .bib database(s) to be used. At this stage LATEX footnote depending on the style chosen). does not substitute the \cite in the text: the .dvi Lapo F. Mori TUGboat, Volume 30 (2009), No. 1 37 tex sty bib bst 2.2.3 Rules for using BibTEX The syntax of BibTEX entries is very intuitive. The log LATEX2ε aux BibTEX blg following paragraphs will discuss the most common rules, all the details can be found in Patashnik(1998). bbl Capital letters. The BibTEX styles control cap- pdf dvi ital and lower case letters, especially for the titles. This behavior is very convenient because it ensures a A Figure 1: Data flow between LTEX and BibTEX to uniform format for the entries but could cause prob- create a .pdf or a .dvi ( ) from the data files .tex ■ lems in some specific situations such as acronyms, and .bib ( ) and the style files .sty and .bst ( ). ■ ■ chemical formulæ, etc. In these cases the user needs to enclose in braces the letters whose capitalizations shows question marks for every \cite and the .log should not be changed by BibTEX, as in the following file reports warnings for unknown references. example for “CO”: BibT X will then read the .aux file, the bibli- E title = {{CO} pollution}, ographic style .bst and .bib database(s) specified. For every \cite entry, it will read the information The .bst style can be used to automatically contained in the .bib files and format it according change the capitalization behavior for titles (e.g. title to the style .bst. At the end it will order the en- style or sentence style) instead of manually enclosing tries according to the style .bst and will write the all the titles in braces. result into the .bbl file. The .bbl contains the bib- Commands. Since T X modifies the capital- liographic entries organized in a thebibliography Bib E A environment; the entries follow the format specified ization depending on the .bst style, some LTEX commands inside titles may not work. For example, by the .bst style and have the information contained if the sentence style is in use and one of the titles in the .bib database. This file will be read every contains the command , this will be converted time that the source .tex file is compiled. \LaTeX to \latex and will give the following error: When running LATEX again, it will produce a warning due to the fact that the references are not de- ! Undefined control sequence. fined yet and will substitute the \bibliography com- mand with the content of the .bbl file. It will also This also can be avoided by enclosing such commands write a note into the .aux file for every \bibitem. in braces: {\LaTeX}. At the next run, LATEX will find the definition Accents and special characters. A similar prob- for every \cite in the .aux file and all the citations lem arises with the commands for accents and spe- in the text will be resolved. The .blg file is a log cial characters such as “ö” (\"{o}), “ç” (\c{c}), “ñ” file created by BibTEX, similar to the .log file for (\~{n}), etc. Again, enclosing the command in LATEX. braces solves the issue: This flow, represented in Fig.1, has to be re- peated if the citations in the text, the .bib database title = {Writing the curriculum vit{\ae}}, or the .bst style are modified. Name lists. When more than one name is present 2.2.2 Structure of a bibliography database in the author or editor fields, they have to be sep- The .bib files are databases that store the informa- arated by ␣and␣ (a space before and after): tion for each bibliographic entry. Here is an example: author = {Author1 and Author2}, @BOOK{Kopka1995, title = {A Guide to {\LaTeX} -- Document Each name has four parts: Name, von, Surname, Preparation for Beginners and Advanced Users Jr. The surname is mandatory, all other parts are }, optional. BibT X accepts two different syntaxes for publisher = {Addison-Wesley}, E year = {1995}, names: author = {H. Kopka and P. W. Daly}, • Name von Surname: for example “Pico della } Mirandola” has to be written as Each type of entry (BOOK, ARTICLE, PROCEEDINGS, Pico della Mirandola. etc.) offers many fields in addition to those shown • von Surname, Jr, Name: for example “Pico in the example (title, publisher, year, author). della Mirandola II” has to be written as Further details can be found in Patashnik(1998). della Mirandola, II, Pico. Managing bibliographies with LATEX 38 TUGboat, Volume 30 (2009), No. 1 The second form is more general because the first 2.2.4 Creating and managing bibliography one cannot be used when the Jr field is present or databases when the surname contains more than one word and As should be clear from the example in section 2.2, the von part is not present. The .bst style takes the .bib file syntax is so intuitive that these files care of abbreviating (or not) names. If the author can be easily written with any text editor. Several wants to use abbreviated names, the .bib database programs, however, are dedicated to the creation can also have abbreviated names. For example: and management of .bib databases, such as Bib- author = {Mori, L. F.}, TeXMng3 (shareware for Windows), BibDesk4 (open- source for Mac OS X), KBibTeX5 (open-source for If the list of authors or editors is too long, it can Linux), Pybliographer6(open-source for Linux), bib- be ended by and others that will then be formatted liographer7 (freeware for Linux), Bibwiki8 (Internet by the style as “et al.” based), cb2Bib9 (freeware for Windows and Linux), author = {Conte, G. B. and Pianezzolla, E. and Zotero10 (open-source multi-platform plugin for Fire- Chiesa, P. and Rossi, G. and others}, fox), and JabRef11 (multi-platform open-source). The last three programs are particularly interesting and URL. The standard BibTEX styles do not provide will be discussed in the next paragraphs. a field for web addresses. A solution with these styles is to use the howpublished field: cb2Bib. cb2bib (which stands for “clipboard to @MISC{..., BibTEX”) is a program for extracting bibliographic ..., information from unformatted sources such as .pdf howpublished = {\url{http://...}}, files, web sites, and email.