Skip to content

Commit

Permalink
merge for_0_13
Browse files Browse the repository at this point in the history
  • Loading branch information
okumuralab committed Feb 11, 2025
2 parents 5e44b52 + 73fc00b commit 56f44cb
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 63 deletions.
7 changes: 7 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
MIT No Attribution

Copyright 2025 Haruhiko Okumura

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
42 changes: 6 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Typst template based on LaTeX jsarticle/jsbook

LaTeXのjsarticle/jsbookっぽいTypstテンプレートです。
LaTeXのjsarticle/jsbookっぽいTypstテンプレートです。Typst 0.13用です。

とりあえず `js.typ``example.typ` を同じディレクトリに入れて

Expand All @@ -10,42 +10,12 @@ typst compile example.typ

として、できた `example.pdf` をご覧ください。

`#ruby[よみ][親文字]` などの定義も含めました。
## What's New

[2025-02-07] オプション `book: true` では、偶数ページのヘッダに章見出し、奇数ページのヘッダに節見出しが入るようにしました。そのページに節見出しがある場合はその最初のもの、なければそれ以前の最後の節見出しが入ります。ただし、章の開始ページではヘッダは入りません。`book: true` 以外でページ番号が出ないバグを直しました
[2024-02-11] Typst 0.13は日本語の扱いがかなり改良されており、0.12に固執する意味はなさそうなので、マージしてTypst 0.13用に一本化しました

[2025-02-08] LaTeXの `\frontmatter` 相当の
[2024-02-10] `#ruby[親文字][読み]` の順序がLaTeXの一般的なマクロと逆になっていたのを正しました。

```
#set heading(numbering: none)
#set page(numbering: "i")
```

`\mainmatter` 相当の

```
#pagebreak(weak: true, to: "odd")
#set heading(numbering: "1.1 ")
#counter(page).update(1)
#set page(numbering: "1")
```

などがちゃんと反映されるようにしたつもりです。

[2025-02-09] デフォルトフォントを

```
textfont: ("New Computer Modern", "Harano Aji Mincho"),
sansfont: ("Source Sans Pro", "Harano Aji Gothic"),
```

としていましたが、より一般的な

```
textfont: ("New Computer Modern", "Hiragino Mincho ProN", "Yu Mincho"),
sansfont: ("Arial", "Hiragino Kaku Gothic ProN", "Yu Gothic"),
```

に変えました(存在しなければ警告が出ますがMacでもWindowsでもどれかのフォントが存在すると思います)。
[2024-02-10] 和文ゴシック体が2ウェイトあれば、`*強い強調*` はボールド、`_強調_` はレギュラーになるはずです。見出しはレギュラーに統一しました(はずです)。

[2025-02-09] `for_0_13` というブランチにTypst 0.13用のコードを入れました
[2024-02-10] フォント指定のしかたを変えました。ありそうなフォントを並べる方式は警告が出るので、和欧それぞれ一つずつ指定する方式にしました。デフォルトはWeb版Typstにある原ノ味フォントとNew Computer Modern、Source Sans Proにしました。これらはTeX Liveに含まれていますが、ない場合は HaranoAjiMincho-Regular、HaranoAjiGothic-(Regular,Bold)、SourceSansPro-(Regular,Bold)[It] くらいを入れておけば便利です
69 changes: 42 additions & 27 deletions js.typ
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// Template based on LaTeX jsarticle/jsbook
// Template based on LaTeX jsarticle/jsbook for Typst 0.13

