Getting APA formatting setup on LaTeX was a pain for me, most possibly because I’ve only recently started messing with LaTeX a lot. Nevertheless, I’d like to record what I did to get the formatting set up, and various tidbits that you need to be careful about to produce APA6 with BibTeX. So, suppose we are writing an essay for psychology and the teacher requires that it is has APA formatting.
1. Obtaining the APA document class. Do not manually try to do APA formatting. Instead, look for the APA 6th edition document class package on CTAN: http://www.ctan.org/tex-archive/macros/latex/contrib/apa6. Download the .zip file and extract everything to some folder, say C:\Users\Username\Desktop. Open up the “apa6.dtx” file in TeXnicCenter (or whatever program works for you), and then hit compile. Of course, it will output a pdf “apa6.pdf” and you will have many errors and warnings: that’s ok. If you look in the folder where the “apa6.dtx” file was, you should now also have a file called “apa6.cls”, which is the APA 6th edition document class file.
2. Setting up APA on a .tex file. Suppose you are working on an essay, stored in C:\Users\Username\Desktop\Essay for Psychology\Essay.tex. Copy and paste the apa6.cls file into the “Essay for Psychology” folder. You can now put the following in the preamble of “Essay.tex”:
\documentclass{apa6}
You will now want to specify the options for this document class. The three primary options you have are called “jou”, “man”, and “doc”. “jou”, to my understanding, will do everything that “man” does, but also put it in two column format. Most likely this is not what your teacher has requested. However, “man” does include things that you’d need for submission to an APA-format required journal: a titlepage with a running head, commands for abstract and table of contents, etc. I believe “doc” avoids titlepage and header – it just handles double-spacing and section headings and such. For now, let’s use “man”.
Another important option that I encountered was the option to have figures (pictures, graphs) between the text, rather than after the references. If you have any figures that you want to refer to frequently, you might want to also want to include the option “floatsintext”, which will put the floats (figures) in the text rather than after the references. So, including these two options will give you:
\documentclass[man,floatsintext]{apa6}
3. The rest of the preamble. At best, I can include here what packages I want to use. As it turns out, for IB we have to do an extended essay which my supervisor wants in APA format. This is rather unusual since I want to do a mathematics essay. At any rate, this is why I have the following packages:
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{geometry}
\usepackage{hyperref}
\usepackage{apacite}
The first two packages are amsmath and amssymb, which are used to typeset math and get fancy symbols. The package graphicx is for including figures in the text, and the package geometry provides an easy way to format the paper (set margins, and such). To be honest, I’m not sure why else I have it.
A comment on the last two packages. Yesterday I was able to get apacite and hyperref working together without problems: I was toying with it today, and couldn’t get lower than 6 errors each time I compiled. I looked online: http://promberger.info/linux/2009/03/18/latex-using-apacite-and-hyperref-in-the-same-document/ and found that the answer is that the hyperref package should come before the apacite package (which is used to make citations and the bibliography in APA format). Now, more on citations later.
4. More on the preamble. I presume that setting the margins to your liking with \setlength commands will cause no problems. Alternately, I do not think setting them as options on the geometry package will cause any problems either. However, we have more to say on the remainder of the preamble, in which commands for the running head, abstract and title/author come. Here is the remainder of my preamble after all the \usepackage code.
\shorttitle{Short title and anything else}
\title{Title}
\author{Name \\ Anything else you need}
\affiliation{Institution Name}
\abstract{Abstract here.}
\begin{document}
\maketitle
\tableofcontents
\newpage
The \shorttitle command gives you the running head. It should be a short title. The title command gives you a title, \author gives you an author. For my personal convenience, I put anything else I need here (such as word count, IB number, etc.). This information can be put on additional lines with the \\ separation as you see above. The affiliation and abstract should be self-explanatory.
That is where the preamble ends, and where the document begins. However, the first thing in the document part of the code should be the \maketitle. You can (I think “should,” because I believe it’s APA format) have the table of contents come after the abstract with the \tableofcontents command. The \newpage is to separate this from the body of the text.
5. Citations. Obtain the apacite package from here: http://www.ctan.org/tex-archive/biblio/bibtex/contrib/apacite. Like before, extract the files to a separate folder and open and compile apacite.ins to obtain apacite.sty. Include this in your LaTeX project folder (just the apacite.sty). For more information on actually installing the packages, see section 1.1 here: http://www.iit.edu/graduate_college/academic_affairs/pdfs/StyleHelp2.pdf. Once you have the apacite.sty file in your folder (say, C:\Users\Username\Desktop\Essay for Psychology), you can nearly begin citations. We will discuss why you can only “nearly” begin in a moment.
Once you have the citation system set up, you will be able to simply reference things in the body of the essay and the “References” section will automatically be compiled for you. However, for now, I will go over three (four?) standard citation commands (by standard, I mean what I used on my own paper).
- Citing multiple sources at once. For this, simply use the command: \cite{source1, source2}. This will give you “(source1,year1), (source2,year2)”.
- Citing just the year. For this, simply use the command: \citeA{source1}. This will then give you “source 1 (year 1)”.
- Page numbers. This will work for any number of sources, as well as work with \citeA. Simply add [p.#] between \cite and {sources}. For instance, if I wanted the citation “Arfken (1985, p.450)” then I would use the command \citeA[p.450]{Arf85}, where Arf85 is the abbreviation I have given the source (more on this later).
- Citing the author and the year. If I wanted the citation (Arfken, 1985), then I would type \cite{Arf85}, where again Arf85 is the abbreviation I have given the source.
Now you might be wondering: How will LaTeX know the information that needs to be on the References page?
6. Creating a BibTeX Database (.bib file). This was the scary part for me. But have no fear! Essentially, you first need to create a .txt file that will store information about the sources that you have drawn from. Later you will change this to a .bib file, open it in TeXnicCenter (or TeXWorks, which is actually the default for me and it seems to be more convenient than TeXnicCenter), and then compile it as BibTeX. The information that you should record for each type of source (book, article, proceedings, etc.) can be found here: http://www.maths.ox.ac.uk/help/faqs/latex/bibtex
As an example, let me show you my .bib file:
@BOOK{Bro03,
AUTHOR = "Brown, J.W. and Churchill, R.V.",
TITLE = "Complex Variables and Applications",
PUBLISHER = "McGraw Hill",
YEAR = 2003
}
@BOOK{Arf85,
AUTHOR = "Arfken, G.",
TITLE = "Mathematical Methods for Physicists",
PUBLISHER = "Academic Press",
YEAR = 1985
}
@UNPUBLISHED{Carde12,
Author = {Carde, Kevin},
Institution = {Canada/USA Mathcamp},
Howpublished = {Class handout},
Year = {2012},
Title = {Summing Series: Complex Analysis Edition}
}
@ONLINE{Sik07,
author = {Siklos, S.T.C.},
title = {Cauchy Principal Value},
year = {2007},
url = "{http://www.damtp.cam.ac.uk/user/stcs/courses/fcm/handouts/cauchy_principal_value.pdf}"
}
@MISC{Wiki1,
author = "Augustin-Louis{\hspace{4pt}}Cauchy",
title = "\textup{In} {W}ikipedia",
year = "n.d.",
howpublished = "Retrieved September 28, 2012 from \url{http://en.wikipedia.org/wiki/Augustin-Louis_Cauchy\#Complex_functions}",
}
@MISC{Wiki2,
author = "Estimation{\hspace{4pt}}lemma",
title = "\emph{In} {W}ikipedia",
year = "n.d.",
howpublished = "Retrieved September 28, 2012 from \url{http://en.wikipedia.org/wiki/Estimation_lemma}",
}
@MISC{Wiki3,
author = "Jordan's{\hspace{4pt}}lemma",
title = "\textup{In} {W}ikipedia",
year = "n.d.",
howpublished = "Retrieved September 28, 2012 from \url{http://en.wikipedia.org/wiki/Jordan's_lemma}",
}
You can look up more of these online. The books, unpublished, and online should speak for themselves. Basically, the first entry in the brackets after the @(TYPE OF SOURCE) is the abbreviation you give to the source so that you can easily use the \cite command on it. (Recall for instance, I used the command \cite{Arf85}). Use abbreviations that make sense! Afterwards, you fill in information that in general any citation style will want to draw from.
Weird code for Wikipedia. Let me explain quickly the Wikipedia entries (@MISC). Wikipedia’s entry on citing Wikipedia says that APA formatting requires that their page on plagiarism be formatted as:
Plagiarism. (n.d.). In Wikipedia. Retrieved August 10, 2004, from http://en.wikipedia.org/wiki/Plagiarism
In particular, the APA format requires the article name to take the place of the author.
To cite Wikipedia with BibTeX, they say to use the code:
@misc{ wiki:###,
author = "Wikipedia",
title = "Plagiarism --- {W}ikipedia{,} The Free Encyclopedia",
year = "2004",
url = "\url{http://en.wikipedia.org/w/index.php?title=Plagiarism&oldid=5139350}",
note = "[Online; accessed 22-July-2004]"
}
This however, puts Wikipedia as the author, among other things (and is therefore not in APA format).
The solution, of course, is that we must put the title into the author field. However, if we then compile, we get things like: if I put, say, author = Estimation lemma, the output in the author position is “lemma, E.” Well, that’s not quite the article name. There are two solutions to this. The first, which I figured out myself, is to set put in the author field the code “Estimation\hspace{4pt}lemma” which then simulates the spacing between two words. A better solution to this problem, which I asked on tex.stackexchange.com (if you have any major problems you’re stuck on with your code, GO THERE): http://tex.stackexchange.com/questions/74578/citing-wikipedia-with-apa-formatting-and-bibtex.
The answer is to simply put
author = {{Estimation lemma}}
That is, to use double brackets (double quotation marks doesn’t quite work). The outer set of brackets work just like the quotation marks.
Reason why the “W” in “Wikipedia” is in brackets. This capitalizes the W. APA format requires the first letter of the first word in a title to be capitalized, and everything else to be in lower case. Of course, given that Wikipedia says APA doesn’t want that in citing Wikipedia, we better get rid of it.
Dangers and benefits of using the \url{…} command in your .bib file. The benefit of this is that when the citation appears in your references page, the \url command automatically breaks up long URLs in natural places (such as after/before a backslash, etc.). The problem with this is that it conflicts with BibTeX a lot – you can find that issue all over the web. I don’t have any certain solution to this. Some things I did to solve this problem:
- Take your LaTeX project file and any necessary other files (such as apa6.cls and apacite.sty) to a new folder, and compile there.
- Include the \url{…} command in the “howpublished” field. In this case, when citing Wikipedia in APA format with BibTeX, it’s actually necessary. We want the part that says “Retrieved (date) from …,” which to my knowledge we can only add in in the “howpublished” field (as opposed to the “url” field).
Miscellaneous on .bib files. Do not forget the commas after each field in the example above. Also note that the outer set of brackets work like quotation marks (and since they appear to be more flexible, might be more useful in general than quotation marks). I also think it could cause problems if your .bib file name has spaces, but I am not certain on this. In general I have noticed it is a good idea to avoid spaces in file names when working with TeXnicCenter, however.
Creating a bibliography. Finally, we are basically done. If you have put \usepackage{apacite} in your preamble, put the following code on its own page (usually references are on their own page).
\bibliographystyle{apacite}
\bibliography{refs}
The “refs” is whatever you named your .bib file before. Now you need to: compile your LaTeX file. Then compile your BibTeX file. Afterwards, compile your LaTeX file twice. After this you should be done. Any time you make minor edits, be sure to compile LaTeX, then BibTeX, then LaTeX twice. If you get errors that prevent a .pdf from being outputted (or just want to get rid of errors in general), look at every possible piece of offending code. Generally, you will be able to tell when the error is in the body of the essay (if you’re used to TeXing, you can avoid this). Otherwise, look at whether packages conflict with each other, whether the order of the packages might conflict with each other, etc. If all else fails, Google the problem or go to tex.stackexchange.com.
When all is said and done, you should have something that looks like this (note: on my Windows 7 64-bit laptop, when I compile this I only get 1 warning for no citations which will, of course, go away when I put in citations).
\documentclass[man,floatsintext]{apa6}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{geometry}
\usepackage{hyperref}
\usepackage{apacite}
\shorttitle{Short title and anything else}
\title{Title}
\author{Michael Zhao \\ Anything else you need}
\affiliation{Institution Name}
\abstract{Abstract here.}
\begin{document}
\maketitle
\tableofcontents
\newpage
\newpage
\bibliographystyle{apacite}
\bibliography{references}
\end{document}