Skip to content

Table number does not appear when using a single table inside a div element. #3931

@magnusnosnes

Description

@magnusnosnes

Hi,

Is there a way to obtain a numbered table caption above a single table using div elements: ":::"?

According to the documentation at tables one can use div elements around multiple tables to get a a numbered table with the caption above using this code:

For example, this code:

::: {#tbl-panel layout-ncol=2}
| Col1 | Col2 | Col3 |
|------|------|------|
| A    | B    | C    |
| E    | F    | G    |
| A    | G    | G    |

: First Table {#tbl-first}

| Col1 | Col2 | Col3 |
|------|------|------|
| A    | B    | C    |
| E    | F    | G    |
| A    | G    | G    |

: Second Table {#tbl-second}

Main Caption
:::

will give a numbered table with caption above as I want. But when using a single table, the table number is not displayed, like this code:

::: {#tbl-panel}

| Col1 | Col2 | Col3 |
|------|------|------|
| A    | B    | C    |
| E    | F    | G    |
| A    | G    | G    |

Main Caption
:::

I am trying to use this as a workaround to get numbered table caption above my datatable produced using R. In the following code, I would like the table caption to be numbered according to the order it appears in the document (relative to other tables), and appear above the datatable.

::: {#tbl-panel}

```{r}
library(DT)
datatable(my_interactive_table)
```

My table caption that should give the table number and appear above the table.
:::

Thank you for your time and help,
Magnus Nygård Osnes

Metadata

Metadata

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