Writing Finance Papers Using LaTeX PDF
Writing Finance Papers Using LaTeX PDF
appear throughout
the document and
are created using the
todonotes package (see
Richard Stanton Section 5.6).
Comments and suggestions on this document are welcome. I am grateful to Jennifer Carpenter and
Johan Walden for valuable input (even if some of it was inadvertent). I am also grateful to Tobias Oetiker
for writing the example environment, which I use liberally in this document. INCLUDES NOTES.
Haas School of Business, U.C. Berkeley, 545 Student Services Building #1900, Berkeley, CA 94720-1900, RS: I like to have this
phone: 510-642-7382, fax: 510-643-1412, e-mail: stanton@haas.berkeley.edu. on the front page to re-
duce the likelihood that
the paper will go back
to the journal complete
with all my insulting
comments about the ref-
eree.
Contents RS: Every entry in the
table of contents is a
clickable hyperlink (see
1 Introduction 3 hyperref package, Sec-
tion 5.10)
2 Installing LATEX 4
3 Entering Text 8
3.1 Spaces and line breaks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.2 Sections and subsections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.3 Emphasizing text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.4 Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.5 Figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1
7 Journal-Specific Document Formatting 30
7.1 Formatting the bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
7.2 Formatting the text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
2
1 Introduction
LATEX is a document typesetting system, based on Knuths program TEX (see Knuth, 1984), RS: By default, LATEX
sets huge margins. Cus-
which makes it relatively simple to produce papers with high-quality equations and error- tomize them easily using
the geometry package
(see Section 5.5).
free cross-references to equations, tables, and figures, and to handle creation and formatting
of bibliographies and citations.1 This document explains the basics of installing and using
LATEX to produce high-quality papers,2 and presents a number of suggestions for tools and
techniques that make me more productive when I write papers, along with instructions and
sample files for formatting your papers to match the requirements of the Journal of Finance,
Journal of Financial Economics, and Review of Financial Studies.
This document is not intended to be a comprehensive overview of LATEX. If youre starting
from scratch, one very popular reference, free to download, is the Not So Short Introduction
to LATEX 2 (Oetiker, Partl, Hyna, and Schlegl, 2011). There are also some excellent books RS: Section 6 deals
with creating citations
and bibliographies using
on LATEX. Standard references include Lamport (1994), written by the original author of BibTEX.
LATEX; Kopka and Daly (2003), a more recent, popular introductory text; and Mittelbach,
Goossens, Braams, Carlisle, and Rowley (2004), an excellent reference on both LATEX itself
and many of the additional packages that have been created since LATEX was created (the
authors of this book are some of the main developers of LATEX).3
Creation of a document using LATEX is a two-step process:
1. Create a LATEX source file, usually with the extension .tex, containing your text plus
commands that tell LATEX how to format your document.4 RS: By default, LATEX
inserts more space be-
2. Process the .tex file to create the final PDF file.5 tween list items than this
(see enumitem package,
1 Section 5.9).
Plenty of people use word processors for writing papers instead. This makes no sense to me, but rather
than engage in a debate, Ill just note that if you use Word this document is probably not going to be very
useful to you.
2
Im talking about the quality of the typesetting here. The intellectual quality is up to you.
3
I own and refer to all of these books, especially Mittelbach et al. (2004), and I originally learned LATEX
from Lamport (1994). You can also find other references at http://www.ctan.org/starter.html. However,
I find that nowadays I use Google more than any other reference.
4
For example, the source for this document is called texintro.tex. Unlike word-processor files, LATEX
files are plain text, with no special control codes. This makes them easily portable from one machine (or
architecture or OS) to another, easy to view using any plain-text file viewer, and also means that you stand
a decent chance of being able to rescue a lot of your material if the file accidentally gets corrupted, say by a
misbehaving word processor or a disk failure. Not that files get corrupted all that often, of course, but just
in case, its nice to know. This also makes it easy to keep track of your work using a Version Control System
(see Section 8).
5
Before PDF became standard, it was usual for the .tex file to be processed to a .dvi (Device Independent)
file, which was then further processed to a printable format using a printer-specific executable (e.g., dvips
for Postscript or dvilj for an HP Laserjet). To create a PDF file, you would 1) run latex to create a .dvi
file, 2) run dvips to convert the .dvi file into a Postscript file, and 3) run Adobe Distiller (or Ghostscript) to
convert the PS file to PDF. Nowadays this is usually done in one step (using the pdflatex program behind
the scenes). Yes, I know you still insist on using dvips, Johan, though I have no idea why. . . .
3
For example, here is an extremely simple LATEX file (the text after % on each line is just
a comment; it is ignored by LATEX):
If you process this file using LATEX, it produces the following PDF file:6
While simple, this document shows the structure of every LATEX source file. The part
of the document before \begin{document} is called the preamble. In this case, it contains
just the single line
More generally, this part of the file contains commands to tell LATEX how to format the
documentspacing, font size and shape, justification, etc. The second part of the document,
the document body, is everything between \begin{document} . . . \end{document}. This is
where you type the words and equations that make up your paper.
The rest of this document starts from here and tries to get you writing papers with LATEX
as quickly and efficiently as possible. Section 2 describes how to download and install LATEX.
Section 3 discusses how to enter text in your document, and Section 4 discusses how to enter
mathematical expressions. Section 5 gives an overview of some particularly useful add-on
packages, Section 6 explains how to handle citations and bibliographies in your document,
and Section 7 discusses formatting your paper for each of the three top Finance journals,
the Journal of Finance, Journal of Financial Economics, and Review of Financial Studies.
Finally, Section 8 explains why I recommend using a Version Control System like Mercurial
to manage your LATEX files (as well as your program files).
2 Installing LATEX
1
In principle, writing papers using LATEX requires three separate pieces of software:
6
Theres also a page number at the bottom of the page, which Ive omitted to save space.
4
1. A text editor to edit the .tex source file.
2. TEX/LATEX software to process your source file and create the final PDF file.
3. A PDF viewer so you can see the output.
While you can install three separate pieces of software, it is much simpler to use a LATEX
installation that comes with a front-end program, which seamlessly integrates all of these
pieces into one so you never have to think about the different steps involved.7 The standard
LATEX installations for Windows and OS X both come with a good front-end program:
OS Installation Name Front end URL
Windows MikTeX TeXworks http://miktex.org
OS X MacTeX TeXShop http://www.tug.org/mactex.
To install one of these on your system, go to the URL listed above (you can click on the
link) and follow the installation instructions.8
Creating a document with either TeXworks or TeXShop involves loading the .tex file,
editing it until youre happy with it, then pressing a button to create the PDF file, which
will also be displayed on the screen. Figure 1 shows how the TeXworks environment looks
when editing the test file from above. Figure 2 shows the same for TeXShop. In both cases:
5
6
Figure 1: Simple document with TeXworks. Shows syntax highlighting and simultaneous view of text and PDF files
RS: To insert graphics, use the \includegraphics command (see graphicx package, Section 5.3). To create a landscape figure, use the sidewaysfigure environment (see
rotating package, Section 5.11).
7
Figure 2: Simple document with TeXShop. Shows syntax highlighting and simultaneous view of text and PDF files.
3 Entering Text
3.1 Spaces and line breaks
Entering text in a LATEX document is pretty straightforwardjust type it. A couple of
things to note if youre used to a word processor (i.e., if you are between 3 and 90 years old):
i. LATEX doesnt care if you use one or several spaces or how often you insert a line break,
and ii. a completely blank line tells LATEX to start a new paragraph.
LATEX automatically adds extra space at the end of a sentence. However, it gets confused
when a word in the middle of a sentence ends with a period. In this case, you can use
\ (backslash then space) to force LATEX to insert a regular intra-sentence space. For example,
I ran into Dr. Smith, who was walking I ran into Dr. Smith, who was walking ex-
extremely rapidly. \\ tremely rapidly.
I ran into Dr.\ Smith, who was walking I ran into Dr. Smith, who was walking extremely
extremely rapidly. rapidly.
Another special space, ~, is used when we want to prevent a line break between two words,
such as between Section, Equation, etc., and the number that follows. For example,
8
1 Section Title
\section{Section Title}
\subsection{Subsection title}
1.1 Subsection title
Some very uninteresting text\ldots
Some very uninteresting text. . .
If you need them, there are also subsubsections, paragraphs, and subparagraphs:
If you want any of these not to be numbered, add an asterisk after the command name, e.g.,
\section*{An Untitled Section}.
Note that these instructions tell LATEX about the logical structure of the document (e.g.,
I want to start a new section here) but not about the formatting that goes along with it
(e.g., Format this left-justified in Times-Roman 12 point), which LATEX takes care of by
itself. This is a general feature of LATEX, which means that you spend most of your time
thinking about what youre writing rather than about how to format your paper.
3.4 Tables
3.5 Figures
\includepackage{amsmath}
9
in the preamble. This document mentions some of the additional capabilities provided by
the amsmath package, but for full details you should see the package documentation, avail-
able at http://www.tug.org/texlive/Contents/live/texmf-dist/doc/latex/amsmath/
amsldoc.pdf.
1. Inline: The expression appears as part of the paragraph if surrounded by (single) dollar
signs, $ . . . $, or (equivalently) \( . . . \). For example,
Of course, $e^{i\pi} + 1 = $
sin(x)
\( \lim_{x \rightarrow 0} Of course, ei + 1 = limx0 x 1 = 0.
\frac{\sin(x)}{x} - 1 = 0 \).
2. Display: The expression appears on a separate line, with more generous vertical spacing,
if surrounded by $$ . . . $$ or (equivalently) \[ . . . \]. For example,
A numbered equation:
\begin{equation} A numbered equation:
E = mc^2.
\label{eq:Einstein} E = mc2 . (1)
\end{equation}
10
Aligned, numbered equations:
Aligned, numbered equations:
\begin{align}
\sum_{i=1}^n i &= n
X n(n + 1)
i= ; (2)
\frac{n(n+1)}{2}; \\ 2
i=1
\sum_{i=1}^n i^2 &= n
X n(n + 1)(2n + 1)
\frac{n(n+1)(2n+1)}{6}. i2 = . (3)
6
i=1
\end{align}
dS
= m dt + s dZ.
S
To create a space between, say, the m and the dt, the obvious thing to try is to insert a
space in the text file, but this looks a lot better in the .tex source than it does in the final
document. . . :
\[
dS
\frac{dS}{S} = m dt + s dZ. = mdt + sdZ.
S
\]
LATEX completely ignores those spaces, making the right hand side very hard to interpret.
You have to tell LATEX explicitly when you want to insert some space in an equation, in this
case using the thinspace command, \,:
\[
dS
\frac{dS}{S} = m\,dt + s\,dZ. = m dt + s dZ.
S
\]
10
The \eqref command and align environment require the amsmath package (see Section 5.4).
11
4.4 Long equations
Sometimes an equation or expression is too long to fit onto a single line. The amsmath
package (see Section 5.4) provides several options to deal with this, notably the multline
and split environments. For example,
\begin{multline}
a+b+c+d+e+f+g+ \\
a + b + c + d + e + f + g+
h+i+j+k+l+m+n
\end{multline} h + i + j + k + l + m + n (4)
\begin{align}
y & = mx + c. \\
\begin{split}
y = mx + c. (5)
a & = b+c+d+e+f+g\\
a=b+c+d+e+f +g
& \quad -h+i+j+k+l (6)
\end{split} h+i+j+k+l
\end{align}
\begin{align*}
A_{\mbox{font too big}} &= 1
\mbox{ in most cases.} \\
Afont too big = 1 in most cases.
A_{\text{font OK}} &= 1
\text{ in most cases.} Afont OK = 1 in most cases.
\end{align*}
4.6 Brackets
It is often necessary to put brackets around mathematical expressions. For small expressions,
this can be done (almost) the obvious way, using ( . . . ), [ . . . ], or \{ . . . \} (but note that
you need a backslash before { or }). For example,
12
\[
(a+b)+[c+d]+\{e+f\}. (a + b) + [c + d] + {e + f }.
\]
However, this doesnt work so well if the expressions inside the brackets are taller than a
single character. For example, the following expression really needs larger brackets:
\[
e2
(\frac{a}{b})+ a c[d+ 2 ]
\{\frac{c^{[d+\frac{e^2}{2}]}}{f}\} ( )+{ }
b f
\]
LATEX has various commands for manually setting a larger bracket size, but in the vast
majority of cases you can just let LATEX set the bracket size automatically by using \left(,
\right), etc. For example,
\[
\left(\frac{a}{b}\right)+ a
h e2 i
c d+ 2
\left\{\frac{c^{\left[d+\frac{e^2}{2} +
b f
\right]}}{f}\right\}
\]
4.7 Arrays
\usepackage{graphicx}
in the preamble to your document. Near the top of this file youll find the lines
13
\usepackage{setspace,graphicx,epstopdf,amsmath,versionPO}
\usepackage{marginnote,datetime,url,enumitem,subfigure,rotating}
These lines load some packages that I find particularly useful, and include in almost every
document I write. You can find full documentation on the Web, but heres a brief description
of why each of these packages is so useful, with some brief examples illustrating their use.
Before that, however, a discussion of how to install them so LATEX knows where to find them.
From time to time, you may want to use a package that is not part of the standard LATEX
distribution. One of the packages I use on a regular basis, versionPO, falls into this category,
and so do my customized journal-specific files, jf.sty, jfe.sty, and rfs.sty. One way to
use packages like this is just to copy them into the directory containing your projects .tex
file, and they will automatically be found when you process it. However, this is not a great
solution, as you have to do it for every new project, and if you ever need to edit one of these
files, its very easy to lose track of the most recent version when you have dozens of copies
at various places on your disk.
A much better method is to install these files (once) somewhere LATEX will always know
where to find them. This does require a bit of work, but it only has to be done once. Lets
illustrate this with the versionPO package included with this document.
1. The first thing you need to decide is where to put your extra .sty file(s). You could put
them in the same directory structure as the standard packages, but dont do this!12
Instead, set up your own local directory tree. For example, on my Windows system,
I store extra packages in subdirectories under c:\RHS\texmf-local\tex\latex, and
on my Mac I use /Users/stanton/Library/texmf/tex/latex.13
11
In some cases (e.g., MikTeX) you can choose not to install all packages, but to have the package manager
install new packages for you whenever you ask to use them for the first time.
12
When you next upgrade your installation, youll have to remember to copy them elsewhere (which also
means remembering which packages they were) to avoid losing them.
13
This may seem complicated, but it follows the recommended TEX directory structure. You can pick
14
2. After creating the relevant directory, tell your LATEX installation where to find it.
MikTeX 2.09:
From the Windows program menu, select MikTeX 2.09 Maintenance (Ad-
min) Settings (Admin).
Click on the Roots tab, click Add, and select the appropriate directory
structure (in my case, this is c:\RHS\texmf-local).14
TeX Live (MacTeX):
If you chose the same directory as I did (~/Library/texmf/tex/latex, where
~ denotes your own home directory, e.g., /Users/stanton), LATEX will auto-
matically look for files there and in all subdirectories, so you dont need to
do anything else here.
Note: Both of these steps only need to be done once for a given LATEX installation. The
next steps need to be performed for every non-standard package you install.
3. Copy any new .sty files into the directory structure you just created. For example,
c:\RHS\texmf-local\tex\latex\misc\versionPO.sty.
Now run LATEX on a file that uses the package versionPO. Wait! It fails with the error
message RS: Should work OK
with the Mac; verify.
What the. . . ?! LATEX knows where you want to keep your extra files and youve put the
file right where LATEX expects to find it. This is a very frustrating error, which can cause
people to get quite annoyed with the idiot coauthor who told them to install a non-standard
package on their system (or so Ive heard. . . ). The reason for the error (which is easy to
forget even for experienced LATEX users, leading to potential frustration every time you install
a new non-standard package) is that when you run LATEX, it doesnt actually search in every
relevant directory to find all the files it needs to load; this would make it unbearably slow.
Instead, it consults a database that tells it where to find each file. Each time you install a
new file, theres therefore one additional step:
15
From the Windows program menu, select MikTeX 2.09 Maintenance (Ad-
min) Settings (Admin).
Click on Refresh FNDB (File name database).
TeXLive (MacTeX):
Run the command texhash or mktexlsr. RS: Shouldnt need to
do this if we chose the
default location.
\begin{singlespace}
This is single spaced. Once this
This is single spaced. Once this environment is
environment is finished, the document finished, the document will revert to its previous
will revert to its previous spacing. spacing.
\end{singlespace}
\begin{figure}[H]
\centering
\includegraphics%
[width=1in]{figures/MikTeX_Options}
\caption{MikTeX main options page}
\label{fig:MikOptions} Figure 3: MikTeX main options page
\end{figure}
Notes
16
Dont include the extension in the file name. The package knows about several standard
graphics types (in this example, I provided a PNG file). In particular, if you tell
it to look for file then if you process the file straight to PDF using pdfLATEX, it
will automatically look for file.pdf (pdflatex cant handle EPS files) and if youre
processing it to a DVI file (and then to a PS file) using the latex command, it will
automatically look for file.eps (latex cant handle PDF files).
If the pdflatex command cannot handle EPS files, what do you do if you dont want
to convert your source file to .dvi, but only have EPS graphic files?15 The answer is to
include the epstopdf package, which automatically converts all EPS graphics files to
PDF files on the fly when you process the source using pdflatex.
There are various options for telling LATEX where to put a figure on the page. In this
case I wanted to force LATEX to put the figure exactly where I defined it, so I used the
[H] option, defined in the float package.
5.4.1 \eqref
This puts parentheses around equation numbers for you instead of your doing it manually
with \ref. For example,16
Use this instead of eqnarray for aligning multiple equations. Compare the spacing of the
following equations:
\begin{equation}
E = mc^2. E = mc2 . (7)
\end{equation}
15
For example, Matlab is much better at generating EPS files than PDF files.
16
Yes, I realize both versions have the same number of characters, but for my two-fingered typing style
its quicker to type an extra eq than the two parentheses.
17
\begin{align}
E &= mc^2. \\
E = mc2 . (8)
A &= \pi r^2.
\end{align} A = r2 . (9)
\begin{eqnarray}
E &=& mc^2. \\
E = mc2 . (10)
A &=& \pi r^2.
\end{eqnarray} A = r2 . (11)
Note: Oetiker et al. (2011) recommend using IEEEeqnarray (part of the IEEEtrantools
package) instead of align (see Moser, 2012, for details on this environment and lots of
useful discussion of how to typeset mathematical equations). It does seem to overcome some
drawbacks of the align package, and maybe Ill try it out one day. . . . For now, heres the
same example as above:17
\begin{IEEEeqnarray}{rCl}
E &=& mc^2. \label{eq:Emc2} \\
E = mc2 . (12)
A &=& \pi r^2.
\end{IEEEeqnarray} A = r2 . (13)
Useful when an equations right-hand side can take several forms. For example,
\begin{equation}
C(S) = \begin{cases}
0 & \text{if $S \leq K$}, \\ 0 if S K,
C(S) = (14)
S - K & \text{otherwise}. S K otherwise.
\end{cases}
\end{equation}
17
One negative: IEEEtrantools is not part of the MiKTeX distribution, so youll have to install it manu-
ally. All of my coauthors already hate me for making them learn how to install non-standard packages. . . (see
Section 5.1.1). In addition, IEEEtrantools interacts badly with enumitem unless you load it with the com-
mand \usepackage[retainorgcmds]{IEEEtrantools}.
18
5.5 Setting page margins: geometry
A convenient way to set the page layout, margins, etc.18 For example, to set one-inch margins
on all sides, you simply type
\usepackage[margin=1in]{geometry}
This can all be done manually instead, but it takes a lot more work.
The command \rhs produces (by default) a green margin note with a small font and tight
interline spacing (to allow me to get more text into a cramped space), and inserts a nice
arrow pointing to the relevant point in the text.21 The note is also listed by default in the RS: Like this one, in-
serted with the com-
mand \rhs{Like this
global To Do list, if there is one. This list, which summarizes the notes in the entire paper, one, inserted with the
command \rhs{Like this
can be inserted anywhere in your text (usually at the top) with the command \listoftodos: one, inserted...
Richards To Do List
\listoftodos[Richards To Do List]
o RS: Dear author, this is gibberish. . . 19
This is useful for keeping track of large numbers of notes, but I often dont include it as it
changes the layout of the paper (and the notes are pretty easy to see in the text anyway).
18
For some reason, the default LATEX margins are huge.
19
For full details, see the package documentation at http://www.ctan.org/tex-archive/macros/latex/
contrib/todonotes/todonotes.pdf.
20
You also need to include the marginnote package if you want to generate notes in footnotes.
21
You need to run LATEX several times to get the note and arrow correctly placed.
19
You can easily modify the definition of or add additional options to the \rhs command to
create different results. For example, its easy to change the color or to make an inline note. RS: A red note, inserted
with the command
\rhs[color=red!30]{A
red note, inserted with
\rhs[inline,nolist]{Heres an inline note. I dont use these much as the command ...
the papers spacing changes when you turn them off, but theyre useful
if you have a really long note. This note does not appear in the To Do
list because I used the \texttt{nolist} option.}
RS: Heres an inline note. I dont use these much as the papers spacing changes when you turn them off, but theyre bet-
ter if you have a really long note. This note does not appear in the To Do list because I used the nolist option.
Note: By default, todo notes do not work inside footnotes or floats (figures and tables).
If you try, LATEX produces an incomprehensible error message and no note. A work-around
for this problem is to redefine the command \marginpar using the command22
\renewcommand{\marginpar}{\marginnote}
This allows notes to be created inside footnotes, but you will now find that notes on your
page overlap if you create two notes close together in the text. To prevent this, my current
work-around is not to include the command above, but instead to define a new note command
\rhsnfn, to be used only in footnotes and floats, which performs this redefinition temporarily.
This is done by the following lines at the top of this document:
20
5.8 Multiple versions from one file: versionPO
This package allows you to include text in your paper conditionally, so you can generate
multiple different versions of a document from a single source file by changing just one or
two statements.23 here are many, many uses for this package, including
Creating working papers and journal submissions from a single source file.
Optionally including responses to referees.
Adding notes to yourself that you can switch on or off at will.
Writing an exam and having the option to add extra space for students to write their
answers, or having the option to include solutions, again all in a single file.
Heres a simple example. See what happens to the output below when you change the
command \includeversion{notes} to \excludeversion{notes} at the top of the file.
Notes \ifnotes{\emph{are}}%
Notes are shown in this file.
{are \emph{not}} shown in this file.
A slightly more interesting example is the following, from the top of this file:
\ifnotes{%
\usepackage[margin=1in,paperwidth=10in,right=2.5in]{geometry}%
\usepackage[textwidth=1.4in,shadow,colorinlistoftodos]{todonotes}%
}{%
\usepackage[margin=1in]{geometry}%
\usepackage[disable]{todonotes}%
}
If the command \includeversion{notes} appears at the top of this file, then this com-
mand loads todonotes with various options, and then loads geometry with some slightly
strange paper size and margin definitions that allow both the text and the margin notes
to be printed on a standard piece of paper without changing the text layout. If the com- RS: To maximize how
much I can say, I use a
small font and the widest
mand \excludeversion{notes} appears instead, notes are disabled and standard one-inch margin notes I can get
my printer to generate.
margins are used, producing a version of the document ready for distribution. One envi-
ronment defined by default (and excluded) is comment, so you can comment out text by
23
One drawback of versionPO.sty is that its not included as part of the standard LATEX installation.
Ive therefore included it with this document, and it needs to be installed as described in Section 5.1.1.
versionPO.sty was written by Piet van Oostrum in about 1991 and originally named version.sty. I renamed
it versionPO.sty to avoid any possible conflicts with a different file, also called version.sty, that is in the
standard distribution.There are several standard packages that do similar things to this one, including
version, versions, optional, and comment. You should feel free to use one of them instead, but I am used
to using versionPO and dont like change.
21
either surrounding it with \ifcomment{...} or (useful for larger blocks) putting it inside
\begin{comment} . . . \end{comment}. This is useful for temporarily removing text that you
might want to put back later. For example,
Here are some more examples from the top of this document. Try changing their settings to
see what happens when you reprocess the document.
\setlist{noitemsep}
This removes all extra vertical space between list items, which I prefer to the default spacing
(by default, LATEX puts extra vertical space between list items). You can also use this package
to change the indentation of a list. For example,
22
\cite{Stanton:95} \\
Stanton (1995)
\url{http://www.ctan.org/} \\
http://www.ctan.org/
\href{http://www.ctan.org/}%
CTAN Web site
{CTAN Web site} \\
Equation (12)
Equation~\eqref{eq:Emc2} \\
Section 5.6
Section~\ref{sec:todo}
You can customize how (and if) these are displayed in your text (colored text, boxes, etc.).
There are also unlinked versions of some commands, e.g.,
\nolinkurl{http://www.ctan.org/} http://www.ctan.org/
If you dont want any hyperlinks in your document, you can turn them all off with the
command \hypersetup{draft=true}.24 You can try this out by changing the command
\includeversion{links} to \excludeversion{links} at the top of this document.
\begin{sidewaysfigure}
\centering
\subfigure[A somewhat familiar figure]{
\includegraphics[width=3.5in]{figures/MikTeX_Options}
\label{fig:sub1}
}
\subfigure[That was fun. Lets plot it again!]{
\includegraphics[width=3.5in]{figures/MikTeX_Options}
\label{fig:sub2}
}
\caption{This completely gratuitous figure plots the same graphic
24
An alternative is to use the url package, but it is less flexible than hyperref.
25
Note that these are placed on separate pages. This is usually what you want, as youre rotating the figure
or table because its too large to be set in portrait mode. However, there is also the sideways environment,
which allows you to have rotated text/figures on the same page as non-rotated material.
23
we saw earlier, but does so twice and in landscape mode. How exciting!
}
\label{fig:fig_subfig}
\end{sidewaysfigure}
Note that you can also refer to the whole figure or to individual subfigures in the text, e.g.,
Figure~\ref{fig:fig_subfig}. \\ Figure 4.
Figure~\ref{fig:sub2}. Figure 4(b).
9.00%
7.80%
5.00% 5.00%
3.00%
2.00%
24
25
(a) A somewhat familiar figure (b) That was fun. Lets plot it again!
Figure 4: This completely gratuitous figure plots the same graphic we saw earlier, but does so twice and in landscape mode.
How exciting!
\begin{center}
\begin{tikzpicture}[>=stealth,sloped]
\matrix (tree) [matrix of nodes, minimum size=.3cm, column sep=2.5cm,
row sep=.7cm, nodes={anchor=east}]
{
& & 9.00\% \\
& 7.80\% & \\
5.00\% & & 5.00\% \\
& 3.00\% & \\
& & 2.00\% \\
};
\draw[->] (tree-3-1) -- (tree-2-2) ;
\draw[->] (tree-3-1) -- (tree-4-2) ;
\draw[->] (tree-2-2) -- (tree-1-3) ;
\draw[->] (tree-2-2) -- (tree-3-3) ;
\draw[->] (tree-4-2) -- (tree-3-3) ;
\draw[->] (tree-4-2) -- (tree-5-3) ;
\end{tikzpicture}
\end{center}
indentfirst: Indents the first line of a new section (JF asks for this).
caption: Gives you easy control over the format of figure and table captions. Useful
for satisfying journal requirements.
xr: Allows you to refer in one document to labels in another document. Useful, for
example, for creating an Internet Appendix for the Journal of Finance where you want
to be able to refer to equation numbers in the main paper.26
amsthm: Allows good control over theorem-like environments.
booktabs: Allows good control over table layout and spacing.
longtable: Allows a single table to span more than one page, keeping the same
column headings, etc.
26
environment and one \bibitem command for each entry. E.g.,
\begin{thebibliography}{99}
\bibitem{Stanton:95} Stanton, Richard, 1995, Rational prepayment and the
value of mortgage-backed securities, {\em Review of Financial Studies\/}
8, 677--708.
\end{thebibliography}
This entry would be cited in the text using the command \cite{Stanton:95}.
This is how bibliography creation is described in Lamport (1994) and Oetiker et al.
(2011) (though the latter does mention using BibTEX), but dont do it this way! Major
drawbacks of this manual method include:
1. If you remove a citation from your text, you need to remove that paper from the
bibliography manually (after, of course, checking to make sure youre not still citing it
somewhere else).
2. To match a journals bibliography style, you have to edit every entry by hand.
3. Since theres no central database of references, you typically end up having to retype
(after re-Googling) the same citations over and over again in different papers. This is
both time-consuming and error-prone.
4. By default, LATEX produces numerical citations, whereas most finance journals want
author-year citations, e.g., Stanton (1995).
6.1 BibTEX
The solution to the problems above is to create bibliographies using BibTEX, a separate
program installed as part of any standard LATEX installation.27 Compared with the manual
method,
1. BibTEX automatically inserts only references you actually cite (or that you tell it to
insert even though you dont actually cite them, using the \nocite command). If you
delete all citations to a particular paper, it will automatically be removed from your
bibliography.
2. Reformatting a bibliography usually requires editing just a single command in your
paper (see Section 6.4.2).
27
One day, it will probably be even better to use the biblatex package instead. This has some more
features than BibTEX (for example, you can have citations appear in footnotes, and can refer to the title of
a reference within your text), and it is in principle easier to customize, but it is currently easier to generate
journal-specific bibliography formats using BibTEX with custom-bib.
27
3. You keep all references in a central database. As a result,
(a) You only need to type or look each reference up once.
(b) Theres no doubt about where to find the latest version of any reference.
(c) Once youve corrected any errors in a reference, they remain corrected forever.
4. Its easy to generate citations in any format you desire using the standard \cite
command (see Section 6.4.1).
@ARTICLE{Stanton:95,
author = {Richard Stanton},
title = {Rational Prepayment and the Value of Mortgage-Backed Securities},
journal = {Review of Financial Studies},
year = {1995},
volume = {8},
pages = {677--708},
number = {3}
}
Note that this entry contains all of the logical information about the reference (author, title,
etc.), but says nothing about formatting, which is handled separately. Once youve entered
a reference in your .bib file and told LATEX and BibTEX where to find it (see below), when
you use the \cite command, BibTEX will automatically find the right reference, add it to
your bibliography, and insert the appropriate citation in the text, e.g.,
Just like a .tex file, a .bib file is a plain-text file and can be edited with the same
editor you use to edit your .tex files. However, there are also some BibTEX-specific editors,
including JabRef (available on multiple platforms from http://jabref.sourceforge.net)
and BibDesk (OS X only, installed as part of the MacTeX distribution).
28
6.3 Telling BibTEX where to find the database
You tell BibTEX to look for references in the file master.bib by putting the following line
in your TeX file:
\bibliography{master}
Note: BibTEX will always find the file master.bib if it is in the current directory, but you
dont want to have lots of different versions of this file sitting in every different project
directory. A better approach is to set the environment variable BIBINPUTS to point to the
directory in which youve stored your Bib file, and then BibTEX will find it no matter where
you run it from.
This package provides finer control than basic LATEX over citation formatting. For example,
28
Searches in Windows almost always look in the current directory first, so this doesnt need specifying.
29
Strictly speaking, this only has an effect if youre running LATEX from a command shell. If run from
within a GUI application, this may not work. If this is a problem for you, set the environment variable
instead using the command launchctl setenv BIBINPUTS ./:~/tex/texmf-local/bibtex/bib//.
29
\cite{Stanton:95} \\
Stanton (1995)
\citep[see, for example,]%
(see, for example, Stanton, 1995, p. 3)
[p. 3]{Stanton:95} \\
Stanton (1995, Equation 1)
\citet[Equation~1]{Stanton:95} \\
Stanton 1995, Equation 1
\citealt[Equation~1]{Stanton:95} \\
Stanton, 1995, Equation 1
\citealp[Equation~1]{Stanton:95} \\
Stanton
\citeauthor{Stanton:95} \\
1995
\citeyear{Stanton:95}
By loading the extra package bibentry, you can also print the full reference. For example,
This package allows you to define a new bibliography style ( a .bst file), matching the
format of your bibliography to that of the journal you are submitting to.30 To create a new
bibliography style called, say, jf.bst for the Journal of Finance, run the command
latex makebst
and then answer various questions about the name of the output file and how you want your
bibliography formatted. It then creates a customized .bst file, jf.bst. To use the format
defined in this file, you insert the command
\bibliographystyle{jf}
in your document. This tells LATEX/BibTEX to format the bibliography using information
in the file jf.bst.
30
7.1 Formatting the bibliography
Ive used custom-bib to create bibliography styles for
These files are included with this document. Change the command \bibliographystyle{jf}
below to \bibliographystyle{jfe} or \bibliographystyle{rfs}, reprocess the docu-
ment (by running LaTeX, BibTeX, and LaTeX again), and see how the bibliography format
changes.31
Note: Youll typically find one or two minor journal bibliography conventions that
custom-bib cant quite handle.32 You now have two choices. One is to spend hours manually
editing the .bst file to do what you want. The other (which I recommend) is to wait until
the bibliography is really final, then just copy the contents of the .bbl file into the body of
the text (removing the \bibliographystyle and \bibliography commands), and edit it
manually to make these last few changes.33
1. Journal of Finance:
jf.sty: Formatting commands for papers.
jfIA.sty: Formatting commands for Internet Appendices.
jf.bst: Bibliography format.
31
The bibliography contains references to published papers (Stanton, 1995), books (Hull, 2011), and work-
ing papers (Carpenter, Stanton, and Wallace, 2012), so you can see how various entry types are formatted.
32
For example, you may have page numbers listed in your BibTEX database as 10231045, while the
journal insists on 102345.
33
Save even more time by doing this after the copy-editor has taken a look and pointed out where you
need to make changes.
31
jfsample.tex: Sample paper (TEX file).
PDF file.
jfIAsample.tex: Sample Internet Appendix (TEX file).
PDF file.
2. Journal of Financial Economics:
jfe.sty: Formatting commands for papers.
jfe.bst: Bibliography format.
jfesample.tex: Sample paper (TEX file).
PDF file.
3. Review of Financial Studies:
rfs.sty: Formatting commands for papers.
rfs.bst: Bibliography format.
rfssample.tex: Sample paper (TEX file).
PDF file.
32
What happens when you realize that at some (unknown) time during the last month,
one of your coauthors accidentally deleted a section of the paper you really liked?
What happens when you realize that your code now produces different results than
it did a year ago, but shouldnt? How do you track down what changes to the code
during the last year caused the change in behavior?
A good back-up system (e.g., Time Machine) will help by allowing you to retrieve old versions
of your files.34 Using Dropbox or some similar file-sharing software is also very helpful in
solving the constant-emailing problem, and it also means that everyone knows that the
latest version of the file is always stored in the shared Dropbox directory (at least as long as
whoever edited it last has remembered to copy it from their working directory to the Dropbox
directory. . . ). For these and many other reasons I strongly recommend that everyone back
up their important files on a regular basis. I also love Dropbox. However,
Suppose you forget that its not your turn to edit a file (or you come up with an
algorithm or way of expressing a thought thats so brilliant you cant possibly wait to
commit it to paperor a .tex file). So now both you and your coauthor are editing
the file at the same time.
Now suppose you save your edits on Dropbox first and then your coauthor saves her
edits. Your edits have now disappeared from the latest version of the file (which is
quite a shame, given how brilliant they were).
More generally, wouldnt it be nice not to have to worry about editing the file sequentially, so
any of the coauthors could edit it whenever they had time or a good idea (or both), without
worrying about losing track of the current version of the file or of their or anyone elses
edits? And wouldnt it be nice if you could at any time easily go back to any prior version of
any file? A Version Control System (VCS) solves all of the problems we discussed above.
Among many advantages,
It makes it easy to merge simultaneous edits by different coauthors, so you dont have to
worry any more about editing files sequentially. Edit whatever file you want whenever
you want.
34
But how do you remember which version from about 6 months ago you actually need? This problem is
commonly solved by saving lots of versions of your paper and code with clever descriptive names like
program WFA2011.m
program remember this as I might want to go back to this version.m
program XXX.m
However, after a while there are so many files that you cant find the one you want in the crowd, and youll
eventually forget what those names, which seemed so clear when you first came up with them, mean.
33
It allows you to keep track of every revision of every file thats ever existed, along with
a log of what changed from one revision to the next. If you want to go back to a prior
version, or see whats changed since a version 2 years ago, its almost trivial.
The second advantage makes using a VCS a good idea even when theres only one author,
but its particularly valuable when there is more than one.35
An in-depth discussion of VCS is beyond the scope of this document. Some excellent
introductions, which explain way better than I could what version control is, why its im-
portant, and how to use it, are Sink (2011), Spolsky (2012), and OSullivan (2009).36 There
are numerous VCS to choose from, but my personal recommendation if youre starting from
scratch is to use one of the three most popular DVCS, Mercurial (see http://mercurial.
selenic.com), Git (see http://git-scm.com), or Bazaar (see http://bazaar.canonical.
com).37 With these systems, each author edits and keeps track of his or her changes locally,
and periodically pushes those changes to a shared central repository.
34
periment with it (and Mercurial).39
Note: I know you probably wont all start using a VCS tomorrow. Ive been extolling
their virtues for years, and so far Ive managed to get one coauthor to admitgrudgingly
that they might think about using one in about 150 years and the rest of them no longer
return my calls or emails. Using a VCS is still a good idea. Really. . . !
References
Carpenter, Jennifer, Richard Stanton, and Nancy Wallace, 2012, Estimation of employee
stock option exercise rates and firm cost, Working paper, U.C. Berkeley.
Hull, John C., 2011, Options, Futures, and Other Derivatives, 8th edition (Prentice Hall,
New York).
Kopka, Helmut, and Patrick W. Daly, 2003, Guide to LATEX , fourth edition (Addison-Wesley,
Reading, MA).
Lamport, Leslie, 1994, LATEX: A Document Preparation System, second edition (Addison-
Wesley, Reading, MA).
Mittelbach, Frank, Michel Goossens, Johannes Braams, David Carlisle, and Chris Rowley,
2004, The LATEX Companion, second edition (Addison-Wesley, Reading, MA).
Moser, Stefan M., 2012, How to typeset equations in LATEX, v. 3.7 (http://moser.cm.nctu.
edu.tw/docs/typeset_equations.pdf).
Oetiker, Tobias, Hubert Partl, Irene Hyna, and Elisabeth Schlegl, 2011, The not so short
introduction to LATEX 2 , v. 5.01 (http://www.ctan.org/tex-archive/info/lshort/
english).
OSullivan, Bryan, 2009, Mercurial: The Definitive Guide (OReilly Media, Inc., Sebastopol,
CA), http://hgbook.red-bean.com/.
39
For details of how to set up an account at Bitbucket and how to interact with Bitbucket repositories,
see Maddox (2012).
35
Sink, Eric, 2011, Version Control by Example (Pyrenean Gold Press, Champaign, IL), http:
//www.ericsink.com/vcbe/.
Stanton, Richard, 1995, Rational prepayment and the value of mortgage-backed securities,
Review of Financial Studies 8, 677708.
36