🙆

自分流Typstテンプレート

に公開

Typst って

Typstは,LaTeX のような文書作成システムです.ですが LaTeX よりコンパイルが断然速いため,こちらを使うことにしました.

Typst のテンプレート

今回のテンプレートでは,#import "@preview/metro:0.3.0" を使っているのですが,これが 2025/04/25 現在 typst の 0.13.x に対応していないため typst のバージョンは 0.12.x にしておく必要があります.

  • Visual Studio Code: 1.99.3
  • typst: 0.13.1
  • Tinymist Typst: 0.12.22

ディレクトリ構成は次のようにします.

ディレクトリ構成
.
├── template.typ
├── main.typ
└── references.bib
template.typ
#import "@preview/codelst:2.0.2": *
#import "@preview/metro:0.3.0": *
#import "@preview/physica:0.9.3": *

#let textL = 1.5em
#let textM = 1.2em
#let fontSerif = "Harano Aji Mincho"
#let fontSan = "HackgenNerd"
#let fontHeading = "Harano Aji Gothic"
#let fontMath = "New Computer Modern Math"

#let project(title: "", authors: "", course: "", body) = {
    // 見出し
    set heading(numbering: "1.1")
    show heading: set text(font: fontHeading, weight: "medium", lang: "ja")
    show heading: it => {
        it
        par(text(size: 0pt, ""))
    }
    show heading.where(level: 1): it => {
        set text(size: 1.0em)
        pad(top: 0.0em, bottom: 0.3em)[#it]
        par(text(size: 0pt, ""))
    }
    show heading.where(level: 2): it => {
        pad(top: 0.0em, bottom: 0.3em, it)
        par(text(size: 0pt, ""))
    }

    // 図
    show figure: it => pad(y: 1em, it)
    show figure.caption: it => text(it, lang: "ja")

    // 表
    set table(stroke: none)
    show figure.where(kind: table): set figure.caption(position: top)

    // 数式
    set math.equation(numbering: "(1)", number-align: bottom)
    set math.mat(delim: "[")
    show math.equation: set text(font: fontMath)

    // ドキュメント全体の設定
    set document(author: authors.map(a => a.name), title: title)
    set text(font: fontSerif, lang: "jp")
    set par(justify: true, first-line-indent: 1em)
    set page(numbering: "1", number-align: center, paper: "a4", margin: 2.5cm)

    // レポート本体 #####################################################################

    // タイトル部分
    align(center)[
        #text(size: 1.4em, weight: "regular")[#title] \
        #v(0.3em)
        #text(size: 1.3em, weight: "light")[#course] \
        #v(0.5em)
        #datetime.today().display("[year]年[month]月[day]日")
    ]


    // 著者名
    pad(
        grid(
            columns: (1fr,) * calc.min(3, authors.len()),
            gutter: 1em,
            ..authors.map(author => align(center)[
                #author.number #author.name\
                #author.affiliation
            ]),
        ),
    )
    set text(font: fontSerif, size: 1em, weight: "light", lang: "ja")

    // main.typ に書かれた本文を挿入
    body

    // 参考文献
    bibliography(title: "参考文献", full: true, style: "ieee", "bib.yaml")
}
main.typ
#import "template.typ": *

#show: project.with(
    title: "タイトル",
    course: "科目名",
    authors: ((number: 2514999, name: "善姓 善名", affiliation: [善大学善学部善学科]),),
)

= 目的

あああ

= 原理

= 方法

= 結果

= 考察

今回のPDF

GitHubで編集を提案

Discussion