6.8 Cross References

  1. Add labels

    Two options:

    • Code cell: add option label: prefix-LABEL
    • Markdown: add attribute #prefix-LABEL
      • Note that the prefix should be connected to the label with a hyphen -.
      • Note that the hash sign # is required.
  2. Add references: @prefix-LABEL, e.g.

    You can see in @fig-scatterplot, that...
Element ID How to cite
Figure #fig-xxx @fig-xxx
Table #tbl-xxx @tbl-xxx
Equation #eq-xxx @eq-xxx
Section #sec-xxx @sec-xxx

Cross-reference to a figure:

```{r #fig-scatter, fig.cap="Scatter plots example"} 
  # scatter plot example
  plot(1:10)
```
Scatter plots example

Figure 6.1: Scatter plots example

See Figure 6.1 (@fig-scatter) for the scatter plots.

You can customize the prefix of the reference (Figure x) using crossref/*-prefix options in YAML.

---
crossref:
  fig-prefix: "Fig"   # (default is "Figure")
---

Cross-references to Equations

$$
y_i = \beta_{i}'x + u_i.
$$ {#eq-cross_sectional_hetero}
  • @eq-cross_sectional_hetero gives Equation 1.

    With the Equation prefix, but no parentheses around the label.

    Quarto Discussion: Add parentheses around equation numbers reference – Unresolved as of Jan 2026.

  • ([-@eq-cross_sectional_hetero]) gives only the tag (1), note that you need to add the parentheses yourself.

  • An alternative way is to use \eqref{eq-cross_sectional_hetero} from amsmath package, which gives (1) with parentheses automatically. You need to add the prefix Eq. yourself. ↩︎

You can customize the appearance of inline references by either changing the syntax of the inline reference or by setting options.

Here are the various ways to compose a cross-reference and their resulting output:

Type Syntax Output
Default @fig-elephant Figure 1
Capitalized @Fig-elephant Figure 1
Custom Prefix [Fig @fig-elephant] Fig 1
No Prefix [-@fig-elephant] 1

Note that the capitalized syntax makes no difference for the default output, but would indeed capitalize the first letter if the default prefix had been changed via an option to use lower case (e.g. “fig.”).

Change the prefix in inline reference using *-prefix options. You can also specify whether references should be hyper-linked using the ref-hyperlink option.

---
title: "My Document"
crossref:
  fig-prefix: figure   # (default is "Figure")
  tbl-prefix: table    # (default is "Table")
  ref-hyperlink: false # (default is true)
---