# Jeromy Anglim's Blog: Psychology and Statistics

## Monday, March 15, 2010

### APA Style References in LaTeX

This post discusses my experience getting APA style references in LaTeX. This includes both in-text citations and the end of document references list. It focuses on the use of the apacite package.

### Setting up a BibTeX Bibliographic Database

Regardless of what citation style you want, you need to have your references formatted in BibTeX format. JabRef is a powerful reference manager for working with a BibTeX database. Also, see my previous post for migrating an Endnote database into BibTeX format and migrating a Word Document with Endnote references into LaTeX format.

APA Style References Several options exist:

From my initial examination apacite looks like it has more features and is more compatible with the nuances of APA style. However, natbib is somewhat of a standard in LaTeX. Thus, using natbib citation commands may enable easier conversion between citation styles. The remainder of this post focuses on my experience with the apacite package.

### Using apacite

For comprehensive information on using apacite, see the documentation. The following sets out some basic details:

1. Ensure that you have a BibTeX database for the document. Your document will be more portable if the database is placed in either the same folder as the LaTeX files or in a subfolder of the LaTeX files.

However, you may prefer to maintain a general Bibliographic database that can be used across documents. If you wish to have a general database, you can use absolute file references to the database. Then when you need to share the BibTeX database, copy the database into a LaTeX project folder or subfolder and change the file reference in the bilbiography command .

2. Reference the apacite package in the preamble.

\usepackage{apacite}

3. Place the bibliography in the desired location in the document (usually after the main text) using the following code:

 \bibliographystyle{apacite} %http://www.ctan.org/tex-archive/biblio/bibtex/contrib/apacite/apacite.pdf \bibliography{bibtex/thesis} % database is "thesis.bib" located in a "bibtex" subfolder

4. To insert citations in the text apacite has a range of commands (see "The citation commands" in the Manual). Table 1 in the manual lists some of the main commands. I find myself using the following ones most often:

• cite: This inserts the author names and years in brackets. This is the standard methods. E.g., "(Anglim, 2002)".
• citeA: Inserts the author names in the text and years in brackets. I use this to insert the authors names in the text e.g., "Anglim (2002)".
• citeyear: inserts just the years in brackets. This is useful when I want to include the author's names in the text in a non-standard way. E.g., I've already written "Anglim's" then citeyear will insert "(2002)".

Each command takes a BibTeX reference as an argument and can have pre- and post- text. For example:

cite<e.g.,>{Ackerman1990JoEPLMaC}

displays as "(e.g., Ackerman, 1990)"

5. To produce the document with references included, the document typically needs to be built three times in order for all updates to occur.

French formatting
Problem: For some reason my document was using a French language version of apacite. This resulted in many unwanted  customisations, such as the French word for references (Références) being displayed at the start of the reference list.
Solution: I inserted the following code into the preamble to restore the English mode of apacite:

\usepackage[english]{babel}

1. Thanks for

\usepackage[english]{babel}

been going crazy trying to get rid of that French version of "References"

2. @Bear I'm glad it helped.

3. Do you know how to deal with other APA formating requirements in LaTeX? For example, how to make APA style heading in LaTeX? I am new to LaTeX and I can't find out how to make it work with the 6th edition of APA Manual.

4. Hi Daniel,
I'd recommend looking at the links under additional resources for tips on APA Style more generally.
Also, try posting a specific question on http://tex.stackexchange.com/

5. Wow thanks for the tip on babel. I was wondering why there were accents marks on my "References".

6. Man, Pls I need some help... I want to use APA style but instead "\usepackage[english]{babel}" I must use "spanish" package, but when I put "\usepackage[spanish]{babel}" the compilation fails and drop errors ...

7. @Alfonso
I'd post the question on http://tex.stackexchange.com/

you might want to check that the apacite package supports spanish natively.

8. Thanks for your posts. I enjoy your blog but never left a comment. With regard to changes in APA 6th edition, I wish someone with the knowledge of latex programming would modify apa style latex file. Do you have any insight as if anybody has attempted to modify the apa style file?

9. Hi Ross,
There was some discussion about APA 6th edition in LaTeX here: http://tex.stackexchange.com/questions/2628/how-to-apa-6th-in-latex

I'm sure I'll have to think more about APA 6th edition issues in the coming year or so. I'll be sure to post something when I work out a strategy.

10. Good post...

A hint for other readers of this blog: If you get odd error messages and your document fails to compile after switching to apacite, try deleting all temporary latex files (such as .aux and .bbl files) and try again. One of these temporary files (I think the old .bbl file) was causing my apacite to fail for this reason.

11. apacite uses angle brackets (< >)for optional pre/post-notes!? That's weird. Everything else I've used uses square brackets...

12. Do you have months in the journal article entries in your database? And if so, do they show up in the dates when you format a reference list (not in the in-text citations, just in the references at the end of the paper)? I'm just starting out with latex and I noticed that if the month is included in the entry (which happens when I download a reference from a database), then the month is printed in the reference list, which goes against APA guidelines. I can't tell if this is a problem with my setup (again, I'm new to this), or whether this is the way that it works for everyone. All the examples that I've found where someone provides a .tex file, a .bib file, and formatted output all have databases without months in them.

13. Yeah. I have noticed a few behaviours like that whereby fields that are in the reference are included even though I don't want to include them.
I generally just remove that field from the bibtex reference if it isn't important.

14. Okay, thanks! I didn't know whether I should spend the time to find a real fix, or whether I should just delete the month field from the database.

15. Thank you about the French references thing! :)

16. Is there a way to get apacite to number each reference? For example:
[1] Trefethen, L. N. (2007). Computing numerically with functions instead of numbers.
Mathematics in Computer Science, 1 (1), 9-19.
[2] ...

17. @Anonymous Numbered references in apacite is not something I've ever needed, so I'm not sure.

18. Thanks to this blog post I discovered apalike for natbib. Thanks you!

19. This was extremely helpful. Had a really tough time getting apacite to work correctly and this solved the problem. Thanks!

20. Thank you, very helpful. Any idea how to cite Tables and Figure using Latex and APA?

1. You mean like \label in a float and \ref in the body? http://en.wikibooks.org/wiki/LaTeX/Tables

21. Thanks for this post, made using apastyle much easier!
If you still maintain this, maybe add the following hint:

\usepackage{apacite} has to stand AFTER \usepackage{hyperref} otherwise citations might not work (it's also written in the apacite manual, but damn I took time to find out what the problem was with my latex)

This is a solution to problems like : ! Paragraph ended before \@cite was complete.

22. Stephan, thanks for clearing that up. I am left with one last hurdle, the bibliography part. I have always used
\begin{thebibliography}{99}
\bibitem{xxx}
\emph{xxxx}
but now, it is saying control sequence not recognized. How do I change the bibliography to work with apacite?.

23. I am the first timer for using apacite, and got the following error message:

!undefined control sequence.
1.1216 \st@rtbibchapter

What's this? Thanks.

24. The best latex APA is actually using biblatex, not bibtex. biblatex uses your .bib file & also lets you use natbib citation styles.