I’m rendering a Quarto document to HTML which contains a code chuck that generates more than 26 figures, to which I’m adding subcaptions. Quarto uses letters to sub-caption figures. In the English language, we only have 26 letters, so the 27th figure subcaption continues with the next ASCII character which is {
. How do I label the 27th figure subcaption with aa
, then bb
, etc?
Below is the last row of charts. Notice the figure on the right is captioned ({) Fig-aa
and I’d like that to be (aa) Fig-aa
. :
Code:
---
title: "27Figures"
format: html
---
Figure @fig-charts shows 27 subfigures.
```{r}
#| label: fig-charts
#| fig-cap: "Charts"
#| layout-ncol: 3
#| fig-subcap:
#| - "Fig-a"
#| - "Fig-b"
#| - "Fig-c"
#| - "Fig-d"
#| - "Fig-e"
#| - "Fig-f"
#| - "Fig-g"
#| - "Fig-h"
#| - "Fig-i"
#| - "Fig-j"
#| - "Fig-k"
#| - "Fig-l"
#| - "Fig-m"
#| - "Fig-n"
#| - "Fig-o"
#| - "Fig-p"
#| - "Fig-q"
#| - "Fig-r"
#| - "Fig-s"
#| - "Fig-t"
#| - "Fig-u"
#| - "Fig-v"
#| - "Fig-w"
#| - "Fig-x"
#| - "Fig-y"
#| - "Fig-z"
#| - "Fig-aa"
for (i in 1:27) {
plot(i, i)
}
```
1
Answers
Add a JavaScript function that runs after the document loads that finds all subfigure captions using the class quarto-subfloat-caption and for captions beyond the 26th figure (index >= 26):
So:
Figure 27 will show as
"(aa) Fig-aa"
Figure 28 will show as
"(bb) Fig-bb"
As you can see, that works for more than 26 plots: