yihui / knitr

A general-purpose tool for dynamic report generation in R
https://yihui.org/knitr/
2.36k stars 873 forks source link

table output for typst #2328

Closed aghaynes closed 4 months ago

aghaynes commented 4 months ago

Quarto has recently introduced support for the typst format. The output of tables is pretty basic currently

image

(gt tables look basically the same)

It would be great to have the same output options for typst as for other formats (if at all possible)

I asked on quarto, but apparently it's rather something for here (and/or gt)... maybe also kableExtra?


By filing an issue to this repo, I promise that

I understand that my issue may be closed if I don't fulfill my promises.

cderv commented 4 months ago

Current table conversion to typst in Quarto or R Markdown will be done from a Markdown Table to Typst syntax through Pandoc.

Tools like gt, kableExtra or flextable usually have more customisation options as they do the work of writing the raw output directly.

This allow them to provide some advanced customisation options based on the feature of each language and tools used.

I don't know any R table package that does yet handle raw typst output but this seems feasible following typst doc (https://typst.app/docs/reference/model/table/)

I would agree this should be done in either one of the Table dedicated existing package, or in a new package for typst output.

See for example existing

Not sure we want to add a new format raw format to knitr::kable() - I let @yihui give his thought on that.

aghaynes commented 4 months ago

thanks @cderv. Just a few minutes ago, I came across the tinytable package which does provide some support for typst tables... nicer than the default... it's a start... image

cderv commented 4 months ago

Nice thanks for sharing. They even use a specific package call tablex (https://github.com/PgBiel/typst-tablex)

I saw that in the template they use: https://github.com/vincentarelbundock/tinytable/blob/main/inst/templates/typst.typ

cderv commented 4 months ago

And I see now we also have an issue about integrated with this in the future.

So Quarto table output for Typst could definitely improve in the future!

aghaynes commented 4 months ago

i've been playing this afternoon...

Tables do indeed work through tinytable. What doesn't work is breaking long tables into multiple pieces.

Part of that is down to tinytable, and i've explained to them what would need changing (although maybe they have reasons for the present implementation).

Part of it also seems (to me) to be down to pandoc. It looks to me that it wraps the output from any typst cells in a "block". This seems to stop tablex from repeating table headers across pages, which is a shame.

https://github.com/vincentarelbundock/tinytable/issues/154

yihui commented 4 months ago

Not sure we want to add a new format raw format to knitr::kable() - I let @yihui give his thought on that.

Given that it seems tinytable has already done a great job, I don't think it's worth reinventing it in knitr::kable(). Thanks for the suggestion, though!

aghaynes commented 4 months ago

Thats fair enough. Thanks for thinking about it.

sda030 commented 3 months ago

Updates to Typst's included table formatting on the way: https://staging.typst.app/docs/changelog