More feature-complete export of tables: table.header(), table.hline(), and align()#50
More feature-complete export of tables: table.header(), table.hline(), and align()#50andersjohansson wants to merge 2 commits into
Conversation
table.header() is best practice in Typst for styling and accessibility This uses org-export heuristics for determining rows that should go in the header. It also prints explicit table rules as table.hline(), but not the rule at the bottom of the header and at the bottom of the table (it is assumed that the user can use a default style for this). Inspiration for this still simplified implementation from ox-html and ox-latex.
|
I realize that tests should be updated if this is added. By the way, my assumption that the user can style strokes appropriately is based on me hacking away on a standard style for “academic” tables (like booktabs in latex): //Academic strokes:
#set table(stroke: (_, y) =>
( top: if y==0 { 1pt } else if y==1 {0.5pt} else { 0pt },
bottom: 1pt
))
#set table.hline(stroke: .5pt)But this actually doesn’t put a (thin) line below “the header”, just below the first row of the table. I am unsure if the header can be addressed directly. https://typst.app/docs/guides/tables/ See also: https://typst.app/universe/package/akatable, which creates the new function |
|
I also realized it would be reasonable to set alignment based on the heuristics or explicit settings (alignment cookies, a row with ‘’, ‘’ or ‘’ for the columns) of org-mode. I was inspired by how this is done in ox-html, where there is an option to set alignment per cell, which could possibly also be used for typst. I didn’t take that path here. This is a quick implementation that “works on my file”, but the design needs to be considered, and tests written. |
|
Sorry for taking so long to come back to you. I wonder what the use-cases are here. I think the first part which adds the table.header is fine and we should do that. But I am not sure if got the second part correctly. You want to use academic styled tables. So you applied this fix and you are using a custom style to archive that? The last part with the table alignment seems also fine. The academic-table package seems to have a very similar style for their input as the current implementation. I wonder if we can have a feature flag which allows the user to use the different table exports. I guess that similar to what LaTeX does with their tables (as you mentioned with the longtabu, etc.). |
table.header() is best practice in Typst for styling and accessibility
This uses org-export heuristics for determining rows that should go in
the header.
It also prints explicit table rules as table.hline(), but not the rule
at the bottom of the header and at the bottom of the table (it is
assumed that the user can use a default style for this).
Inspiration for this still simplified implementation from ox-html and ox-latex.