Closed vincentarelbundock closed 6 months ago
LaTeX does centering by default, so it would be nice to be consistent and center Typst tables by default too.
What's the appropriate syntax? Should go in here: https://github.com/vincentarelbundock/tinytable/blob/main/inst/templates/typst.typ
#align(center,
[
#let nhead = 1;
....
]
)
This would conflict with #250 though... there i replace out[1]
(#[
) with [
and prepend the rotate. If you switch to center aligned, I suppose you'd need to wrap the rotate in align instead. Or maybe there's a more elegant way (something along the lines of gsub("#", "#rotate(-90deg,\\n[", out[1])
)
Ultimately it would be something like this I suppose (for a rotated table)
#align(center,
rotate(-90deg, reflow: true,
[
#let nhead = 1;
...
]
)
)
or like this for a portrait one
#align(center,
[
#let nhead = 1;
...
]
)
Having written it like that, an easier solution for the rotated table presents itself, assuming you go with center aligned tables. If the template.typ file has a blank line in position 2, it could just be replaced with the rotate statement, and an extra closing bracket added to the end of the vector.
Shall I add it to #250 like that? Or do you want the alignment to be optional?
Thanks for the suggestion @aghaynes This was a good idea. Should be merged in Github dev version now.
This unfortunately doesnt seem to have worked... tables are still left aligned...
i think its interacting with the quarto stuff again... removing the tbl-cap and label seems to center align it... this is frustrating...
Weird. This works on my computer:
---
format: typst
---
```{r}
packageVersion("tinytable")
library(tinytable)
tt(iris[1:3, 1:3], caption = "blah blah blah")
#| tbl-cap: blah blah blah
#| label: tbl-blah
library(tinytable)
tt(iris[1:3, 1:3], caption = "blah blah blah")
![image](https://github.com/vincentarelbundock/tinytable/assets/987057/e0a9f79a-7323-4c05-a485-97e8e3f9cef3)
that does indeed work for me too... i'm sure i tested it like this though.
Maybe it's the template i'm using then... that same code within the template i'm using is left aligned... i'll investigate...
it's the echo option!
---
format: typst
execute:
echo: false
---
```{r}
packageVersion("tinytable")
library(tinytable)
tt(iris[1:3, 1:3], caption = "blah blah blah")
#| tbl-cap: blah blah blah
#| label: tbl-blah
library(tinytable)
tt(iris[1:3, 1:3], caption = "blah blah blah")
#| tbl-cap: blah blah blah
#| label: tbl-blah2
#| echo: true
library(tinytable)
tt(iris[1:3, 1:3], caption = "blah blah blah")
![image](https://github.com/vincentarelbundock/tinytable/assets/6594028/75ce36f9-dbdc-4972-a4f7-8f7bcafdc26d)
I have no idea why this would change things. Maybe you can inspect the raw .typ
file.
no idea why, but adding an empty r block into the .typ
does the trick (but it also add the grey box to the PDF)
#block[
```r
The only difference between the code for these two tables is that r block (it's copy/pasted .typ code, not recompiled through knitr, only typst)
![image](https://github.com/vincentarelbundock/tinytable/assets/6594028/0e68b040-0e49-4837-a293-1592ae0326c2)
Originally posted by @aghaynes in https://github.com/vincentarelbundock/tinytable/issues/247#issuecomment-2115098640