Simplify Your Academic Life With LaTeX on Your Next Paper

Publishing an APA Paper with LaTeX

Simplify Your Academic Life With LaTeX on Your Next Paper

Photo by Chris Arthur-Collins on Unsplash


Using LaTeX to author a paper can be a tedious process when you’re just getting started; however, I found it a powerful tool to control the publishing process running. Some of the advantages I’ve found:

  1. Documentation-as-Code along with version control.

  2. Ability to integrate with your codebase making updates seamless.

  3. Prebuilt templates that perfectly format based on a standard such as the American Psychological Association or APA format.

  4. Ability to insert advanced typesetting such as math equations.

I wanted to document the process I ended up using. I hope it’s helpful to you!

What is LaTex?

LaTeX is a software system that’s used for document production. Instead of utilizing a graphical editor, LaTeX is authored using plain text and a markup language. When combined with the TeX typesetting system, the document is compiled into an output format.

Installing LaTeX

First, you need to get LaTeX installed. I’m running a Mac, and therefore I’m using the MacTeX distribution. You can download it here:

I find this distribution complete and easy to manage. An installer is provided that has everything you need to author and publish TeX documents. It’s also compatible with Intel or Arm (Apple Silicon) processors.

Updating the TeX Distribution

After installing the software, you need to ensure all appropriate packages are up to date. You can accomplish this by Launching the TeX Live Utility and running the Update All Packages command.

Image by Author

VS Code and LaTeX

Next is your Authoring Environment. The MacTeX distribution does come with an editor, but it is very spartan. Fortunately, VS Code has a wonderful extension that allows you to write your document directly inside your favorite editor and publish your document automatically as you edit it.

Install the LaTeX Workshop extension from the VSCode Marketplace.

A Cloud-Based Alternative

There is also a nice cloud-based solution called Overleaf. The APA Template is even available to get you started quicker. Check out Overleaf for more information. The downside is that you’re not integrated with your coding environment.

The APA Template

I’ll admit that building an APA formatted document from scratch with LaTeX would be a different experience than what comes next. Fortunately, Daniel A. Weiss created a great APA template that supports the 7th edition and is included in the TeX Live distribution. As long as you’ve updated your packages, it should be seamless.

Be sure to check out the documentation (PDF). It clearly shows how to use the template and will help you with further customization.

Building Blocks of an APA Paper

Several sections of the TEX document create all of the components needed for a paper. I’ll go through each of them with code samples.

Document Header

Start by creating a new document with any name and add the extension .tex. Insert these lines at the very top. Note the \begin{document} and \end{document} tags. The rest of the paper will fall between these.




We can see the documentclass is set to use the {apa7} template along with the option stu, which is a definition for formatting as a Student Paper vs. a journal article. Additionally, there is the \addbibresource{} definition, which I'll cover later, that will help us add citations that are properly formatted into the document.

Title Page and Abstract

Adding a Title Page and Abstract page is a breeze. Just insert this between the begin and end tags.

\title{Capstone Project}

\authorsnames{Brian Roepke}
\authorsaffiliations{Data Analytics, Golden Gate University}
\professor{Dr. Professor Data}
\duedate{August 21, 2021}

Bacon ipsum dolor amet jerky burgdoggen turkey...


You’ll also notice that the compiler will start to create your first PDF! Upon each change you make, you will see the PDF update. One of the great things about the VS Code integration is you can preview the PDF side by side and watch your changes appear as you make them. Just open the preview splitter window to the side, and you should see a PDF with a cover page, an abstract, and the first page of the paper. Magic!

Body and Sections

Next, we can author the paper. The general structure adds your first intro page under the \maketitle tag and then follows several sections and sub-sections.

Tongue sausage ground round capicola pork pancetta brisket, strip steak...


\section{Sentiment Analysis of Dog's Feelings Towards Bacon}

Drumstick short loin cow prosciutto flank leberkas pastrami pancetta...

\subsection{Other Sources of Bacon Goodness}
Consectetur biltong pork chop duis lorem consequat...

What is happening here?

  • \newpage does exactly that - puts a page break in the document and allows you to start a section on a new page.

  • \section is the second level heading according to APA. It's Flush Left, Boldface, Title Case Heading

  • \subsection is the third level heading. It's Flush Left, Boldface Italic, Title Case Heading

  • \subsubsection is the fourth level heading and so on. There are five levels supported. Check out the documentation for information.


Next is an example of how to insert a figure, accomplished via an in-text reference using the following syntax:

(see fig ~\ref{fig:my_fig})

Then anywhere in the document, you create the figure with the corresponding matching label. There are additional controls for the placement of images that you'll find important as your document grows. There is a great answer on StackExchange describing the options.

\caption{A puppy confused by bacon-ipsum, but really wants bacon.}


Adding citations is also incredibly easy. In the header of the document, we had defined \addbibresource{bibliography.bib}. Create a file with this name, and then you can add a citation to it using the BibTeX format like this:

title={How to Lie with Statistics},
author={Huff, D. and Geis, I.},
publisher={W. W. Norton}

And then, when citing in the body of your paper, you add the citation like this:

Andouille alcatra burgdoggen, tri-tip boudin shank jerky buffalo beef short loin \textcite{huff2010lie} filet mignon leberkas \parencite{huff2010lie}.

The output will look something like the below, showing both text and classic citations.

Andouille alcatra burgdoggen, tri-tip boudin shank jerky buffalo beef short loin Huff and Geis (2010) filet mignon leberkas (Huff & Geis, 2010).

Working with a Reference Manager

If you use a reference manager like EndNote or Zotero, you can export your entire citation list as BibTex and paste it into the .bib file. I used EndNote for a good portion of my academic studies, but I recently switched to Zotero because it's excellent and free to use. Here is a quick flow on how you export your citations.

Image by Author

From the Zotero interface, highlight the items you wish to export and select the Export items... menu option.

Image by Author

Next, select the BibTex option and save the file. From here, you can move these into the bibliography.bib file. Make sure to remove the file: key-value pair.

Image by Author

Integrating with Your Project Code

I mentioned above that one of the advantages of using LaTeX and VS Code together is integrating with your code automatically. You can easily reference images saved from Python directly in the references to the images in the LaTeX document.

If you’re using matplotlib, add these two lines after your plot:

plt.savefig('images_path/img_name.png', dpi=300);

And then reference that image in your LaTeX document. Every time your plot updates, you won’t have to worry about updating it.


Image by Author

It can seem like a daunting task when you’re getting started. By learning a few basics and leveraging templates like the APA template used here, you can easily publish professional-looking papers and articles. Give it a shot on your next assignment or project! For convenience, I’ve posted the source code on GitHub if you’d like to see the entire project.