はじめに
Typstの表に関して、仕様をまとめる。
デフォルトは表が狭い。
#set table(inset: 10pt)
言語を設定しておく
#set text(lang: "ja")
表の結合
横
#table(
columns: 2,
table.cell(colspan: 2)[a],
[b], [c]
)
縦
#table(
columns: 2,
table.cell(rowspan: 2)[a],
[b], [c]
)
縦横
#table(
columns: 3,
table.cell(rowspan: 2, colspan: 2)[a],
[b], [c], [d], [e], [f]
)
stroke
で枠線の色や太さが変わる。 none
にすると透明になる。
枠線の色
#table(
columns: 2,
stroke: gray,
[a], [b],
[c], [d]
)
寄せる
align
を横方向は left
、center
、right
から、縦方向は top
、horizon
、bottom
から選ぶ。
中央揃え
#table(
columns: 3,
align: center,
[a], [b], [c],
[ddddd], [eeeee], [fffff]
)
列ごとに指定
#table(
columns: 3,
align: (left, center, right),
[a], [b], [c],
[ddddd], [eeeee], [fffff]
)
条件付き
#table(
columns: 3,
align: (x, _) =>
if x == 0
{ center }
else
{ left },
[a], [b], [c],
[ddddd], [eeeee], [fffff]
)
幅の指定
#table(
columns: (1fr,1fr, 200pt),
[a], [b], [c],
[ddddd], [eeeee], [fffff]
)
繰り返し指定
#table(
columns: (2em, ) * 2,
[a], [b],
[c], [d]
)
セルの背景色
条件付き
#table(
columns: 2,
fill: (x, y) =>
if x == 0 or y == 0
{ silver },
[a], [b],
[c], [d]
)
その他
中に box
をいれて制御する。
#table(
columns: 2,
align: horizon,
[
#box(
baseline: 32%,
[
- a
- b
]
)
⇒ c
], [d]
)