Exercise: Formatting Quarto documents in APA 7 style
This exercise is only relevant, if you are a psychologist or want to publish in journals that require manuscripts to be formatted in the APA 7 style (Publication Manual of the American Psychological Association: 7th Edition). If you are from another discipline, checkout whether Quarto already provides article templates for your most beloved journals.
Description
Pick a preprint of your own and implement it using Quarto in the APA 7 manuscript style. You also can view an example document that incorporates all features from this exercise.
Getting started
The official Quarto extension apaquarto
can be used to format documents according to the APA 7 guidelines1. After installing the extension into the current project, we can set the format
to apaquarto-pdf
or apaquarto-docx
. Here are the detailed steps that are necessary to create a manuscript in APA 7 style (Note: skip step 1 if you want to use an already existing Quarto document).
Prerequisites
- Install required packages
Click on Console
Enter
install.packages(c("rmarkdown", "conflicted", "tidyverse", "flextable", "ftExtra"))
- Install TinyTeX
- Click on Terminal
- Enter
quarto install tinytex
- Install required packages
Optional: Create a new Quarto Document
- Click on File > New File > Quarto Document
- Fill Title and Author
- Choose PDF
- Click Create
Add APA 7 Quarto extension
- Go to Terminal
- Enter
quarto add wjschne/apaquarto
- Confirm installation by entering Y twice, then avoid opening the documentation by entering n
- If you want to update the extension at a later point, enter
quarto update wjschne/apaquarto
Declare the language of the document by setting e.g.
lang: en
in the YAML header (see the Quarto documentation on document language for more information)Change
format
as follows:
format: apaquarto-pdf: documentmode: man a4paper: true pdf-engine: lualatex keep-tex: false
Click on the disk symbol to save (maybe call the file
manuscript.qmd
)Click on Render
(alternatively, go to the Terminal and enterquarto render manuscript.qmd
)
We can now provide additional information in the YAML header as detailed below.
Short title
A running header in upper case can be added like this:
shorttitle: "My short title"
Abstract
You can add an abstract using the abstract
YAML key:
abstract: "Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
Keywords
One can add multiple keywords by using a list:
keywords:
- meta science
- replication
- multiverse analysis
Figures
For including images, it is recommended to define a label starting with fig-
to make the figure cross-referencable. One can also add a note and set the image width and height. In APA 7 style, captions are to be written in title case.
![This Image Depicts a Flower.](flower.jpg){#fig-flower apa-note="This is the note below the figure." height="5cm" width="5cm"}
For figures that are computed dynamically, the following might serve as an example:
```{r}
#| label: fig-cars
#| fig-cap: Plot of the cars Dataset.
#| apa-note: Another note.
#| out-height: 5cm
#| out-width: 5cm
#| fig-height: 3
#| fig-width: 3
plot(cars)
```
When using the apaquarto
extension, by default, figures appear at the end of the document, unless one sets floatsintext: true
in the YAML header. Therefore it might make sense to add a final heading Appendix
below which the figures will appear. Figures can be cross-referenced by using the @
symbol followed by the reference label: For an image of a flower, see @fig-flower.
For more information on how to work with figures, head over to the Quarto documentation on figures.
Tables
Tables need to have labels prefixed with tbl-
:
| Letters | Numbers |
|:-------:|:-------:|
| A | 1 |
| B | 2 |
| C | 3 |
: My Caption {#tbl-mytable apa-note="Note below table" data-quarto-disable-processing="true"}
As an alternative to using markdown, tables can be created dynamically, e.g. using the R packages tibble
and flextable
:
```{r}
#| label: tbl-ingredients
#| tbl-cap: Substances and Their Key Ingredients.
#| apa-note: The note below the table.
tibble::tribble(
~"Substance", ~"Key Ingredient",
"a", "None",
"b", "Sugar",
"c", "Salt"
) |>
flextable::flextable() |>
flextable::theme_apa()
```
When using the apaquarto
extension, by default, tables appear at the end of the document, unless one sets floatsintext: true
in the YAML header. One can refer to tables by using the @
symbol followed by the reference label: Key ingredients are given in @tbl-ingredients.
For more information on how to create tables, head over to the Quarto documentation on tables.
Footnotes
The following serves as an example for how to add footnotes:
[This text appears as a footnote.] Here is an inline note.^
References
Put your bibliography in a BibTeX file (extension .bib
) and reference it in your YAML metadata:
bibliography: literature.bib
Add a level one heading and a Div with the id refs
at the end of the document (but before the appendix, if you have one):
# References
::: {#refs} :::
You can now cite from your bibliography using the syntax [@id]
.
For more information on how to cite literature, head over to the Quarto documentation on citations.
Numbered lines
If you would like to have your lines numbered, set numbered-lines: true
in the YAML header.
Generate .tex
file
Sometimes you might need the intermediate .tex
file in addition to the final .pdf
file. In order to keep that, set keep-tex: true
in the YAML header.
Use publication style
In the YAML header shared above, the style of the document is a manuscript as required when submitting to an APA journal. To switch to publication style which resembles the format of an article printed in an APA journal, change the document mode by setting documentmode: jou
Generate .docx
file
If you prefer to create your manuscript as DOCX rather than PDF, you can set the format as follows:
format:
apaquarto-docx: default
Final notes
You can download a manuscript with all the features presented on this page via the following button:
If you are interested in all the options provided by the apaquarto
extension (e.g., masked citations for anonymous peer review), have a look at the apaquarto documentation. Also, we recommend reading the guide APA Style via Markdown.