Closed MarcoPortmann closed 6 months ago
The problem is that when you use the tbl-cap
tag in Quarto, it will wrap the table in a floating LaTeX environment , which pushes it down and looks weird.
So for long tables, you cannot use that and must use the caption
argument instead, possibly including a \\label{}
call directly in there.
Unfortunately, when supporting so many different output formats, it's hard to be 100% consistent. But I already plan to at least document this better in the future. Follow progress here: https://github.com/vincentarelbundock/tinytable/issues/208
I could cope with this inconsistency. However, it seems that crossref doesn't work that way:
---
title: "Quarto Document"
format: pdf
---
```{r include=FALSE}
library(tidyverse)
library(tinytable)
This is @tbl-test.
rbind(mtcars, mtcars) %>%
tt(caption = "Hello world\\label{tbl-test}") %>%
theme_tt(theme = "multipage", rowhead = 1)
![image](https://github.com/vincentarelbundock/tinytable/assets/7468121/1298abd1-0732-4ac5-a9bb-047f15011403)
What does the raw latex file look like? Maybe Quarto tweaks the labels automatically?
The \label{tbl-test}
seems fine to me.
This is \textbf{?@tbl-test}.
\begin{longtblr}[ %% tabularray outer open
caption={Hello world\label{tbl-test}},
] %% tabularray outer close
{ %% tabularray inner open
colspec={Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]Q[]},
rowhead=1,
} %% tabularray inner close
\toprule
My guess is Quarto will only recognize the @ syntax if it handles everything, including the label chunk option.
You might have to use \ref{} in the text, although this won't be cross platform.
This is one of the problems of using quarto, which is a layer on top of pandoc, a layer on top of latex, a layer on top of tex...
Circling back to this to note that I've exchanged with Quarto developers, and have learned that the problem is that Quarto automatically wraps tables in an floating table environment, which causes a conflict with tabularray
's longtblr
environment.
Unfortunately, there is nothing I can do about this multipage problem, since there's currently no way to disable that Quarto feature.
I filed a feature request, but don't know if it will be implemented upstream.
In the meantime, a workaround is to work with pure LaTeX labels, as is now documented in the vignette.
tt(rbind(mtcars, mtcars), caption = "Example table.") |>
style_tt(tabularray_outer = "label={tbl-ex-multipage}") |>
theme_tt("multipage")
And then refer to tables with \ref{tbl-ex-multipage}
as any other LaTeX reference.
Thanks again for raising this issue.
The following example creates a multi-page table. However, the continuation of the table starts directly after the first table instead of starting on a new page, and the continuation extends beyond the margin.
This is @tbl-test.