summaryrefslogtreecommitdiff
path: root/test/tables
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2024-03-20 14:25:08 -0700
committerGitHub <noreply@github.com>2024-03-20 14:25:08 -0700
commit604f541b0ff2e521ba207991baf43c9550189736 (patch)
treebbeece4e30227df45e206008be89072beae9dc94 /test/tables
parentebcae86cf47e3037ccc3c7146cf610e5a7af3b03 (diff)
Typst writer: support Typst 0.11 table features. (#9593)
* Typst writer: support Typst 0.11 table features. - colspans - rowspans - cell alignment overrides - relative column widths - header and footer - multiple table bodies with intermediate headers Row heads are not yet supported. The default typst template has been modified so that tables don't have lines by default. As is standard with pandoc, we only add a line under a header or over a footer. However, a different default stroke pattern can easily be added in a template. Closes #9588.
Diffstat (limited to 'test/tables')
-rw-r--r--test/tables/nordics.typst23
-rw-r--r--test/tables/planets.typst33
-rw-r--r--test/tables/students.typst26
3 files changed, 82 insertions, 0 deletions
diff --git a/test/tables/nordics.typst b/test/tables/nordics.typst
new file mode 100644
index 000000000..322d19845
--- /dev/null
+++ b/test/tables/nordics.typst
@@ -0,0 +1,23 @@
+#figure(
+ align(center)[#table(
+ columns: (30%, 30%, 20%, 20%),
+ align: (center,left,left,left,),
+ table.header(table.cell(align: center)[Name], table.cell(align: center)[Capital], table.cell(align: center)[Population
+ \
+ (in 2018)], table.cell(align: center)[Area \
+ (in km#super[2];)],),
+ table.hline(),
+ [Denmark], [Copenhagen], [5,809,502], [43,094],
+ [Finland], [Helsinki], [5,537,364], [338,145],
+ [Iceland], [Reykjavik], [343,518], [103,000],
+ [Norway], [Oslo], [5,372,191], [323,802],
+ [Sweden], [Stockholm], [10,313,447], [450,295],
+ table.hline(),
+ table.footer([Total], [], [27,376,022], [1,258,336],),
+ )]
+ , caption: [States belonging to the #emph[Nordics.]
+
+ ]
+ , kind: table
+ )
+<nordics>
diff --git a/test/tables/planets.typst b/test/tables/planets.typst
new file mode 100644
index 000000000..1d80ae88b
--- /dev/null
+++ b/test/tables/planets.typst
@@ -0,0 +1,33 @@
+#figure(
+ align(center)[#table(
+ columns: 12,
+ align: (center,center,auto,right,right,right,right,right,right,right,right,auto,),
+ table.header(table.cell(colspan: 2)[], [Name], [Mass (10^24kg)], [Diameter
+ (km)], [Density (kg/m^3)], [Gravity (m/s^2)], [Length of day
+ (hours)], [Distance from Sun (10^6km)], [Mean temperature (C)], [Number of
+ moons], [Notes],),
+ table.hline(),
+ table.cell(rowspan: 4, colspan: 2)[Terrestrial
+ planets], [Mercury], [0.330], [4,879], [5427], [3.7], [4222.6], [57.9], [167], [0], [Closest
+ to the Sun],
+ [Venus], [4.87], [12,104], [5243], [8.9], [2802.0], [108.2], [464], [0], [],
+ [Earth], [5.97], [12,756], [5514], [9.8], [24.0], [149.6], [15], [1], [Our
+ world],
+ [Mars], [0.642], [6,792], [3933], [3.7], [24.7], [227.9], [-65], [2], [The
+ red planet],
+ table.cell(rowspan: 4)[Jovian planets], table.cell(rowspan: 2)[Gas
+ giants], [Jupiter], [1898], [142,984], [1326], [23.1], [9.9], [778.6], [-110], [67], [The
+ largest planet],
+ [Saturn], [568], [120,536], [687], [9.0], [10.7], [1433.5], [-140], [62], [],
+ table.cell(rowspan: 2)[Ice
+ giants], [Uranus], [86.8], [51,118], [1271], [8.7], [17.2], [2872.5], [-195], [27], [],
+ [Neptune], [102], [49,528], [1638], [11.0], [16.1], [4495.1], [-200], [14], [],
+ table.cell(colspan: 2)[Dwarf
+ planets], [Pluto], [0.0146], [2,370], [2095], [0.7], [153.3], [5906.4], [-225], [5], [Declassified
+ as a planet in 2006.],
+ )]
+ , caption: [Data about the planets of our solar system.
+
+ ]
+ , kind: table
+ )
diff --git a/test/tables/students.typst b/test/tables/students.typst
new file mode 100644
index 000000000..223732b06
--- /dev/null
+++ b/test/tables/students.typst
@@ -0,0 +1,26 @@
+#figure(
+ align(center)[#table(
+ columns: (50%, 50%),
+ align: (left,left,),
+ table.header(table.cell(align: center)[Student
+ ID], table.cell(align: center)[Name],),
+ table.hline(),
+ table.cell(colspan: 2)[Computer Science],
+ table.hline(),
+ [3741255], [Jones, Martha],
+ [4077830], [Pierce, Benjamin],
+ [5151701], [Kirk, James],
+ table.cell(colspan: 2)[Russian Literature],
+ table.hline(),
+ [3971244], [Nim, Victor],
+ table.cell(colspan: 2)[Astrophysics],
+ table.hline(),
+ [4100332], [Petrov, Alexandra],
+ [4100332], [Toyota, Hiroko],
+ )]
+ , caption: [List of Students
+
+ ]
+ , kind: table
+ )
+<students>