Bibliographies
Citing from .bib files with BibTeX's styles, natbib and biblatex, with no separate BibTeX step.
mLaTeX reads .bib files itself. There is no BibTeX or Biber to run and no .bbl to keep up to date: cite, name the file, and compile once.
With BibTeX's commands
\documentclass{article}
\begin{document}
Literate programming~\cite{knuth84} changed how programs are written.
\bibliographystyle{plain}
\bibliography{refs}
\end{document}@article{knuth84,
author = {Donald E. Knuth},
title = {Literate Programming},
journal = {The Computer Journal},
year = {1984},
volume = {27},
pages = {97--111}
}\cite
\cite{key} cites an entry by its key and prints its label. \cite{a,b} cites several at once, and \cite[p.~5]{knuth84} adds a note after the label.
\nocite
\nocite{key} lists an entry in the bibliography without citing it in the text; \nocite{*} lists every entry in the file.
\bibliographystyle and \bibliography
\bibliographystyle{style} chooses the style, and \bibliography{refs} names the .bib file, without its extension, and sets the bibliography where it stands. Entries are chosen, sorted, labelled and set in the style named.
Styles
| Style | Cites as | Sorted |
|---|---|---|
plain, abbrv | [1] | By author |
unsrt, ieeetr, IEEEtran | [1] | In the order cited |
alpha | [Knu84] | By author |
plainnat, abbrvnat, apalike, agsm, chicago | Knuth (1984) with natbib | By author |
ACM, splncs, siam, elsarticle, ams | Each publisher's own way | As the style does |
apsrev, the AIP's styles | [1], initials first | In the order cited |
A style mLaTeX does not know is set as plain.
natbib
natbib cites by author and year:
\usepackage{natbib}
\citet{knuth84} showed it \citep{lamport94}. % Knuth (1984) showed it (Lamport, 1994).
\citep[see][p.~5]{knuth84} % (see Knuth, 1984, p. 5)
\bibliographystyle{plainnat}
\bibliography{refs}Citations in the text and in parentheses
| Command | Prints |
|---|---|
\citet{key} | Knuth (1984) |
\citep{key} | (Knuth, 1984) |
\citealt{key} | Knuth 1984 |
\citealp{key} | Knuth, 1984 |
\citeauthor{key} | Knuth |
\citeyear{key} | 1984 |
\citenum{key} | The entry's number |
The capitalised forms \Citet, \Citep and \Citeauthor are read too, and \citeyearpar prints the year in parentheses.
Notes
\citep[p.~5]{key} adds a note after, and \citep[see][p.~5]{key} one before and one after.
Numbers
The numbers option, \usepackage[numbers]{natbib}, cites every entry by number instead.
biblatex
\usepackage[style=authoryear]{biblatex}
\addbibresource{refs.bib}
\begin{document}
\textcite{knuth84} and \parencite{lamport94}.
\printbibliography
\end{document}\addbibresource
\addbibresource{refs.bib} in the preamble names a .bib file, with its extension. It can be given more than once.
Citations
\textcite{key}cites in the text, as natbib's\citet.\parencite{key},\autocite{key}and\smartcite{key}cite in parentheses, as\citep.\supercite{key}cites by the entry's number.\footcite{key}cites in a footnote.\Textcite,\Parenciteand\Autociteare read too.
Styles
The style option chooses the style, and each is set as the BibTeX style nearest it:
| biblatex style | Set as |
|---|---|
authoryear, apa, chicago, harvard, authortitle | Author and year |
ieee | IEEE's style |
alphabetic | [Knu84] labels |
nature, science, the physics styles, or sorting=none | Numbered in the order cited |
| any other | Numbered, sorted by author |
\printbibliography
\printbibliography sets the bibliography where it stands. It reads heading=none, heading=bibintoc and title=. A report's or a book's bibliography is a chapter, as those classes have it.
Where the entries come from
A .bib file
A .bib file beside the document, in a folder given with -I, or handed in by a program.
Imported with \input
\input{refs.bib} makes a .bib file a source of the bibliography, as \addbibresource does, and \bibliography{} or \printbibliography then sets what it holds.
Carried in the document
A filecontents block holding the entries is kept for the run, so the document is a single file.
A ready-made .bbl
A paper sent to a journal or the arXiv often carries the .bbl file BibTeX wrote instead of its .bib. When none of the files \bibliography names can be read, the document's own .bbl is set in its place.
Written by hand
A thebibliography block with \bibitem entries works as in LaTeX, natbib's \bibitem[Knuth(1984)]{knuth} included.
What the .bib reader understands
@string abbreviations, # concatenation, month names, @comment, and @preamble, whose text is placed ahead of the list so that commands the entries use are defined.
Looking a bibliography over
Give a .bib file as the document to set every entry it holds, cited or not, as a list:
mlatex refs.bibMistakes
A citation with no entry
A citation with no entry is a warning, Citation `key' undefined, and prints ?.
A file that cannot be read
A .bib file that cannot be read is an error that names it. See Troubleshooting.
Related packages
- References and Notes: every package, with its commands and an example.