Created
June 7, 2024 16:04
-
-
Save cderv/8b0f83f14de38d77cf0d2ec433c4f69f to your computer and use it in GitHub Desktop.
quarto longtable testing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
format: latex | |
keep-tex: true | |
title: "Long Table kable fixups etc" | |
_quarto: | |
tests: | |
latex: | |
ensureFileRegexMatches: | |
- | |
- "\\label{tbl-test}" | |
- [] | |
--- | |
## Raw longtable table with no crossref and caption from kable function | |
In this case we'll issue a warning about of the type | |
```` | |
Raw LaTeX table found with non-tbl label: tab:not-tbl | |
Won't be able to cross-reference this table using Quarto's native crossref system. | |
```` | |
```{r} | |
#| label: not-tbl | |
#| echo: false | |
df <- tibble::tibble( | |
x = 1:20, | |
y = rnorm(20), | |
z = rnorm(20) | |
) | |
knitr::kable(df, | |
format = "latex", | |
longtable = TRUE, | |
booktabs = TRUE, | |
caption = "A long table with a caption") | |
``` | |
## Raw longtable table with no crossref and no caption | |
In this case, Quarto will transform to longtable* to remove numbering | |
```{r} | |
#| echo: false | |
df <- tibble::tibble( | |
x = 1:20, | |
y = rnorm(20), | |
z = rnorm(20) | |
) | |
knitr::kable(df, | |
format = "latex", | |
longtable = TRUE, | |
booktabs = TRUE) | |
``` | |
## Raw longtable table with crossref and caption from kable function | |
```{r} | |
#| label: tbl-test | |
#| echo: false | |
df <- tibble::tibble( | |
x = 1:20, | |
y = rnorm(20), | |
z = rnorm(20) | |
) | |
knitr::kable(df, | |
format = "latex", | |
longtable = TRUE, | |
booktabs = TRUE, | |
caption = "A long table with a caption") | |
``` | |
See @tbl-test. | |
## Complex longtable table with caption and no crossref | |
```{r} | |
library(kableExtra) | |
``` | |
```{r} | |
#| tbl-cap: "This table is fine but not cross-referenceable" | |
rbind(mtcars, mtcars) |> | |
kbl(longtable = TRUE, booktabs = TRUE) |> | |
kable_styling() | |
``` | |
## Complex longtable with caption and crossref | |
```{r} | |
#| label: tbl-test2 | |
#| tbl-cap: "This table is cross-referenceable" | |
rbind(mtcars, mtcars) |> | |
kbl(longtable = TRUE, booktabs = TRUE) |> | |
kable_styling() | |
``` | |
See @tbl-test2 | |
## Complex longtable with no caption and crossref from a div label | |
::: {#tbl-test3} | |
```{r} | |
rbind(mtcars, mtcars) |> | |
kbl(longtable = TRUE, booktabs = TRUE) |> | |
kable_styling() | |
``` | |
This table is also cross-referenceable | |
::: | |
See @tbl-test3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment