-
Notifications
You must be signed in to change notification settings - Fork 1
/
template.typ
151 lines (133 loc) · 3.67 KB
/
template.typ
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#let phantom-paragraph() = {
set text(size: 11pt)
let a = par(box())
a
context v(-0.8 * measure(2 * a).width)
}
#let project(
id: "",
title-ja: "",
title-en: "",
abstract: [],
authors: (),
affiliations: (),
keywords: (),
n-columns: 2,
body,
) = {
// General settings
set document(author: authors.map(a => a.name-ja), title: title-ja)
// Prioritize YuMincho because MS Mincho does not support bold.
set text(font: ("Times New Roman", "Yu Mincho", "YuMincho", "MS Mincho"), lang: "ja")
set page(paper: "a4", margin: (x: 23mm, y: 25mm))
// Heading settings
set heading(numbering: "1.1.")
show heading: it => {
// Workaround for the limitation of Typst.
// See https://github.com/typst/typst/issues/311#issuecomment-2023038611
{
set text(size: 9.5pt, weight: "bold")
set block(spacing: 0.65em)
{
// Add a vertical space before the heading, if not the first heading.
let selector = selector(heading).before(here())
let level = counter(selector)
// level.display()
if level.display() != "1" and it.level == 1 {
v(9.5pt)
}
}
it
}
phantom-paragraph()
}
// Section reference settings
show ref: it => {
let el = it.element
if el != none and el.func() == heading {
context {
let heading_counts = counter(heading).at(it.element.location())
if el.depth == 1 {
// 章
[第#heading_counts.at(0)章]
// counts
} else if el.depth == 2 {
// 節
[第#heading_counts.at(0).#heading_counts.at(1)節]
} else if el.depth == 3 {
// 項
[第#heading_counts.at(0).#heading_counts.at(1).#heading_counts.at(2)項]
} else {
it
}
}
} else {
it
}
}
// Paragraph settings
show par: set block(spacing: 0.65em)
// Equation settings
set math.equation(numbering: "(1)")
// Figure settings
show figure.where(kind: table): set figure.caption(position: top)
set table(stroke: .5pt)
set figure.caption(separator: [ ])
// Title (Japanese).
align(center)[#text(size: 16pt)[#id\u{3000}#title-ja]]
v(10.5pt)
// Author information (Japanese).
align(center)[
#set text(size: 10.5pt)
#authors.enumerate().map(i_author => {
let (i, author) = i_author
if author.presenting [〇]
box(author.name-ja)
if (
i < authors.len() - 1 and author.affiliation-ja != authors.at(i + 1).affiliation-ja
) or i == authors.len() - 1 {
box([(#author.affiliation-ja)])
}
}).join(",")
]
v(10.5pt)
// Title (English).
align(center)[#text(size: 10.5pt, title-en)]
// Author information (English).
align(center)[
#set text(size: 10.5pt)
#authors.enumerate().map(i_author => {
let (i, author) = i_author
box(author.name-en)
if (
i < authors.len() - 1 and author.affiliation-en != authors.at(i + 1).affiliation-en
) or i == authors.len() - 1 {
box([~(#author.affiliation-en)])
}
}).join(", ", last: " and ")
]
v(9.5pt)
// Keywords
align(center)[
#set text(size: 9.5pt)
Keywords: #keywords.join(", ")
]
v(9.5pt)
// Abstract
align(center)[
#text(size: 9.5pt)[Abstract]
]
text(size: 9.5pt)[#h(2em)#abstract]
v(1.2em)
// Main body.
set text(size: 9.5pt)
// We need to subtract 9.5pt (the font size) from 15pt to get the correct line spacing.
// 0.65pt in Typst is equivalent to no line spacing in MS Word.
set par(justify: true, leading: 15pt - 9.5pt + 0.65pt, first-line-indent: 1em)
if n-columns == 1 {
body
} else {
show: columns.with(n-columns, gutter: 7mm)
body
}
}