I am trying to explore the utility of quarto
and typst
for PDF output from R.
Unfortunately, I am unable to find in the documentation how to control the font size of the figure captions. When rendering the Quarto document, the figure caption appears to have the same font size than the normal body text.
On top of that, it appears that the cross-referencing of the figure captions to include the chapter, e.g. Figure 5.1 ..., does not react to the the YAML crossref: chapters: true
.
The font size of figure captions could be adjusted by applying a custom show rule like this:
#show figure.caption: set text(size: 18pt)
Regarding the crossref: chapters: true
it seems to be a little bit more complex because, as you stated, with format: typst
Quarto does not seem to react and additionally, Typst currently has no built-in feature for this need (see e.g. typst/typst#1896 for more details). However, a solution as indicated in this comment should be applicable:
#set figure(numbering: num => {
locate(loc => {
let chap_num = counter(heading.where(level: 1)).at(loc).first()
let chap_loc = query(heading.where(level: 1).before(loc)).last().location()
let fig_offset = counter(figure).at(chap_loc).first()
str(chap_num) + "." + str(num - fig_offset)
})
})
---
title: Figure caption font size and numbering in Quarto Typst
format:
typst:
include-before-body:
- text: |
#set heading(numbering: "1")
#show figure.caption: set text(size: 18pt)
#set figure(numbering: num => {
locate(loc => {
let chap_num = counter(heading.where(level: 1)).at(loc).first()
let chap_loc = query(heading.where(level: 1).before(loc)).last().location()
let fig_offset = counter(figure).at(chap_loc).first()
str(chap_num) + "." + str(num - fig_offset)
})
})
---
# First chapter
# Second chapter
{#fig-elephant1 width=40%}
See @fig-elephant1 for an illustration.