-
Notifications
You must be signed in to change notification settings - Fork 2
/
template.qmd
212 lines (159 loc) · 8.64 KB
/
template.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
---
title: "Quarto Title for the *APSR*"
format:
apsr-pdf:
keep-tex: false
runningtitle: Quarto APSR
runningauthor: "One, Two, and Three"
author:
- name: Author One
affiliations:
- name: An Organization
note: "Author One is PhD Candidate, ABC Department, Affiliation A, 12345 NY. (a.1@example.edu)"
- name: Author Two
affiliations:
- Affiliation B
note: "Author Two is Assistant Professor, Faculty of Z, Affiliation B, 42813. Corresponding Author (a.2@acme.edu) Additional notes about Author Two."
- name: Author Three
affiliations:
- A Third Organization
note: "Author Three is ..."
abstract: |
This document is a template demonstrating the APSR format.
Make sure it is long enough to work with the automatic dropcap.
That means you need at least three lines worth of text. That is a lot of
text for this example, but the APSR allows 150 words in the abstract at the
time of writing this example.
bibliography: bibliography.bib
classoption: twocolumn
nonblind: true
word-count: "{{wordcountref}}" # or set it manually like 500
execute:
echo: false
---
# Introduction {#sec-intro}
\dropcap{Thanks} for using Quarto to write your article. This Quarto template is unofficial and based on Overleaf's APSR template. Your introduction goes here! Do make sure the first paragraph here is at least three lines long, to accommodate the dropped-cap. Some examples of commonly used commands and features are listed below, to help you get started.
Since we are in Quarto, you can cite with an `@` symbol, like @knuth1984texbook. As seen below, you can mix markdown and Latex with each other, though it's likely best to mostly use markdown.
Use section (`#`) and subsection (`##`) commands to organize your document.
\LaTeX{} and Quarto handle all the formatting and numbering automatically.
Use the `@` commands for cross-references.
# Word Count
This template uses a wordcount lua filter from <https://github.com/christopherkenny/wordcount>.
To include the word count including references, set `word-count: {{wordcountref}}`.
To remove references from the word count, set `word-count: {{wordcount}}`.
# Figures and Tables
Beware: this template has a special first page style.
Like many such templates, it behaves very poorly if it tries to place a figure on the first page of the outputted PDF.
To avoid this problem, ensure that you have filled out at least some introductory paragraphs and the abstract before trying to render images immediately at the start of the paper.
You may find the [lorem R package](https://github.com/gadenbuie/lorem) useful for generating placeholder text if you are experiencing this issue at the start of writing.
Use the table and tabular commands for basic tables --- see @tbl-widgets, for example. [TablesGenerator.com](http://tablesgenerator.com) is a handy tool for designing tables and generating the LaTeX code, which you can copy and paste into your article here.
```{=tex}
\begin{table}[hbt!]
\caption{An example table}
\label{tbl-widgets}
\centering
\begin{tabular}{lr}
Item & Quantity \\\midrule
Widgets & 42 \\
Gadgets & 13
\end{tabular}
\floatnote{This is a note for this table.}
\end{table}
```
To include a figure in your document, I recommend using a code chunk.
You will want to set the floatnote property in the chunk.
All figure labels should start with `fig-`.
```{r}
#| label: fig-view
#| fig-cap: One way to include figures
#| floatnote: This is a note for this figure.
knitr::include_graphics('figs/example-image.png')
```
You can also include figures using Quarto syntax.
![A figure example.](figs/example-image.png){#fig-view2}
Finally, you can also create figures using R in general, like in @fig-r:
```{r, echo=FALSE}
#| label: "fig-r"
#| fig-cap: Example figure from R.
#| echo: false
#| floatnote: "A ggplot"
library(ggplot2)
mpg |>
ggplot() +
geom_density(aes(x = cty, fill = factor(cyl)), alpha = 0.7) +
theme_bw()
```
Notes can be added to the bottom of figures and tables in LaTeX using the `\floatnote` command.
```{=tex}
\begin{table*}
\caption{Automobile Land Speed Records (GR 5-10).}
\label{tbl-wide}
\begin{tabular}{l l l l r}
Speed (mph) & Driver & Car & Engine & Date \\
\midrule
407.447 & Craig Breedlove & Spirit of America & GE J47 & 8/5/63 \\
413.199 & Tom Green & Wingfoot Express & WE J46 & 10/2/64 \\
434.22 & Art Arfons & Green Monster & GE J79 & 10/5/64 \\
468.719 & Craig Breedlove & Spirit of America & GE J79 & 10/13/64 \\
526.277 & Craig Breedlove & Spirit of America & GE J79 & 10/15/65 \\
536.712 & Art Arfons & Green Monster & GE J79 & 10/27/65 \\
555.127 & Craig Breedlove & Spirit of America, Sonic 1 & GE J79 & 11/2/65 \\
576.553 & Art Arfons & Green Monster & GE J79 & 11/7/65 \\
600.601 & Craig Breedlove & Spirit of America, Sonic 1 & GE J79 & 11/15/65 \\
622.407 & Gary Gabelich & Blue Flame & Rocket & 10/23/70 \\
633.468 & Richard Noble & Thrust 2 & RR RG 146 & 10/4/83 \\
763.035 & Andy Green & Thrust SSC & RR Spey & 10/15/97\\
\end{tabular}
\floatnote{\url{https://www.sedl.org/afterschool/toolkits/science/pdf/ast_sci_data_tables_sample.pdf}}
\end{table*}
```
Tables can also be made using common table-making packages, like [`kableExtra`](https://cran.r-project.org/web/packages/kableExtra/index.html), as in @tbl-r.
Though formatting may be more finicky.
There is not currently a way to change the underlying environment to a `table*` environment within Quarto for these types of chunks.
```{r}
#| label: tbl-r
#| tbl-cap: Example R table.
mtcars[, 1:3] |>
head() |>
kableExtra::kable(format = 'latex')
```
For wide, double-column figures and tables, use the `figure*` (Figure \ref{fig-wide}) or `table*` (@tbl-wide) starred environments. Landscaped figures and tables can be obtained using the `sidewaysfigure` and `sidewaysfigure` commands from the `rotating` package. Alternatively, you can use the `landscape` environment from the `pdflscape` package.
Multi-page tables can be created using the `longtable` and `supertabular` packages, though note that `longtable`s cannot be used in two-column documents.\footnote{This is an example footnote.}
Currently `table`, `table*`, `figure`, `figure*`, `longtable`, `supertabular`, `sidewaystable` and `sidewaysfigure` will be automatically framed.
If you are using a custom figure or table environment from a package (e.g.~a `MyFigure` environment) and it's not getting framed, add `\makeframedenv{MyFigure}` in the preamble.
## Lists and Quotations
You can make lists with automatic numbering \dots
1. Like this,
2. and like this.
\dots or bullet points \dots
- Like this,
- and like this.
An example long quotation:
> This is a sample quotation text. This is a sample quotation text. This is a sample quotation text.
# Citations
Quarto formats citations and references automatically using the bibliography records in your .bib file. For a citation in parentheses use [@greenwade93] and for a text citation: @greenwade93. Multiple citations can be given as [@greenwade93;@knuth1984texbook]. Drop the author like so [-@greenwade93].
If your manuscript is accepted, the APSR production team will re-format the references for publication. \emph{It is not necessary to format the reference list yourself to mirror the final published form.}
# Mathematics
Let $X_1, X_2, \ldots, X_n$ be a sequence of independent and identically distributed random variables with $\text{E}[X_i] = \mu$ and $\text{Var}[X_i] = \sigma^2 < \infty$, and let
\begin{equation}
\label{eq:CLT}
S_n = \frac{X_1 + X_2 + \cdots + X_n}{n}
= \frac{1}{n}\sum_{i}^{n} X_i
\end{equation}
denote their mean. Then as $n$ approaches infinity, the random variables $\sqrt{n}(S_n - \mu)$ converge in distribution to a normal $\mathcal{N}(0, \sigma^2)$.
# Wide Figures
To include the widest of figures, set the `fig-env` to `figure*` in a Quarto chunk, just as you would set the environment to `figure*` in LaTeX. For some figures, you may also need to tell it to have `out-width: 100%` if the figure is naturally smaller than the width of the page.
```{r}
#| label: "fig-wide"
#| echo: false
#| fig-env: "figure*"
#| fig-cap: "A wide figure"
#| out-width: 95%
#| floatnote: "This is a wide figure."
knitr::include_graphics('figs/example-image-16x9.png')
```
Finally, you can include tex tables from other files as usual.
This can make use of input, though you may also find use for shortcodes from Quarto.
Built in shortcodes are listed [here](https://quarto.org/docs/extensions/shortcodes.html).
\input{figs/tableex2}
\clearpage