Skip to content

tbl-subcap with LaTeX tables #10328

@cscheid

Description

@cscheid

Minimal repro from keep-md: true:

---
format: pdf
keep-tex: true
---

::: {#tbl-example .cell layout-ncol="2" tbl-cap='Example' tbl-subcap='["Cars","Pressure"]'}

```{.r .cell-code}
library(tinytable)
tt(head(cars)) |> theme_tt("tabular") |> 
  save_tt("latex") |> knitr::asis_output()
```

::: {.cell-output-display}
```{=latex}
\begin{tabular}{ll}
\hline
speed & dist \\ \hline
4 &  2 \\
4 & 10 \\
7 &  4 \\
7 & 22 \\
8 & 16 \\
9 & 10 \\
\hline
\end{tabular}
```
:::

```{.r .cell-code}
tt(head(pressure)) |> theme_tt("tabular")  |> 
  save_tt("latex") |> knitr::asis_output()
```

::: {.cell-output-display}
```{=latex}
\begin{tabular}{ll}
\hline
temperature & pressure \\ \hline
0 & 0.0002 \\
20 & 0.0012 \\
40 & 0.0060 \\
60 & 0.0300 \\
80 & 0.0900 \\
100 & 0.2700 \\
\hline
\end{tabular}
```
:::
:::

Discussed in #10324

Originally posted by vincentarelbundock July 18, 2024

Description

Hi,

Thanks for all your work on Quarto and on this forum!

When a package produces markdown tables, the tbl-subcap functionality works as expected. However, when the package produces a LaTeX table, there is no subcaption.

Is it possible for Quarto to support subcaptions in LaTeX tables as well?

I'd love to get some clarification on this.

  1. Are subcaptions only supported for markdown tables?
  2. Are there plans to extend support for LaTeX tables as well?

Thanks!

---
format: pdf
---

```{r}
#| label: tbl-example
#| tbl-cap: "Example"
#| tbl-subcap: 
#|   - "Cars"
#|   - "Pressure"
#| layout-ncol: 2

library(tinytable)
tt(head(cars)) |> save_tt("markdown") |> knitr::asis_output()
tt(head(pressure)) |> save_tt("markdown") |> knitr::asis_output()
```

This doesn't work:

library(tinytable)
tt(head(cars)) |> save_tt("latex") |> knitr::asis_output()
tt(head(pressure)) |> save_tt("latex") |> knitr::asis_output()
```</div>

Metadata

Metadata

Assignees

Labels

crossrefenhancementNew feature or requesttablesIssues with Tables including the gt integration

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions