Skip to content

Commit 66f170a

Browse files
docs(language): document crossref title/prefix localisation (#2006) (#2009)
* docs(language): document crossref title/prefix localisation * refactor: reword per suggestion (cherry picked from commit c11a03d) Co-authored-by: Mickaël Canouil <[email protected]>
1 parent b37d283 commit 66f170a

4 files changed

Lines changed: 107 additions & 1 deletion

File tree

docs/authoring/_cross-references-callouts.qmd

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,20 @@ The prefixes for each type of callout are:
3232
| `important` | `#imp-` |
3333
| `caution` | `#cau-` |
3434

35-
: Prefixes for callout cross-references {#tbl-callout-prefixes}
35+
: Prefixes for callout cross-references {#tbl-callout-prefixes}
36+
37+
The text used for each callout cross-reference (for example, "Note 1" in "See Note 1...") can be localised by setting `crossref-{nte,tip,wrn,imp,cau}-prefix` under `language:`:
38+
39+
``` yaml
40+
---
41+
lang: fr
42+
language:
43+
crossref-nte-prefix: "Note"
44+
crossref-tip-prefix: "Astuce"
45+
crossref-wrn-prefix: "Avertissement"
46+
crossref-imp-prefix: "Important"
47+
crossref-cau-prefix: "Mise en garde"
48+
---
49+
```
50+
51+
See [Cross-Reference Titles and Prefixes](language.qmd#cross-reference-titles-and-prefixes) for the full localisation pattern, including per-language subkeys.

docs/authoring/cross-reference-options.qmd

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,29 @@ crossref:
4141
---
4242
```
4343

44+
## Localisation
45+
46+
The `crossref:` keys above override caption titles and reference prefixes for the current document and are language-independent.
47+
For locale-aware overrides, set the corresponding `crossref-{type}-title` and `crossref-{type}-prefix` keys under `language:` instead.
48+
These keys plug into Quarto's localisation system, can be scoped per target language, and can live in a project-level `_language.yml` file.
49+
50+
For example, the Spanish equivalent of the snippets above is:
51+
52+
``` yaml
53+
---
54+
title: "Mi Documento"
55+
lang: es
56+
language:
57+
crossref-fig-title: "Figura"
58+
crossref-tbl-title: "Tabla"
59+
crossref-fig-prefix: "fig."
60+
crossref-tbl-prefix: "tbl."
61+
---
62+
```
63+
64+
The same `language:` mechanism applies to callouts and to [custom cross-reference kinds](cross-references-custom.qmd).
65+
See [Cross-Reference Titles and Prefixes](language.qmd#cross-reference-titles-and-prefixes) for the full set of supported keys and the per-language subkeys pattern.
66+
4467
## Numbering
4568

4669
There are a variety of numbering schemes available for cross-references, including:

docs/authoring/cross-references-custom.qmd

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,37 @@ There are some additional options that give you more control over the appearance
6464

6565
You can find a complete listing of the options available for the `custom` key on the [Cross-Reference Options](/docs/reference/metadata/crossref.qmd#custom) reference page.
6666

67+
## Localisation
68+
69+
Custom cross-reference kinds inherit the same localisation pattern as built-in floats.
70+
A custom kind with `key: vid` is localised by setting `crossref-vid-title` and `crossref-vid-prefix` under `language:`:
71+
72+
``` yaml
73+
---
74+
lang: es
75+
language:
76+
crossref-vid-title: "Vídeo"
77+
crossref-vid-prefix: "Vídeo"
78+
crossref:
79+
custom:
80+
- kind: float
81+
reference-prefix: Video
82+
key: vid
83+
---
84+
```
85+
86+
The per-language subkeys form also works, which is useful when a single project is rendered in more than one language:
87+
88+
``` yaml
89+
language:
90+
es:
91+
crossref-vid-prefix: "Vídeo"
92+
fr:
93+
crossref-vid-prefix: "Vidéo"
94+
```
95+
96+
See [Cross-Reference Titles and Prefixes](language.qmd#cross-reference-titles-and-prefixes) for the full pattern.
97+
6798
## PDF Output
6899
69100
If your output format is `pdf` you'll also need to specify `latex-env`, a name to be used for the float environment wrapped around the element in the intermediate TeX. For example, to use the custom video reference type you could add `latex-env: video`:

docs/authoring/language.qmd

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,42 @@ fr:
112112
title-block-published: "Mis à jour"
113113
```
114114

115+
### Cross-Reference Titles and Prefixes
116+
117+
The same mechanism applies to cross-reference labels.
118+
Any key of the form `crossref-{type}-title` or `crossref-{type}-prefix` can be set under `language`, where `{type}` is a built-in float (`fig`, `tbl`, `lst`), a theorem environment (`thm`, `lem`, `cor`, `prp`, `cnj`, `def`, `exm`, `exr`), a callout (`nte`, `tip`, `wrn`, `imp`, `cau`), or a [custom cross-reference kind](cross-references-custom.qmd).
119+
120+
For floats and theorem environments, `crossref-{type}-prefix` falls back to `crossref-{type}-title` when omitted.
121+
122+
For example, to localise figure, table, and equation labels in a Spanish document:
123+
124+
``` yaml
125+
---
126+
title: "Mi Documento"
127+
lang: es
128+
language:
129+
crossref-fig-title: "Figura"
130+
crossref-tbl-title: "Tabla"
131+
crossref-eq-prefix: "Ecuación"
132+
---
133+
```
134+
135+
The pattern above also works for cross-reference keys:
136+
137+
``` yaml
138+
---
139+
title: "My Document"
140+
lang: es
141+
language:
142+
es:
143+
crossref-fig-title: "Figura"
144+
fr:
145+
crossref-fig-title: "Figure"
146+
---
147+
```
148+
149+
For per-document overrides that do not depend on `lang`, see [Cross-Reference Options](cross-reference-options.qmd).
150+
115151
## Custom Translations
116152

117153
You can create and use a custom translation for a new language not supported by Quarto as follows:

0 commit comments

Comments
 (0)