quarto - How to control the font size of figure captions and include chapter notation? - Stack Overflow

I am trying to explore the utility of quarto and typst for PDF output from R.Unfortunately, I am unabl

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.

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.

Share Improve this question edited Mar 24 at 20:52 M-- 29.5k10 gold badges69 silver badges106 bronze badges asked Mar 24 at 20:09 RayRay 2,30017 silver badges23 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

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

![Figure caption with custom font size](elephant.png){#fig-elephant1 width=40%}

See @fig-elephant1 for an illustration.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744230089a4564203.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信