6.8 Cross References
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.
- Note that the prefix should be connected to the label with a hyphen
- Code cell: add option
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:
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.
Cross-references to Equations
@eq-cross_sectional_heterogivesEquation 1.With the
Equationprefix, 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}fromamsmathpackage, 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)
---