Closed aghaynes closed 4 months ago
Thanks for giving this a shot, I appreciate it!
Unfortunately, I'm not sure that's going to work for every use-case. The Typst case is a bit more complicated because there are two main cases:
tinytable
encloses the table in a #figure
environment.#| label: tbl-blahblah
chunk option: tinytable
removes the #figure()
environment.So we can't just add something at the start of the template, because the start sometimes gets removed when Quarto takes over.
A less committal way to do this would be to add a theme_tt("rotate")
option. Themes are nice, because they don't need to work in every format. They can also be thought of as a "sandbox" where we can implement features that eventually "graduate" to a full-fledged argument. We can also have theme-specific arguments like the degrees, which would allow users to control the orientation of landscape.
In this PR, I implemented minimal support: https://github.com/vincentarelbundock/tinytable/pull/251
There are still problems with my approach, there, as you can see in the screenshot.
I'm not sure if/when I'll have time to work on this more, but perhaps that gives you something to play with if you want to.
Under what circumstances do you think it wont work? It seems to work fine for the two cases you mentioned... same with label and captions individually...
```{r}
#| label: tbl-tt
#| tbl-cap: A tinytable object
mtcars[, 1:3] |> head() |> tinytable::tt(landscape = TRUE)
mtcars[, 1:3] |> head() |> tinytable::tt(landscape = TRUE)
![image](https://github.com/vincentarelbundock/tinytable/assets/6594028/5c2b7c4a-fd8d-469d-bd2a-e5753147e96f)
(I dont have a major issue with the theme approach either to be honest - it's similar to the concepts in gt, gtsummary, etc, so if you'd prefer to go down that route...)
Well, in landscape the label needs to be rotated as well. Otherwise you have to flip the page twice...
Haha... indeed... For that I assume the rotate command would have to go around the whole figure block that quarto applies...
#figure([
#block[
#rotate(-90deg, reflow: true,
[
#let nhead = 1;
would need to be
#rotate(-90deg,
figure([
#block[
#rotate(-90deg, reflow: true,
[
#let nhead = 1;
Could that be handled by the theme method?
That's precisely the problem. In Quarto documents, Quarto automatically wraps the whole content that tinytable
produces in its own #figure
environment. That happens after tinytable
is done working, so we no longer have control over anything at that stage, so we can't wrap Quarto's figure in a #rotate
Then i'll post a question/request at quarto for it...
Then i'll post a question/request at quarto for it...
Good idea. But try not to introduce tinytable
into your question. Better to make it a truly minimal example, and ask how to landscape a Typst figure in Quarto, generally.
lua filters are the answer... this discussion includes one... https://github.com/quarto-dev/quarto-cli/discussions/9705
This is very cool, but it appears to kill the Quarto tbl-cap
caption.
Also, maybe it sets text in the middle too? not sure
I've not tried it out yet. Had to head off.
Looks like they're considering adding it as a quarto feature even!
this also works by putting raw typst cells before and after the table producing code, so I propose we close this PR (and possibly also #251) without merging...
```{=typst}
#rotate(-90deg, reflow: true, [
#| tbl-cap: blah blah blah
#| label: tbl-base
head(mtcars) |> tinytable::tt()
])
Ah thanks, that's useful. I'll close this one but keep the other one open. It might sitll be useful for LaTex...
related to #249
Rather than going for full rotational support (i.e. user defined angles, which is doable in typst), I opted for landscape (-90 degree rotation)
The latex implementation is untested (I think I may even have broken my tex installation in trying to install tabularray :( ). Can you try it, @vincentarelbundock?
Users will probably have to add either lscape and/or pdflscape to their headers (I dont remember which and I'm not sure if/how you handle it with tabularray):