Maël
Maël

Reputation: 52329

Side-by-side caption positions of figure and table

In Quarto, it is possible to display a figure and a table side by side with layout-ncol. Theoretically, we should be able to use cap-location: "bottom" to set all captions to bottom, but it is not the case here. Is there a way to set all captions to bottom, including when using both table and figure?

Minimal example:

---
title: "sidebyside"
format: pdf
editor: visual
---

```{r}
#| layout-ncol: 2
#| layout-valign: bottom
#| cap-location: bottom
#| fig-cap: "A plot"
#| tbl-cap: "A table"

library(knitr)

# plot on the left
plot(cars)

# table on the right
kable(head(cars))
```

Output:

enter image description here

The expected output would have both captions in the bottom and no additional "A plot".

Upvotes: 3

Views: 2124

Answers (1)

Carlos Scheidegger
Carlos Scheidegger

Reputation: 1966

(quarto dev here) The only way to make this work presently is to set the caption location document-wide in the front matter. Our documentation is currently misleading wrt this, we will be fixing it very soon.

So, what you want is:

---
title: "sidebyside"
format: 
  pdf:
    cap-location: bottom
editor: visual
---

```{r}
#| layout-ncol: 2
#| layout-valign: bottom
#| fig-cap: "A plot"
#| tbl-cap: "A table"

library(knitr)

# plot on the left
plot(cars)

# table on the right
kable(head(cars))
```

This doesn't fix the multiple-captions "A plot" problem, though. That's a different bug. (The path of mixing figure and table captions is clearly not well exercised enough; we'll fix that too!)

Upvotes: 5

Related Questions