|
| 1 | +#let font-size-default = 10pt |
| 2 | +#let font-size-heading = 11pt |
| 3 | +#let spacing-size-heading = 12pt |
| 4 | +#let appendix-numbering = "A.1" |
| 5 | +#let state-font-gothic = state("gothic", (:)) |
| 6 | + |
| 7 | +// import third-party packages |
| 8 | +#import "@preview/codly:1.1.1": codly-init |
| 9 | +#import "@preview/ctheorems:1.1.3": thmplain, thmproof, thmrules |
| 10 | + |
| 11 | +// Theorem environments |
| 12 | +#let thmja = thmplain.with(base: {}, separator: [#h(0.5em)], titlefmt: strong, inset: (top: 0em, left: 0em)) |
| 13 | +#let definition = thmja("definition", context{text(font: state-font-gothic.get())[定義]}) |
| 14 | +#let lemma = thmja("lemma", context{text(font: state-font-gothic.get())[補題]}) |
| 15 | +#let theorem = thmja("theorem", context{text(font: state-font-gothic.get())[定理]}) |
| 16 | +#let corollary = thmja("corollary", context{text(font: state-font-gothic.get())[系]}) |
| 17 | +#let proof = thmproof("proof", context{text(font: state-font-gothic.get())[証明]}, separator: [#h(0.9em)], titlefmt: strong, inset: (top: 0em, left: 0em)) |
| 18 | + |
| 19 | +#let jaconf( |
| 20 | + title-ja: [日本語タイトル], |
| 21 | + title-en: [], |
| 22 | + authors-ja: [著者], |
| 23 | + authors-en: [], |
| 24 | + abstract: none, |
| 25 | + keywords: (), |
| 26 | + font-gothic: "Noto Sans CJK JP", |
| 27 | + font-mincho: "Noto Serif CJK JP", |
| 28 | + font-latin: "New Computer Modern", |
| 29 | + body |
| 30 | +) = { |
| 31 | + // Set the font for headings. |
| 32 | + state-font-gothic.update(font-gothic) |
| 33 | + |
| 34 | + // Enable packages. |
| 35 | + show: thmrules.with(qed-symbol: $square$) |
| 36 | + show: codly-init.with() |
| 37 | + |
| 38 | + // Set document metadata. |
| 39 | + set document(title: title-ja) |
| 40 | + |
| 41 | + // Configure the page. |
| 42 | + set page( |
| 43 | + paper: "a4", |
| 44 | + margin: (top: 20mm, bottom: 27mm, x: 20mm) |
| 45 | + ) |
| 46 | + set text(font-size-default, font: font-mincho) |
| 47 | + set par(leading: 0.5em, first-line-indent: 1em, justify: true, spacing: 0.6em) |
| 48 | + show "、": "," |
| 49 | + show "。": "." |
| 50 | + |
| 51 | + // Configure equation numbering and spacing. |
| 52 | + set math.equation(numbering: "(1)") |
| 53 | + show math.equation: set block(spacing: 0.55em) |
| 54 | + |
| 55 | + // Configure appearance of references |
| 56 | + show ref: it => { |
| 57 | + // Equation -> (n). |
| 58 | + // See https://typst.app/docs/reference/model/ref/ |
| 59 | + let eq = math.equation |
| 60 | + let el = it.element |
| 61 | + if el != none and el.func() == eq { |
| 62 | + link(el.location(), numbering( |
| 63 | + el.numbering, |
| 64 | + ..counter(eq).at(el.location()) |
| 65 | + )) |
| 66 | + } |
| 67 | + // Sections -> n章m節l項. |
| 68 | + // Appendix -> 付録A. |
| 69 | + else if el != none and el.func() == heading { |
| 70 | + let sec-cnt = counter(heading).at(el.location()) |
| 71 | + if el.numbering != appendix-numbering{ |
| 72 | + if el.depth == 1 { |
| 73 | + link(el.location(), [#sec-cnt.at(0)章]) |
| 74 | + } else if el.depth == 2{ |
| 75 | + link(el.location(), [#sec-cnt.at(0)章#sec-cnt.at(1)節]) |
| 76 | + } else if el.depth == 3{ |
| 77 | + link(el.location(), [#sec-cnt.at(0)章#sec-cnt.at(1)節#sec-cnt.at(2)項]) |
| 78 | + } |
| 79 | + } else { |
| 80 | + link(el.location(), [ |
| 81 | + 付録#numbering(el.numbering, ..sec-cnt) |
| 82 | + ]) |
| 83 | + } |
| 84 | + } else { |
| 85 | + it |
| 86 | + } |
| 87 | + } |
| 88 | + |
| 89 | + // Configure lists. |
| 90 | + set enum(indent: 1em) |
| 91 | + set list(indent: 1em) |
| 92 | + |
| 93 | + // Configure headings. |
| 94 | + set heading(numbering: "1.1") |
| 95 | + show heading: it => { |
| 96 | + set par(first-line-indent: 0em, spacing: spacing-size-heading) |
| 97 | + let levels = counter(heading).get() |
| 98 | + if it.level == 1 { |
| 99 | + set text(font-size-heading, font: font-gothic) |
| 100 | + // Acknowledgment sections are not numbered. |
| 101 | + if it.numbering != none and not it.body in ([謝辞], [Acknowledgment], [Acknowledgement]) { |
| 102 | + numbering(it.numbering, ..levels) |
| 103 | + h(1em) |
| 104 | + } |
| 105 | + it.body |
| 106 | + } else { |
| 107 | + set text(font-size-default, font: font-gothic) |
| 108 | + if it.numbering != none { |
| 109 | + numbering(it.numbering, ..levels) |
| 110 | + h(1em) |
| 111 | + } |
| 112 | + it.body |
| 113 | + } |
| 114 | + } |
| 115 | + |
| 116 | + // Configure figures. |
| 117 | + show figure.where(kind: table): set figure(placement: top, supplement: [Table]) |
| 118 | + show figure.where(kind: table): set figure.caption(position: top, separator: [: ]) |
| 119 | + show figure.where(kind: image): set figure(placement: top, supplement: [Fig.]) |
| 120 | + show figure.where(kind: image): set figure.caption(position: bottom, separator: [: ]) |
| 121 | + |
| 122 | + // Display the paper's title. |
| 123 | + align(center, text(16pt, title-ja, weight: "bold", font: font-gothic)) |
| 124 | + v(18pt, weak: true) |
| 125 | + |
| 126 | + // Display the authors list. |
| 127 | + align(center, text(12pt, authors-ja, font: font-mincho)) |
| 128 | + v(1.5em, weak: true) |
| 129 | + |
| 130 | + // Display the paper's title in English. |
| 131 | + align(center, text(12pt, title-en, weight: "bold", font: font-latin)) |
| 132 | + v(1.5em, weak: true) |
| 133 | + |
| 134 | + // Display the authors list in English. |
| 135 | + align(center, text(12pt, authors-en, font: font-latin)) |
| 136 | + v(1.5em, weak: true) |
| 137 | + |
| 138 | + // Display abstract and index terms. |
| 139 | + if abstract != none { |
| 140 | + grid( |
| 141 | + columns: (0.7cm, 1fr, 0.7cm), |
| 142 | + [], |
| 143 | + [ |
| 144 | + #set text(10pt, font: font-latin) |
| 145 | + #set par(first-line-indent: 0em) |
| 146 | + *Abstract--* #h(0.5em) #abstract |
| 147 | + #v(1em) |
| 148 | + *Key Words:* #h(0.5em) #keywords.join(", ") |
| 149 | + ], |
| 150 | + [] |
| 151 | + ) |
| 152 | + v(1em, weak: false) |
| 153 | + } |
| 154 | + |
| 155 | + // Start two column mode and configure paragraph properties. |
| 156 | + show: columns.with(2) |
| 157 | + |
| 158 | + // Configure Bibliography. |
| 159 | + set bibliography(title: text(font-size-heading)[参考文献], style: "sice.csl") |
| 160 | + show bibliography: it => [ |
| 161 | + #set text(9pt, font: font-mincho) |
| 162 | + #show regex("[0-9a-zA-Z]"): set text(font: font-latin) |
| 163 | + #it |
| 164 | + ] |
| 165 | + |
| 166 | + // Display the paper's contents. |
| 167 | + body |
| 168 | +} |
| 169 | + |
| 170 | +// Appendix |
| 171 | +#let appendix(body) = { |
| 172 | + set heading(numbering: appendix-numbering) |
| 173 | + counter(heading).update(0) |
| 174 | + counter(figure.where(kind: image)).update(0) |
| 175 | + counter(figure.where(kind: table)).update(0) |
| 176 | + set figure(numbering: it => { |
| 177 | + [#numbering("A", counter(heading).get().at(0)).#it] |
| 178 | + }) |
| 179 | + v(spacing-size-heading) |
| 180 | + context(text(font-size-heading, font: state-font-gothic.get(), weight: "bold")[付録]) |
| 181 | + body |
| 182 | +} |
0 commit comments