#let js(
lang: "ja",
textfont: ("New Computer Modern", "Hiragino Mincho ProN", "Yu Mincho"),
sansfont: ("Arial", "Hiragino Kaku Gothic ProN", "Yu Gothic"),
seriffont: "New Computer Modern",
seriffont-ja: "Harano Aji Mincho",
sansfont: "Source Sans Pro",
sansfont-ja: "Harano Aji Gothic",
paper: "a4", // "a*", "b*", or (paperwidth, paperheight) e.g. (210mm, 297mm)
fontsize: 10pt,
baselineskip: auto,
Expand Down Expand Up @@ -48,7 +50,7 @@
if not book { auto } else {
context {
let n = if page.numbering == none { "" } else {
counter(page).display(page.numbering) // logical page number
counter(page).display() // logical page number
}
let p = here().page() // physical page number
let h1 = heading.where(level: 1)
Expand Down Expand Up @@ -94,39 +96,38 @@
)
set text(
lang: lang,
font: textfont,
font: ((name: seriffont, covers: "latin-in-cjk"), seriffont-ja),
weight: 450,
size: fontsize,
top-edge: 0.88em,
)
set par(
first-line-indent: 1em,
first-line-indent: (amount: 1em, all: true),
justify: true,
spacing: baselineskip - 0.88em, // 段落間
leading: baselineskip - 0.88em, // 行間
spacing: baselineskip - 0.88em, // space between paragraphs
leading: baselineskip - 0.88em, // space between lines
)
set heading(numbering: "1.1")
show heading: set text(font: sansfont, weight: 450)
show heading: set text(
font: ((name: sansfont, covers: "latin-in-cjk"), sansfont-ja),
weight: 450,
)
show heading: it => {
v(baselineskip, weak: true)
it
par("")
v(-0.8 * baselineskip)
v(0.2 * baselineskip)
}
show heading.where(level: 1): it => {
set par(first-line-indent: 0em, spacing: 2.5 * fontsize, leading: 1.3 * fontsize)
if book {
pagebreak(weak: true, to: "odd")
v(2 * baselineskip)
if it.numbering != none {
let h = counter(heading).get().at(0, default: 0)
par(text(2 * fontsize, "" + str(h) + ""))
let n = counter(heading).get().at(0, default: 0)
text(2 * fontsize, "" + str(n) + "")
linebreak()
}
par(
first-line-indent: 0em,
spacing: 2.5 * fontsize,
leading: 1.3 * fontsize,
text(size: 2.5 * fontsize, it.body)
)
text(size: 2.5 * fontsize, it.body)
v(2 * baselineskip)
} else {
v(2 * baselineskip, weak: true)
Expand All @@ -137,21 +138,29 @@
text(if book { 1.4 } else { 1.2 } * fontsize, it)
}
set list(indent: 1.2em)
show strong: set text(font: sansfont, weight: 450)
show strong: set text(
font: ((name: sansfont, covers: "latin-in-cjk"), sansfont-ja),
weight: 450,
)
show emph: set text(
font: ((name: seriffont, covers: "latin-in-cjk"), sansfont-ja),
weight: 450,
)
set quote(block: true)
show quote.where(block: true): set pad(left: 2em)
show quote.where(block: true): set block(spacing: 1.5 * baselineskip - 0.88em)
show list: set block(spacing: 1.5 * baselineskip - 0.88em)
show enum: set block(spacing: 1.5 * baselineskip - 0.88em)
show terms: set block(spacing: 1.5 * baselineskip - 0.88em)
show math.equation.where(block: true): set block(spacing: 1.5 * baselineskip - 0.88em)
// set block(spacing: 1.5 * baselineskip - 0.88em) // affects all blocks
set terms(indent: 2em, separator: h(1em, weak: true))
set enum(indent: 0.722em)
set list(indent: 0.722em)
show terms: set block(spacing: 1.5 * baselineskip - 0.88em)
show raw.where(block: true): set block(width: 100%, fill: luma(240), inset: 1em)
show raw.where(block: true): set par(
justify: false,
spacing: 1.5 * baselineskip - 0.88em, // 段落間
leading: 0.8 * baselineskip - 0.88em, // 行間
leading: 0.8 * baselineskip - 0.88em,
)
set table(stroke: 0.4pt)
show table: set text(top-edge: 0.76em)
Expand Down Expand Up @@ -179,16 +188,22 @@

#let kintou(width, s) = box(width: width, s.text.clusters().join(h(1fr)))
#let scatter(s) = h(1fr) + s.text.clusters().join(h(2fr)) + h(1fr)
#let ruby(yomi, kanji) = box[
#let ruby(kanji, yomi) = box[
#context {
let w = measure(yomi).width / 2
let x = measure(kanji).width
set par(first-line-indent: 0em)
let w = measure(kanji).width
let x = measure(yomi).width / 2
if w < x { w = x }
box(width: w, h(1fr) + kanji + h(1fr)) // or scatter(kanji)
place(top + center, dy: -0.5em, box(width: w, text(0.5em, scatter(yomi))))
}
]

#let noindent(body) = {
set par(first-line-indent: 0em)
body
}

#let boxtable(x) = {
if type(x) == array {
box(baseline: 100%-0.76em-0.4em,
Expand Down Expand Up @@ -238,7 +253,7 @@
#if abstract != [] {
block(width: 90%)[
#set text(0.9em)
*概要*
_概要_
#align(left)[#abstract]
]
v(1.5em)
Expand Down

0 comments on commit 56f44cb

Please sign in to comment.