Search code examples
pdflatexr-markdownquarto

Quarto: PDF Document - Figure Caption size


How to customize font size of Figure Caption in a quarto pdf document? I have checked about the mainfont and fontfamily options, but the documentation doesn't provide examples of how to use change the font size for individual elements in a pdf document.


Solution

  • Since for pdf output, ultimately latex is used, you just need to find the corresponding latex solution to do what you want to do and incorporate those latex codes using LaTex Includes.

    So to change the figure caption size, we can use the caption package. From section 2.3 of the caption package manual,

    There are three font options which affect different parts of the caption: One affecting the whole caption (font), one which only affects the caption label and separator (labelfont) and at least one which only affects the caption text (textfont).

    You set them up using the options font={⟨font options⟩}, labelfont={⟨font options⟩}, and textfont={⟨font options⟩}, where ⟨font options⟩ is a list of comma separated font options.

    And these are the available font options:

    • scriptsize => Very small size
    • footnotesize => The size usually used for footnotes
    • small => Small size
    • normalsize => Normal size
    • large => Large size
    • Large => Even larger size

    Read the manual (section 2.3) to know the details and more options.


    ---
    title: "Figure Caption Size"
    format: 
      pdf:
        include-in-header:
          text: |
           \usepackage[font=Large,labelfont={bf,Large}]{caption}
    ---
    
    ## Quarto
    
    ```{r}
    #| fig-cap: "Just a scatterplot"
    
    plot(rnorm(1:10), rnorm(1:10))
    ```
    

    Large caption for figure in Quarto