You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/authoring/cross-references-divs.qmd
+26-2Lines changed: 26 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -6,9 +6,21 @@ title: Cross-Reference Div Syntax
6
6
7
7
## Overview
8
8
9
-
Cross-referenceable [figures](#figures), [tables](#tables) and [code listings](#listings) are known as *float* cross-references. Floats can appear in the rendered document at locations other than where they are defined, i.e. they float, and usually have captions.
9
+
Cross-referenceable [figures](#figures), [tables](#tables) and [code listings](#listings) are known as *float* cross-references.
10
+
Floats can appear in the rendered document at locations other than where they are defined, i.e. they float, and usually have captions.
10
11
11
-
Along with compact syntax for the most common uses of cross-references, Quarto also provides a more general div syntax for declaring floats that can be cross-referenced. To declare a cross-referenceable float, place the content inside a fenced div with the reference identifier as an attribute. The last paragraph inside the fenced div will be treated as the caption. For example:
12
+
Along with compact syntax for the most common uses of cross-references, Quarto also provides a more general div syntax for declaring floats that can be cross-referenced.
13
+
To declare a cross-referenceable float, place the content inside a fenced div with the reference identifier as an attribute.
14
+
The last paragraph inside the fenced div will be treated as the caption.
15
+
16
+
::: callout-warning
17
+
18
+
Quarto currently only supports this alternative syntax for **floats**, as described above.
19
+
Some cross-referenceable elements like theorems, proofs, etc naturally use this div syntax, but note that Quarto does not support the use of the div syntax for block-level equations.
20
+
21
+
:::
22
+
23
+
As a minimal example, consider the following QMD snippet:
12
24
13
25
````{.markdown}
14
26
::: {#fig-example}
@@ -20,6 +32,18 @@ Caption
20
32
:::
21
33
````
22
34
35
+
This produces the following (admittedly silly) figure:
36
+
37
+
::: {#fig-example}
38
+
39
+
CONTENT
40
+
41
+
Caption
42
+
43
+
:::
44
+
45
+
Now, this figure can be cross-referenced with `@fig-example`, see @fig-example.
46
+
23
47
To be recognized as a cross-reference the identifier must begin with one of the built-in float reference types (Figures (`fig-`), Tables (`tbl-`) and Listings (`lst-`)), or be defined as a [custom float cross-reference](cross-references-custom.qmd) type.
24
48
25
49
You can then refer to the element as usual with the `@` syntax, e.g.
0 commit comments