Search code examples
rquarto

How can i place the figure caption next to the figure in quarto pdf format?


How can I use side captions in Quarto PDF?

Will fig-cap-location: margin give me the desired result in pdf format? I have tried putting it the header but this will be applied to all figures, however, I would like to specify it for each figure separately.


Solution

  • Instead of using the quarto or latex syntax, use knitr to include the picture and put the cap-location argument in the chunk options like this:

    ```{r}
    #| echo: false
    #| fig-cap: My Picture
    #| cap-location: margin
    
    knitr::include_graphics("path/to/picture")
    ```
    

    Edit (10/14/2023)

    The problem we are running into is that LaTeX/Quarto is reserving space specifically for the margin across the document. So we need to convince our text to specifically infringe into the margin. This is definitely a hack solution (and not super convenient), but it is an option.

    ---
    format: pdf
    ---
    
    :::{.column-screen-inset-right}
    
    This is some text to span across the page in order to see how the margins change in relation to the other text.
    
    :::
    
    ```{r}
    #| echo: false
    #| fig-cap: My Picture
    #| cap-location: margin
    
    knitr::include_graphics("path/to/picture")
    ```
    
    :::{.column-screen-inset-right}
    
    This is some more text to span across the page in order to see how the margins change in relation to the other text.
    
    :::