1
0

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パッケージをもうちょっと簡単にかけるようにした(k-mapper)

1
Posted at

デフォルトでは列挙する値の順番は直感的でない。
そこで、実際の表のようにテキストを書いて期待する表が出力されるように値を並び替えている。
他のプロパティについては、プロパティ名を一文字に変えたのみ。
s4k()はsplit for karnaughで、意味のない文字を取り除いている(\tも取り除くべきかも)。

パッケージ:https://typst.app/universe/package/k-mapper
おそらく最新版は更新されているのでバージョンのところは変更する。

#import "@preview/k-mapper:1.2.0": *

#let s4k(it) = it.split("").filter(b => b != "" and b != "\r" and b != "\n" and b != " ")
#let k(b, i:(), v:(), h:(), c:false) = karnaugh(16,
    x-label: $Q_1 Q_0$,
    y-label: $Q_3 Q_2$,
    manual-terms: (0, 1, 3, 2, 4, 5, 7, 6, 12, 13, 15, 14, 8, 9, 11, 10)
        .map(i => s4k(b).at(i)),
    implicants: i,
    vertical-implicants: v,
    horizontal-implicants: h,
    corner-implicants: c,
    colors: (rgb(0,0,0,0),),
)

#figure(caption: [カルノー図], k(i: ((4, 12),), "
    0000
    1000
    xxxx
    xxxx
"))

注意:使用したバージョンでは、(rgb(0,0,0,0),)の末尾のカンマは必須

出力:
スクリーンショット 2026-01-11 013248.png

1
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?