0
0

Typstで均等割付

Posted at

タイトルの通り,Typstで文字の均等割付を実装する関数(やっつけ)です

二文字以上の日本語限定ですが,均等割付けを使いたいときは大体そうなので,まず問題ないでしょう.
mojiで文字列の幅,bodyに割り付けしたい文字をstrで書きます.

#let kinto(moji,body) ={

context[
#let size = measure[も].width
#let wari_width = size * moji
#let body_mojisuu = calc.round(measure[#body].width/size)
#let cell_width = wari_width/body_mojisuu

#let haba = (wari_width - measure[#body].width)/(body_mojisuu - 1)


#let columns_cell = () 

#for i in range(moji) {
  columns_cell.push(cell_width)
}
#let body_array = ()
#let x = int(body.len()/3)
#for i in range(x) {
  body.at(3*i) 
  h(haba)
}
#h(-haba)
]
}

次のように使います.

#kinto(4,"氏名")
0
0
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
0
0