-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtemplate.typ
More file actions
443 lines (419 loc) · 18.6 KB
/
template.typ
File metadata and controls
443 lines (419 loc) · 18.6 KB
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
#import "src/main.typ": thesis_template
// Use this file as the mapping layer between MyST data and the Typst layout.
// It should stay as thin as possible:
// - read metadata, part files, and PDF export options from MyST
// - map them to the argument names expected by src/main.typ
// - leave layout defaults in src/main.typ whenever possible
//
// Navigation notes:
// - `project.*` values are preferred and `doc.*` values are used as fallbacks
// - some MyST values are mapped twice in different shapes for the title page
// - if an argument is omitted here, src/main.typ supplies the default
#show: thesis_template.with(
// Shared document metadata
// These values are reused across the cover, title page, and front matter.
[# if project.title #]
title: "[-project.title-]",
[# elif doc.title #]
title: "[-doc.title-]",
[# endif #]
[# if project.subtitle #]
subtitle: "[-project.subtitle-]",
[# elif doc.subtitle #]
subtitle: "[-doc.subtitle-]",
[# endif #]
[# if project.authors or doc.authors #]
authors: (
[# if project.authors #]
[# for author in project.authors #]
"[# if author.name #][-author.name-][# else #][-author-][# endif #]",
[# endfor #]
[# elif doc.authors #]
[# for author in doc.authors #]
"[# if author.name #][-author.name-][# else #][-author-][# endif #]",
[# endfor #]
[# endif #]
),
[# endif #]
[# if options.isbn is defined and options.isbn != none and options.isbn != "" #]
isbn: "[-options.isbn | replace("\\", "\\\\") | replace("\"", "\\\"") | replace("\n", "\\n")-]",
[# endif #]
[# if project.doi #]
doi: "[-project.doi | replace("\\", "\\\\") | replace("\"", "\\\"") | replace("\n", "\\n")-]",
[# elif doc.doi #]
doi: "[-doc.doi | replace("\\", "\\\\") | replace("\"", "\\\"") | replace("\n", "\\n")-]",
[# endif #]
[# if project.license is string #]
document_license: "[-project.license | replace("\\", "\\\\") | replace("\"", "\\\"") | replace("\n", "\\n")-]",
[# elif project.license.content is defined and project.license.content.id #]
document_license: "[-project.license.content.id | replace("\\", "\\\\") | replace("\"", "\\\"") | replace("\n", "\\n")-]",
[# elif project.license.content is defined and project.license.content.name #]
document_license: "[-project.license.content.name | replace("\\", "\\\\") | replace("\"", "\\\"") | replace("\n", "\\n")-]",
[# elif doc.license is string #]
document_license: "[-doc.license | replace("\\", "\\\\") | replace("\"", "\\\"") | replace("\n", "\\n")-]",
[# elif doc.license.content is defined and doc.license.content.id #]
document_license: "[-doc.license.content.id | replace("\\", "\\\\") | replace("\"", "\\\"") | replace("\n", "\\n")-]",
[# elif doc.license.content is defined and doc.license.content.name #]
document_license: "[-doc.license.content.name | replace("\\", "\\\\") | replace("\"", "\\\"") | replace("\n", "\\n")-]",
[# endif #]
// Keep contributor ids so the title page can group entries such as
// supervisor-1 and committee-1.
[# if project.contributors or doc.contributors #]
contributors: (
[# if project.contributors #]
[# for contributor in project.contributors #]
(
id: "[# if contributor.id #][-contributor.id-][# else #][# endif #]",
name: "[# if contributor.name #][-contributor.name-][# else #][-contributor-][# endif #]",
affiliations: (
[# if contributor.affiliations #]
[# for affiliation_id in contributor.affiliations #]
"[-affiliation_id-]",
[# endfor #]
[# endif #]
),
),
[# endfor #]
[# elif doc.contributors #]
[# for contributor in doc.contributors #]
(
id: "[# if contributor.id #][-contributor.id-][# else #][# endif #]",
name: "[# if contributor.name #][-contributor.name-][# else #][-contributor-][# endif #]",
affiliations: (
[# if contributor.affiliations #]
[# for affiliation_id in contributor.affiliations #]
"[-affiliation_id-]",
[# endfor #]
[# endif #]
),
),
[# endfor #]
[# endif #]
),
[# endif #]
// The same affiliation source is mapped in two forms:
// - `affiliation_catalog` keeps ids for contributor lookup
// - `affiliations` keeps printable names for simpler title-page rendering
[# if project.affiliations or doc.affiliations #]
affiliation_catalog: (
[# if project.affiliations #]
[# for aff in project.affiliations #]
(
id: "[# if aff.id #][-aff.id-][# else #][# endif #]",
name: "[# if aff.institution #][-aff.institution-][# elif aff.name #][-aff.name-][# else #][-aff-][# endif #]",
),
[# endfor #]
[# elif doc.affiliations #]
[# for aff in doc.affiliations #]
(
id: "[# if aff.id #][-aff.id-][# else #][# endif #]",
name: "[# if aff.institution #][-aff.institution-][# elif aff.name #][-aff.name-][# else #][-aff-][# endif #]",
),
[# endfor #]
[# endif #]
),
[# endif #]
[# if project.affiliations or doc.affiliations #]
affiliations: (
[# if project.affiliations #]
[# for aff in project.affiliations #]
"[# if aff.institution #][-aff.institution-][# elif aff.name #][-aff.name-][# else #][-aff-][# endif #]",
[# endfor #]
[# elif doc.affiliations #]
[# for aff in doc.affiliations #]
"[# if aff.institution #][-aff.institution-][# elif aff.name #][-aff.name-][# else #][-aff-][# endif #]",
[# endfor #]
[# endif #]
),
[# endif #]
// MyST dates are structured values, so this mapping flattens them into a simple string.
[# if project.date #]
date: "[-project.date.day-]-[-project.date.month-]-[-project.date.year-]",
[# elif doc.date #]
date: "[-doc.date.day-]-[-doc.date.month-]-[-doc.date.year-]",
[# endif #]
[# if project.keywords or doc.keywords #]
keywords: (
[# if project.keywords #]
[# for keyword in project.keywords #]
"[-keyword-]",
[# endfor #]
[# elif doc.keywords #]
[# for keyword in doc.keywords #]
"[-keyword-]",
[# endfor #]
[# endif #]
),
[# endif #]
// Thesis-specific metadata
// Use these fields for the academic labels shown on the detailed title-page layouts.
[# if options.thesis_degree #]
thesis_degree: "[-options.thesis_degree-]",
[# endif #]
[# if options.thesis_program #]
thesis_program: "[-options.thesis_program-]",
[# endif #]
[# if options.thesis_track #]
thesis_track: "[-options.thesis_track-]",
[# endif #]
[# if options.thesis_faculty #]
thesis_faculty: "[-options.thesis_faculty-]",
[# endif #]
[# if options.thesis_institution #]
thesis_institution: "[-options.thesis_institution-]",
[# endif #]
[# if options.thesis_defense_date #]
thesis_defense_date: "[-options.thesis_defense_date-]",
[# endif #]
// Optional front-matter part files
// These come from separate MyST part files and are rendered before the main chapters.
[# if parts.abstract #]
abstract: [
[-parts.abstract-]
],
[# endif #]
[# if parts.preface #]
preface: [
[-parts.preface-]
],
[# endif #]
[# if parts.acknowledgements #]
acknowledgements: [
[-parts.acknowledgements-]
],
[# endif #]
[# if parts.dedication #]
dedication: [
[-parts.dedication-]
],
[# endif #]
[# if parts.colophon #]
colophon: [
[-parts.colophon-]
],
[# endif #]
// Document structure and front matter
[# if options.show_cover_full is defined #]
show_cover_full: [-options.show_cover_full-],
[# endif #]
[# if options.show_title_page is defined #]
show_title_page: [-options.show_title_page-],
[# endif #]
[# if options.show_contributor_affiliations is defined #]
show_contributor_affiliations: [-options.show_contributor_affiliations-],
[# endif #]
[# if options.frontmatter_order is defined and options.frontmatter_order != none and options.frontmatter_order != "" #]
[# if options.frontmatter_order is string #]
frontmatter_order: "[-options.frontmatter_order-]",
[# else #]
frontmatter_order: (
[# for item in options.frontmatter_order #]
"[-item-]",
[# endfor #]
),
[# endif #]
[# endif #]
[# if options.show_toc is defined #]
show_toc: [-options.show_toc-],
[# endif #]
[# if options.show_list_of_figures is defined #]
show_list_of_figures: [-options.show_list_of_figures-],
[# endif #]
[# if options.show_list_of_tables is defined #]
show_list_of_tables: [-options.show_list_of_tables-],
[# endif #]
[# if options.toc_depth is defined and options.toc_depth != none #]
toc_depth: [-options.toc_depth-],
[# endif #]
[# if options.show_verso_blank_page_statement is defined #]
show_verso_blank_page_statement: [-options.show_verso_blank_page_statement-],
[# endif #]
[# if options.verso_blank_page_statement is defined and options.verso_blank_page_statement != none and options.verso_blank_page_statement != "" #]
verso_blank_page_statement: "[-options.verso_blank_page_statement-]",
[# endif #]
// Page layout
[# if options.paper_size is defined and options.paper_size != none and options.paper_size != "" #]
paper_size: "[-options.paper_size-]",
[# endif #]
[# if options.margin_top_cm is defined and options.margin_top_cm != none #]
margin_top_cm: [-options.margin_top_cm-]cm,
[# endif #]
[# if options.margin_bottom_cm is defined and options.margin_bottom_cm != none #]
margin_bottom_cm: [-options.margin_bottom_cm-]cm,
[# endif #]
[# if options.margin_left_cm is defined and options.margin_left_cm != none #]
margin_left_cm: [-options.margin_left_cm-]cm,
[# endif #]
[# if options.margin_right_cm is defined and options.margin_right_cm != none #]
margin_right_cm: [-options.margin_right_cm-]cm,
[# endif #]
// Typography
// Font family options are only passed when they are set explicitly.
// Otherwise src/main.typ keeps the template's built-in fallback families.
[# if options.font_body #]
font_body: "[-options.font_body-]",
[# endif #]
[# if options.font_mono #]
font_mono: "[-options.font_mono-]",
[# endif #]
[# if options.font_math #]
font_math: "[-options.font_math-]",
[# endif #]
[# if options.font_size_pt is defined and options.font_size_pt != none #]
font_size_pt: [-options.font_size_pt-]pt,
[# endif #]
[# if options.line_spacing_em is defined and options.line_spacing_em != none #]
line_spacing_em: [-options.line_spacing_em-]em,
[# endif #]
// Bibliography
// The bibliography file comes from MyST itself, while the remaining settings
// come from the PDF export options.
[# if doc.bibtex #]
bibliography_file: "[-doc.bibtex-]",
[# endif #]
[# if options.show_bibliography is defined #]
show_bibliography: [-options.show_bibliography-],
[# endif #]
[# if options.bibliography_title #]
bibliography_title: "[-options.bibliography_title-]",
[# endif #]
[# if options.bibliography_style #]
bibliography_style: "[-options.bibliography_style-]",
[# endif #]
[# if options.bibliography_numbered_heading is defined #]
bibliography_numbered_heading: [-options.bibliography_numbered_heading-],
[# endif #]
// Shared assets and branding
// If no custom files are provided, src/main.typ falls back to the bundled template assets.
[# if options.logo #]
logo: "[-options.logo-]",
[# endif #]
// Cover-page options
[# if options.cover_page_variant #]
cover_page_variant: "[-options.cover_page_variant-]",
[# endif #]
[# if options.show_cover_subtitle is defined #]
show_cover_subtitle: [-options.show_cover_subtitle-],
[# endif #]
[# if options.cover_background_image #]
cover_background_image: "[-options.cover_background_image-]",
[# elif options.cover_image #]
cover_background_image: "[-options.cover_image-]",
[# endif #]
[# if options.cover_graphical_appearance #]
cover_graphical_appearance: "[-options.cover_graphical_appearance-]",
[# endif #]
[# if options.cover_graphical_alignment is defined and options.cover_graphical_alignment != none and options.cover_graphical_alignment != "" #]
cover_graphical_alignment: "[-options.cover_graphical_alignment-]",
[# endif #]
[# if options.cover_title_text_color is defined and options.cover_title_text_color != none and options.cover_title_text_color != "" #]
cover_title_text_color: "[-options.cover_title_text_color-]",
[# endif #]
[# if options.cover_title_weight is defined and options.cover_title_weight != none and options.cover_title_weight != "" #]
cover_title_weight: "[-options.cover_title_weight-]",
[# endif #]
[# if options.cover_subtitle_weight is defined and options.cover_subtitle_weight != none and options.cover_subtitle_weight != "" #]
cover_subtitle_weight: "[-options.cover_subtitle_weight-]",
[# endif #]
[# if options.cover_author_weight is defined and options.cover_author_weight != none and options.cover_author_weight != "" #]
cover_author_weight: "[-options.cover_author_weight-]",
[# endif #]
[# if options.cover_bottom_text_color is defined and options.cover_bottom_text_color != none and options.cover_bottom_text_color != "" #]
cover_bottom_text_color: "[-options.cover_bottom_text_color-]",
[# endif #]
[# if options.cover_title_box_color is defined and options.cover_title_box_color != none and options.cover_title_box_color != "" #]
cover_title_box_color: "[-options.cover_title_box_color-]",
[# endif #]
[# if options.cover_title_box_text is defined and options.cover_title_box_text != none and options.cover_title_box_text != "" #]
cover_title_box_text: "[-options.cover_title_box_text-]",
[# endif #]
[# if options.cover_title_box_opacity_pct is defined #]
cover_title_box_opacity_pct: [-options.cover_title_box_opacity_pct-],
[# endif #]
[# if options.show_cover_bottom_ribbon is defined #]
show_cover_bottom_ribbon: [-options.show_cover_bottom_ribbon-],
[# endif #]
[# if options.cover_bottom_ribbon_color is defined and options.cover_bottom_ribbon_color != none and options.cover_bottom_ribbon_color != "" #]
cover_bottom_ribbon_color: "[-options.cover_bottom_ribbon_color-]",
[# endif #]
[# if options.cover_bottom_ribbon_opacity_pct is defined #]
cover_bottom_ribbon_opacity_pct: [-options.cover_bottom_ribbon_opacity_pct-],
[# endif #]
[# if options.cover_logo_variant is defined and options.cover_logo_variant != none and options.cover_logo_variant != "" #]
cover_logo_variant: "[-options.cover_logo_variant-]",
[# endif #]
[# if options.cover_logo_white #]
cover_logo_white: "[-options.cover_logo_white-]",
[# endif #]
[# if options.cover_logo_black #]
cover_logo_black: "[-options.cover_logo_black-]",
[# endif #]
[# if options.cover_logo_text is defined and options.cover_logo_text != none and options.cover_logo_text != "" #]
cover_logo_text: "[-options.cover_logo_text-]",
[# endif #]
[# if options.cover_bottom_block_dy_cm is defined and options.cover_bottom_block_dy_cm != none #]
cover_bottom_block_dy_cm: [-options.cover_bottom_block_dy_cm-]cm,
[# endif #]
// Title-page options
[# if options.title_page_variant #]
title_page_variant: "[-options.title_page_variant-]",
[# endif #]
[# if options.title_page_basic_title_alignment is defined and options.title_page_basic_title_alignment != none and options.title_page_basic_title_alignment != "" #]
title_page_basic_title_alignment: "[-options.title_page_basic_title_alignment-]",
[# endif #]
[# if options.title_page_basic_table_alignment is defined and options.title_page_basic_table_alignment != none and options.title_page_basic_table_alignment != "" #]
title_page_basic_table_alignment: "[-options.title_page_basic_table_alignment-]",
[# endif #]
[# if options.title_page_logo_alignment is defined and options.title_page_logo_alignment != none and options.title_page_logo_alignment != "" #]
title_page_logo_alignment: "[-options.title_page_logo_alignment-]",
[# endif #]
[# if options.title_page_formal_statement is defined and options.title_page_formal_statement != none and options.title_page_formal_statement != "" #]
title_page_formal_statement: "[-options.title_page_formal_statement | replace("\\", "\\\\") | replace("\"", "\\\"") | replace("\n", "\\n")-]",
[# endif #]
// Colophon options
[# if options.show_colophon_publication_info is defined #]
show_colophon_publication_info: [-options.show_colophon_publication_info-],
[# endif #]
[# if options.show_colophon_cover_description is defined #]
show_colophon_cover_description: [-options.show_colophon_cover_description-],
[# elif options.show_title_page_cover_description is defined #]
show_colophon_cover_description: [-options.show_title_page_cover_description-],
[# endif #]
[# if options.colophon_cover_description is defined and options.colophon_cover_description != none and options.colophon_cover_description != "" #]
colophon_cover_description: "[-options.colophon_cover_description | replace("\\", "\\\\") | replace("\"", "\\\"") | replace("\n", "\\n")-]",
[# elif options.title_page_cover_description #]
colophon_cover_description: "[-options.title_page_cover_description | replace("\\", "\\\\") | replace("\"", "\\\"") | replace("\n", "\\n")-]",
[# endif #]
[# if options.show_colophon_confidentiality_statement is defined #]
show_colophon_confidentiality_statement: [-options.show_colophon_confidentiality_statement-],
[# elif options.show_title_page_confidentiality_statement is defined #]
show_colophon_confidentiality_statement: [-options.show_title_page_confidentiality_statement-],
[# endif #]
[# if options.colophon_confidentiality_statement is defined and options.colophon_confidentiality_statement != none and options.colophon_confidentiality_statement != "" #]
colophon_confidentiality_statement: "[-options.colophon_confidentiality_statement | replace("\\", "\\\\") | replace("\"", "\\\"") | replace("\n", "\\n")-]",
[# elif options.title_page_confidentiality_statement #]
colophon_confidentiality_statement: "[-options.title_page_confidentiality_statement | replace("\\", "\\\\") | replace("\"", "\\\"") | replace("\n", "\\n")-]",
[# endif #]
[# if options.colophon_printer is defined and options.colophon_printer != none and options.colophon_printer != "" #]
colophon_printer: "[-options.colophon_printer | replace("\\", "\\\\") | replace("\"", "\\\"") | replace("\n", "\\n")-]",
[# endif #]
[# if options.colophon_publisher is defined and options.colophon_publisher != none and options.colophon_publisher != "" #]
colophon_publisher: "[-options.colophon_publisher | replace("\\", "\\\\") | replace("\"", "\\\"") | replace("\n", "\\n")-]",
[# endif #]
[# if options.colophon_copyright is defined and options.colophon_copyright != none and options.colophon_copyright != "" #]
colophon_copyright: "[-options.colophon_copyright | replace("\\", "\\\\") | replace("\"", "\\\"") | replace("\n", "\\n")-]",
[# endif #]
[# if options.colophon_custom_text is defined and options.colophon_custom_text != none and options.colophon_custom_text != "" #]
colophon_custom_text: "[-options.colophon_custom_text | replace("\\", "\\\\") | replace("\"", "\\\"") | replace("\n", "\\n")-]",
[# endif #]
[# if options.colophon_company_logo #]
colophon_company_logo: "[-options.colophon_company_logo | replace("\\", "\\\\") | replace("\"", "\\\"") | replace("\n", "\\n")-]",
[# endif #]
[# if options.show_colophon_watermark is defined #]
show_colophon_watermark: [-options.show_colophon_watermark-],
[# endif #]
)
// MyST adds helper imports here.
[-IMPORTS-]
// MyST adds the ordered document content here.
[-CONTENT-]