Closed vincentarelbundock closed 1 month ago
I am not sure if this is along the same lines. I am making use of a quarto to render typst tables and was trying your example form the tutorial
dat <- mtcars[1:9, 1:8]
tt(dat) |>
group_tt(
i = list("I like (fake) hamburgers" = 3,
"She prefers halloumi" = 4,
"They love tofu" = 7),
j = list("Hamburgers" = 1:3,
"Halloumi" = 4:5,
"Tofu" = 7)) |>
style_tt(
i = c(3, 5, 9),
align = "c",
background = "teal",
color = "white") |>
style_tt(i = -1, color = "teal")
When it creates the PDF, the output looks very different to your web version.
There could be some template interactions here. If you have any tips that I can use to help debug/diagnose I'd be more than happy to help improve this.
Thanks for the nudge @danwwilson ! Yep, that looks like exactly the same issue.
My guess is that the solution is to fix the row indices used in a few places in this file:
https://github.com/vincentarelbundock/tinytable/blob/main/R/style_typst.R
I actually don't expect this to be hard to fix---the code is pretty straightforward--- but in my brief attempt I couldn't quite get all the combinations working. The horizontal lines or group indentation would get shifted, for example.
Again, shouldn't be too hard, but I just have not found the time to look at this seriously yet. If you take a look and find something, that would be super useful!
I think the issue is that the group rows are off when columns are also grouped — in the screenshot, the formatting is in the correct row number, but the group label rows are one lower than they ought to be. Without the j
argument in the group, I was getting correct(ish) results.
It doesn't seem like nhead should be in the offset for the body of the typst table?
So I submitted a PR where I changed x@nhead
to 1
, but not sure if this might cause breakage in other scenarios.
Also I'm not sure this is limited to Typst — had similar issues with latex output.
Thanks all. This should now be fixed in the main
branch on Github. The fix will be part of the next CRAN release, coming in the coming weeks.
Lots of bugs in variations of this. Try groups with black background and orange text.