One of the nice features of writing a paper in LaTeX is BibTeX, which formats your bibliography automatically for you, enables you to change the format without much effort, and automatically makes sure your in-text citations are consistent with your bibliography. However, for this to work well, you need to make sure you enter your bibliography data consistently so that BibTeX then formats your entries consistently.
I will assume here that you've already followed my article on how to set up a LaTeX paper repository.
In your sources.bib
file in your paper repository, a typical bib entry looks something like this:
@inproceedings{vandePaper08,
author = {Alice {van de Paper} and Bob Authorson and Carrie Writerman},
title = {A paper on writing papers},
year = {2008},
booktitle = {Advances in Good Paper Writing Processes}}
Every bib entry will have this general form:
@_____
entry type {
____ = {____}
separated by commas}
There are many types of entry aside from @inproceedings
(see below), but the
format of the bib entry will look like this regardless. In particular, here are
some rules to follow that apply for all types of bibliography entry:
{...}
. title = {On Bayesian inference}
, BibTeX may decide that it should be typeset as "On bayesian inference," which is not correct because Bayesian is a proper noun and needs to be capitalized. Therefore, you should include braces to force the format: title = {On {B}ayesian inference}
.Alice C{\^o}t{\'e}
will typeset as Alice CôtéFirstname Lastname
, separated by "and," no commas. Do not use Lastname, Firstname formatting; I have found this to be more error prone in the past, especially with complicated names. For lastnames with spaces, use braces, for example Firstname {Lastname III}
.title = {On {B}ayesian procedures for inferring a {D}irichlet mixture of betas}
title = {Probability Theory: Examples and Counterexamples}
Since you included the natbib
package after reading how to set up a LaTeX repo, you have two
major options for citing references in your text: \citet
(no parentheses) or \citep
(parentheses). Use \citet
when the citation is part of your sentence. For example, \citet{Authorson18} showed that X is true
will typeset
as something like
Authorson & Writerman (2018) showed that X is true.
When the citation is not part of the sentence, use \citep
. For example,
It is possible to show that X is true \citep{Authorson18}
will typeset as
It is possible to show that X is true (Authorson & Writerman, 2018).
Three things to look out for when using citations:
Books: When citing a book, never cite the entire book; always cite a particular chapter, theorem, page range etc. You can
do this with optional arguments to \citep
, e.g., paper writing skills \citep[Ch.~3]{Authorson18}
will typeset as
paper writing skills (Ch.~3, Authorson & Writerman, 2018)
Citation spacing: Make sure to include a space before each \citep
or \citet
command. This makes sure citations are spaced properly.
For example, paper writing skills\citep{Authorson18}
will typeset as
paper writing skills(Authorson & Writerman, 2018)
while paper writing skills \citep{Authorson18}
will be properly spaced:
paper writing skills (Authorson & Writerman, 2018)
Numbered citations: If your bibliography format is numbers—and citations appear in your text like [4]—then \citep
should be used. BibTeX will complain if you use \citet
.
In order to make sure your paper and bibliography are compiled properly, you will need to run the following five commands:
pdflatex main.tex
pdflatex main.tex
bibtex main
pdflatex main.tex
pdflatex main.tex
If your sources.bib
file has errors, you will see them here after the bibtex main
call. Note that warnings should
be treated as errors; a warning is simply something that BibTeX can ignore and move past.
But it usually means that your PDF file will have incorrectly formatted / broken citations.
For example, the below "warning" implies that you tried to use \citep{ghahramani06}
in the main
text of your paper, but there is no bib entry with the ghahramani06
tag. In your paper, you will see
a "??" where your citation should be.
This is BibTeX, Version 0.99d (TeX Live 2017/Debian)
The top-level auxiliary file: main.aux
A level-1 auxiliary file: superposition_algorithm.aux
The style file: unsrtnat.bst
Database file #1: sources.bib
Warning--I didn't find a database entry for "ghahramani06"
(There was 1 warning)
Note: some fancy LaTeX editors have a button to compile your document. Unfortunately, many of them do not
report BibTeX warnings. Feel free to use this when you're working, but before you send a draft to your advisor,
you should compile your document on the command line to catch and fix all the errors/warnings from pdflatex
and bibtex
.
For conference papers, use the @inproceedings
entry type.
@inproceedings{vandePaper08,
author = {Alice {van de Paper} and Bob Authorson and Carrie Writerman},
title = {A paper on writing papers},
year = {2008},
booktitle = {Advances in Good Paper Writing Processes}}
For a standard journal article, use the @article
type.
Notes:
number
--
in page ranges@article{vandePaper09,
author = {Alice {van de Paper} and Bob Authorson},
title = {A really long paper on writing papers},
year = {2009},
volume = {10},
number = {3},
pages = {1234--5678},
journal = {The Annals of Paper Writing}}
It is becoming increasingly common to cite unpublished arXiv articles. For these,
I use the @article
entry type, filling out only author
/title
/year
and using the journal
for a brief formatted link to the arXiv identifier. A lot of people would put something like
arXiv e-print arXiv:0901.23456
, but I don't like how much redundancy there is there; arXiv
only hosts one type of media (articles), so there's no reason to be verbose about it.
@article{vandePaper09b,
author = {Alice {van de Paper} and Bob Authorson},
title = {A really long paper on writing papers},
year = {2009},
journal = {arXiv:0901.23456}}
Also note that sometimes when you first write your manuscript, a paper is only on arXiv; but then later on down the road it gets published. Before submitting your final version of your work to a conference or journal, search google for any arXiv citations to see if they've been published. Cite only the published version.
For books, use the @book
entry type. Note: when citing a book, never cite the entire thing. In your LaTeX code, you should always provide the optional argument to specify page ranges, chapters, a theorem number, etc. For example, you should never do \citep{vandePaper10}
, but instead be more specific: \citep[Ch.~3]{vandePaper10}
, or \citep[p.~773--779]{vandePaper10}
.
@book{vandePaper10,
author = {Alice {van de Paper}},
title = {Writing Lots of Papers: A Book About It},
year = {2009},
edition = {$2^\text{nd}$},
publisher = {Paper Writing Press}}
If it's a chapter in a collection, use the @incollection
type. Since the citation won't be for an entire book, you don't necessarily need to include optional information in the \cite
command.
@incollection{vandePaper10,
author = {Alice {van de Paper}},
title = {A Chapter on Writing Papers},
editor = {Bob Authorson and Carrie Writerman},
booktitle = {The Handbook of Paper Writing},
publisher = {Paper Writing Press},
year = {2009},
pages = {266--290},
chapter = {10}}
For other things not listed above—which represent about 99% of cases I run into regularly—I consult google and see what other people have used. For example, this site provides a nice list of types that you might run into, e.g.,
@phdthesis
: for Ph.D. theses@techreport
: for technical reports@misc
: for online resources, lecture notes, etcHere is a checklist to go through before your paper draft is ready to show your advisor.
Make sure you check both your sources.bib
file and your rendered PDF paper for errors.
Sometimes it's easier to spot an error in one or the other.
title = {On {B}ayesian stuff for reasons}
.title = {{B}ayesian Statistics in the Real World}
{___}
braces, e.g. the {B}ayesian
above)journal = {The Annals of Papers and Whatnot}
Firstname Lastname
format separated by and
and no commas