vincentarelbundock / tinytable

Simple and Customizable Tables in `R`
https://vincentarelbundock.github.io/tinytable
GNU General Public License v3.0
210 stars 18 forks source link

across-table effects in style_tt using Quarto plus typst #385

Open haokaitseng opened 3 hours ago

haokaitseng commented 3 hours ago

Dear developer of tiny table,

With the help and support of tinytable package, I am using Quarto for rendering a typst pdf output. My question is, when I style_tt() a table in a r chunk, this styling effect will affecting all the irrelevant tables in other r chunks. The styling effect includes bold, color, align, font size.

for example in R chunk A I have:

table_a |> tt(width=c(2.5,1,1,1,1,1) )|> group_tt(i = list("Vaccines used in routine immunisation" = 1, "Routine immunisation" = 4))|> #! grouped table dat_jrf|>filter(iso3==current_iso3)|>select(Item) style_tt( i = 0, #header color = "white", background = "#005CB9", align = "c" )|> style_tt( i=c(2,3,4,6,7,8), align = "c" )|> style_tt( i=c(1,5), j=1, #subgroup align = "l", background = "#ededed", bold = TRUE )|> style_tt( i=c(1:8), j=1, align = "l" )|> style_tt( i = c(0, 1), line = "t", line_color = "white" )|> style_tt( i = 8 , #bottom line line = "b", line_color = "white" )|> format_tt(replace = "-", escape=TRUE)

the output is below, your can see subgroup titles are correctly bold image

in R chunk B i have :

table_b |> tt(theme = "striped", width=1 )|> style_tt( i = 0, #header color = "white", background = "#005CB9", align = "c")|> style_tt(

i = c(0:20),

align = "c"#,
#fontsize = 0.9
)|># text centred for all rows

style_tt( i = c(0,1), line = "t", #top line line_color = "white" )|> style_tt( i = dat_launch |> filter(iso3 == current_iso3) |> nrow(), line = "b", #bottom line line_color = "white", line_width = 0.1 )

And you can see the output of table B is affected by the bold font and also somehow skewed alignment.

image

I have tried to remove my typst template, purely using format: typst in YAML, which couldn't solve this problem.

Ideally I also want to adjust font sizes, which will be crazily catastrophic if this across-table effect is still in place. I need the format and style of the table be independent within the table itself. Any thoughts will be much appreciated! Thanks for your time.

best, Kai

vincentarelbundock commented 3 hours ago

I have completely re-written Typst support for the next version. Can you please try the development version of tinytable from github?

Install:

remotes::install_github("vincentarelbundock/tinytable")

Restart R competely.

Then try again.

vincentarelbundock commented 3 hours ago

If that doesn't work, please supply a MINIMAL and FULLY REPRODUCIBLE example.

Here are some tips on asking "good" questions about software: https://marginaleffects.com/bonus/help.html#getting-help