Appendix B: Quarto Cross-Reference Guide

This appendix provides a complete reference for Quarto’s cross-referencing system, covering figures, tables, equations, sections, and theorems.

How Cross-References Work

Quarto’s cross-reference system has two parts:

  1. A label on the item being referenced (must start with fig-, tbl-, eq-, sec-, etc.)
  2. A reference in text using @label

Quarto then numbers items automatically and inserts the number wherever @label appears.

Figures

ggplot2 / Base R Figures

```{r}
#| label: fig-yield-trend
#| fig-cap: "Annual wheat yield trend in Punjab (2010–2023)."
#| fig-alt: "Line chart showing increasing wheat yield over time."
#| fig-width: 8
#| fig-height: 4.5

ggplot(wheat_data, aes(x = year, y = yield)) +
  geom_line() + ...
```

Reference in text: As shown in @fig-yield-trend, yields have increased...

Rendered: “As shown in Figure 1, yields have increased…”

Multiple Figures (Sub-figures)

```{r}
#| label: fig-comparison
#| fig-cap: "Yield comparison across crops."
#| fig-subcap:
#|   - "Wheat yields by state"
#|   - "Rice yields by state"
#| layout-ncol: 2

plot_wheat
plot_rice
```

Reference sub-figures: @fig-comparison-1 and @fig-comparison-2.

Static Images

![Caption for the image.](images/my-figure.png){#fig-my-image width=80%}

Reference: @fig-my-image.


Tables

knitr Tables

```{r}
#| label: tbl-summary-stats
#| tbl-cap: "Summary statistics for the wheat yield dataset."

knitr::kable(summary_table)
```

Reference: @tbl-summary-stats.

gt Tables

```{r}
#| label: tbl-regression-results
#| tbl-cap: "Regression coefficients for the yield model."

library(gt)
my_table |> gt()
```

Markdown Tables

| State  | Yield (qt/ha) | Area (000 ha) |
|--------|---------------|---------------|
| Punjab | 50.2          | 3520          |

: Summary of wheat production {#tbl-wheat-states}

Reference: @tbl-wheat-states.


Equations

Display Equations

The linear model is:

$$
Y_i = \beta_0 + \beta_1 X_i + \varepsilon_i
$$ {#eq-linear-model}

where $\varepsilon_i \sim N(0, \sigma^2)$.

Reference: As shown in @eq-linear-model...

Inline Math

Inline equations use single dollar signs: $\hat{\beta} = (X^TX)^{-1}X^Ty$

Common LaTeX Math Symbols

Table 1: Common LaTeX math symbols used in statistics
Symbol Meaning LaTeX Code
\(\mu\) Population mean
\(\sigma\) Population SD
\(\sigma^2\) Population variance ^2
\(\bar{x}\) Sample mean {x}
\(\hat{\beta}\) Estimated coefficient
\(\sum\) Summation
\(\prod\) Product
\(\int\) Integral
\(\alpha\) Significance level / Type I error
\(\beta\) Regression coefficient
\(\epsilon\) Error term
\(\varepsilon\) Residual
\(\sim\) Distributed as
\(\approx\) Approximately equal
\(\neq\) Not equal
\(\leq\) Less than or equal
\(H_0\) Null hypothesis H_0
\(H_1\) Alternative hypothesis H_1
\(\chi^2\) Chi-squared ^2
\(\infty\) Infinity

Sections

Section cross-references use the section’s label (the {#sec-...} anchor):

## Methods {#sec-methods}

... content ...

As described in @sec-methods, we used...
TipQuarto Auto-Labels

Quarto automatically creates labels for headings based on their text. “## My Analysis” gets the label #sec-my-analysis. You only need to specify {#sec-...} explicitly if you want a custom label.


Theorems and Proofs

::: {#thm-clt}
## Central Limit Theorem

Let $X_1, X_2, \ldots, X_n$ be i.i.d. random variables with mean $\mu$ and 
variance $\sigma^2$. Then as $n \to \infty$:

$$
\frac{\bar{X}_n - \mu}{\sigma/\sqrt{n}} \xrightarrow{d} N(0, 1)
$$
:::

Reference: @thm-clt states that...

Other theorem-type blocks: {#def-...} (Definition), {#lem-...} (Lemma), {#cor-...} (Corollary), {#prp-...} (Proposition), {#exm-...} (Example).


Citations

Basic Citations

<!-- Inline citation -->
@wickham2016r found that...

<!-- Parenthetical citation -->
The Grammar of Graphics [@wilkinson2005grammar] describes...

<!-- Multiple citations -->
Several studies [@ref1; @ref2; @ref3] have shown...

<!-- Suppress author name -->
The package [-@wickham2016r] provides...

<!-- Page numbers -->
@wickham2016r [p. 42] states...

.bib File Format

@book{wickham2016r,
  title     = {R for Data Science},
  author    = {Wickham, Hadley and Grolemund, Garrett},
  year      = {2016},
  publisher = {O'Reilly Media},
  url       = {https://r4ds.had.co.nz}
}

@article{wilkinson2005grammar,
  title   = {The Grammar of Graphics},
  author  = {Wilkinson, Leland},
  year    = {2005},
  journal = {Springer},
  doi     = {10.1007/0-387-28695-0}
}

Cross-Reference Prefixes Summary

Table 2: Quarto cross-reference label prefixes and their usage.
Type Prefix Example Label Reference Syntax
Figure fig- #fig-scatter Figure 5.2
Table tbl- #tbl-summary ?tbl-summary
Equation eq- #eq-linear ?eq-linear
Section sec- #sec-methods ?sec-methods
Listing (code) lst- #lst-clean-code ?lst-clean-code
Theorem thm- #thm-clt ?thm-clt
Lemma lem- #lem-helper ?lem-helper
Corollary cor- #cor-result ?cor-result
Proposition prp- #prp-main ?prp-main
Definition def- #def-pvalue ?def-pvalue
Example exm- #exm-ttest ?exm-ttest
Exercise exr- #exr-exercise1 ?exr-exercise1