Quarto/RMarkdown to PDF: How to increase margin between subcaptions of tables?

Viewed 153

Using Quarto/RMarkdown I export a PDF that includes a code chunk that produces two tables incl. subcaps.

How can I increase the margin of the lower subcap to the upper table?

My code:

#| label: tbl-1985
#| tbl-cap: "*Was Wann Wo* im Jahr 1985"
#| tbl-subcap: 
#|   - "Auswertung nach Kategorien"
#|   - "Besonderheiten"
#| layout-nrow: 2
#| fig-pos: 'H'

# table 1
df_table_1 %>% 
    knitr::kable(., caption = paste0("\\textit{Was Wann Wo} im Jahr ", year)) %>%
    kableExtra::kable_styling(latex_options = "scale_down")

# table 2
df_table_2 %>% 
    knitr::kable(., caption = paste0("Besonderheiten im Jahr ", year)) %>% 
    kableExtra::column_spec(2, width = "12cm")

enter image description here

1 Answers

One option could be using layout option to create some vertical space between the two table. As per the Quarto documentation on complex layout,

The layout attribute is a 2-dimensional array where the first dimension defines rows and the second columns. In this case layout="[[1,1], [1]]" translates to: create two rows, the first of which has two columns of equal size and the second of which has a single column.

You can also use negative values to create space between elements.

---
format: pdf
execute: 
  echo: false
---


```{r}
#| label: data

df_table_1 <- head(mtcars, 15)
```


```{r}
#| label: tbl-1985
#| tbl-cap: "*Was Wann Wo* im Jahr 1985"
#| tbl-subcap: 
#|   - "Auswertung nach Kategorien"
#|   - "Besonderheiten"
#| layout: "[[1], [-1], [1]]"
#| fig-pos: 'H'

# table 1
knitr::kable(df_table_1)

# table 2
knitr::kable(df_table_1)
```

vertical space between tables.


Related