Support for Typst (as .typ and Quarto's typst-pdf)#2137
Open
christopherkenny wants to merge 33 commits intorstudio:masterfrom
Open
Support for Typst (as .typ and Quarto's typst-pdf)#2137christopherkenny wants to merge 33 commits intorstudio:masterfrom
.typ and Quarto's typst-pdf)#2137christopherkenny wants to merge 33 commits intorstudio:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds full support for Typst-based tables, for both direct
.typoutputs and for use in Quarto. Each feature is carefully designed to mimic the code style and heavy function use throughout the existing export types, particularly LaTeX, as the closest export engine.I had planned to make a relatively minor PR a few weeks back, but I realized that this is best as a complete PR rather than a partially working one. So, my apologies for the very large PR.
It covers: normal table semantics, coloring, complete text styling (from font to color to stretch), lifting strokes to the column- or row- or table-level, lifting fill colors, exporting labels, etc. Tables can be saved to
.typand directly rendered.gt_group()is supported. It is tested for both raw Typst outputs and in Quarto.Several features of this PR required some decision making, so below are the most important ones:
stacked to keep them together.as_typst()allows for these to be configured, auto-detects if not supplied, and warns if a table is selected for something that would require a figure.as_typst(). These work natively for Typst and don't require the ever-problematic long tables. Ifbreakableis not set, then no Typstshowrule is emitted, defaulting to the existing rules.text()call, since these are unified in Typst. This introduces a few paste0(..., collapse = ', ') that are not strictly necessary, but gives much more readable outputs.For the overall style of the tables, I aimed to match existing exports, rather than Typst's defaults. The default table styling in Typst is a white, blank table with aligned text. I match LaTeX-for-gt's minimalistic styling here, with simple lines at the top of the table, bottom of the table, and below the header.
The main feature not implemented here is support for
frac-style widths. These are very convenient ways to mix explicit widths and remainder fractions, but aren't necessary (though useful) and require making policy decisions for working withpx,pct, etc in types without a correspondingfracidea, likertf. I'm happy to do a follow-up with what I would expect this to look like, but the whole PR was getting big enough and this is nice-to-have-but-not-necessary.Example Tables
Simple
Code
Complex
Code
Related GitHub Issues and PRs
as_typst()function to support styled tables intypstQuarto output format #1500 withas_typst()additionChecklist
testthatunit tests totests/testthatfor any new functionality.