4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Typst の表

Last updated at Posted at 2024-06-24

はじめに

Typstの表に関して、仕様をまとめる。

デフォルトは表が狭い。

#set table(inset: 10pt)

言語を設定しておく

#set text(lang: "ja")

表の結合

#table(
  columns: 2,
  
  table.cell(colspan: 2)[a],
  [b], [c]
)

image.png

#table(
  columns: 2,
  
  table.cell(rowspan: 2)[a],
  [b], [c]
)

image.png

縦横
#table(
  columns: 3,
  
  table.cell(rowspan: 2, colspan: 2)[a],
  [b], [c], [d], [e], [f]
)

image.png

stroke で枠線の色や太さが変わる。 none にすると透明になる。

枠線の色
#table(
  columns: 2,
  stroke: gray,
  
  [a], [b],
  [c], [d]
)

image.png

寄せる

align を横方向は leftcenterrightから、縦方向は tophorizonbottom から選ぶ。

中央揃え
#table(
  columns: 3,
  align: center,
  
  [a], [b], [c],
  [ddddd], [eeeee], [fffff]
)

image.png

列ごとに指定
#table(
  columns: 3,
  align: (left, center, right),
  
  [a], [b], [c],
  [ddddd], [eeeee], [fffff]
)

image.png

条件付き
#table(
  columns: 3,
  align: (x, _) =>
    if x == 0
      { center }
    else
      { left },
  
  [a], [b], [c],
  [ddddd], [eeeee], [fffff]
)

image.png

幅の指定

#table(
  columns: (1fr,1fr, 200pt),
  
  [a], [b], [c],
  [ddddd], [eeeee], [fffff]
)

image.png

繰り返し指定
#table(
  columns: (2em, ) * 2,
  [a], [b],
  [c], [d]
)

image.png

セルの背景色

条件付き
#table(
  columns: 2,
  fill: (x, y) => 
    if x == 0 or y == 0
      { silver },
  
  [a], [b],
  [c], [d]
)

image.png

その他

中に box をいれて制御する。

#table(
  columns: 2,
  align: horizon,

  [
    #box(
      baseline: 32%,
      [
        - a
        - b
      ]
    )
    ⇒ c
  ], [d]
)

image.png

4
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?