-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathucsd_thesis.typ
575 lines (463 loc) · 12.7 KB
/
ucsd_thesis.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
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
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
// chp => chapter
// fig => figure
// spc => spacing
// mjr => major
#let prof_indent = 0.5in
// Spacing before the first entry of the chapter in the outline
#let otln_new_chp_spc = state("ut_otln_new_chp_spc", 1em)
// Spacing between the chapter number and the chapter title in the outline
#let otln_chp_primary_spc = state("ut_otln_chp_primary_spc", 6em)
// Additional indentation of sub-headings for each level in the outline
#let otln_chp_secondary_spc = state("ut_otln_chp_secondary_spc", 3em)
// Spacing between the major entries in the table of contents
#let toc_mjr_spc = 2em
// Leading of the outline (table of contents, list of figures, etc.)
#let otln_leading_spc = state("ut_otln_leading_spc", 1em)
// Columns for the list of abbreviations. The first column is for the abbreviation and the second column is for the full form.
#let abbrv_columns = state("ut_abbrv_columns", (0.25fr, 1fr))
#let CommitteeProf(person, indent: true) = context {
if indent {
h(prof_indent)
}
if person.title != none {
person.title + [ ]
}
person.name
if person.chair {
[, Chair]
}
linebreak()
}
#let PreambleChapter(title, label_name: none) = context {
show heading: set align(center)
heading(numbering: none, supplement: none)[
#{
text(weight: "regular", upper(title)) + v(1em)
}
]
}
#let ThesisBibliography(..files, full: false, style: "association-for-computing-machinery", title: "Bibliography") = {
par(
leading: 1em,
spacing: 2em
)[
#show heading.where(level: 1): it => context {
pagebreak()
text(1.8em, style: "normal", weight: "bold")[
#par(leading: 1em, justify: false)[
#it.body
]
]
}
#bibliography(
files.pos(),
full: full,
style: style,
title: title
)
]
}
#let ucsd_thesis(
// Subject of the thesis
subject: "Computer Science",
// Author of the thesis
author: "John/Jane Doe",
// Title of the thesis
title: "My Little Thesis",
// Degree of the thesis
degree: "Doctor of Philosophy",
// Committee members as dict in the order of appearance
// If a member is the chair, set chair to true
// Fields: title, name, chair
committee: (
(title: "Professor", name: "Jane Doe", chair: true),
(title: "Professor", name: "John Doe", chair: false)
),
// Abstract of the thesis. Omitted if none
abstract: none,
// Dedication of the thesis. Omitted if none
dedication: none,
// Acknowledgement of the thesis. Omitted if none
acknowledgement: none,
// Epigraph of the thesis. Omitted if none
epigraph: none,
// List of abbreviations. Omitted if none
// The list will be sorted by the abbreviation.
//
// Example:
// (
// "UCSD": "University of California San Diego",
// "PhD": "Doctor of Philosophy"
// )
abbrv: none,
// Vita of the author. Omitted if none
vita: none,
// Publications of the author. Omitted if none
publications: none,
// Introduction of the thesis. Omitted if none
introduction: none,
// Enable field of study section
enable_field_of_study: false,
// Research Topic for Field of Study
research_topic: none,
// Enables List of Table page
enable_list_of_tables: true,
// Enables List of Table page
enable_list_of_figures: true,
doc,
) = {
set page(
paper: "us-letter",
number-align: center,
numbering: none,
margin: (top: 1.5in, left: 1.01in, right: 1.01in)
)
set par(
justify: true
)
show table.cell: it => text(weight: "regular")[#it]
show table.cell: it => par(leading: 0.5em)[#it]
show figure: it => block(width: 100%)[#align(center)[
// Captions for Tables should be above the table (Manual, Pg 32)
#let body_before_caption = it.kind != table
#let caption = none
#let body = par(leading: 1em)[
#it.body
]
#set par(leading: 1em)
#if it.has("caption") {
if it.caption != none and it.caption.has("body") {
caption = {
text(weight: "bold", {
it.supplement
" "
str(counter(heading).get().first())
"."
str(counter(figure.where(kind: it.kind)).get().first())
}
)
": "
it.caption.body
}
}
}
#if body_before_caption {
body
caption
} else {
caption
body
}
]
]
show ref: it => {
let auto_supplement = (
"table": "Table",
"image": "Figure",
)
let el = it.element
if el != none and el.has("kind") and el.kind in (table, image) {
// Override references.
let kind_str = [#el.kind].text
let text = auto_supplement.at(kind_str) + [ ] +[#counter(heading).at(el.location()).first()\.#counter(figure.where(kind: el.kind)).at(el.location()).first()]
link(it.target)[#text]
} else if el != none and el.has("level") {
// Other references as usual.
let num = numbering("1.1.1", ..counter(heading).at(it.element.location()))
let text = "Section"
if it.element.level == 1 {
text = "Chapter"
}
link(it.target)[#text #num]
// link(it.target)[#text #num]
} else {
it
}
}
set outline(fill: align(right, repeat(gap: 5pt)[.]))
show outline.entry : it => context {
if it.element.func() == heading { // Table of contents outline
let element = it.element
let body = it.body
if element.numbering == none { // Preamble Chapters
v(toc_mjr_spc)
if body.has("text") { // Bibliography
body.text
box(width: 1fr, it.fill)
" " + it.page
} else {
let name = body.children.at(1).children.at(0).child
name + " "
box(width: 1fr, it.fill)
" " + it.page
}
} else if it.has("level") { // Normal Chapters
if element.body.has("text") and element.body.text == "Acknowledgement" {
// Skip it
} else {
let num = numbering("1.1.1", ..counter(heading).at(it.element.location()))
let grid_data = ()
let lvl = it.level
let prim_spc = otln_chp_primary_spc.get()
let sec_spc = otln_chp_secondary_spc.get()
let columns = (
"1": (prim_spc, 1fr),
"2": (prim_spc, sec_spc, 1fr),
"3": (prim_spc, sec_spc, sec_spc, 1fr),
"4": (prim_spc, sec_spc, sec_spc, sec_spc, 1fr),
"5": (prim_spc, sec_spc, sec_spc, sec_spc, sec_spc, 1fr),
)
if lvl == 1 {
if num == "1" {
v(toc_mjr_spc + 0.1em)
} else if num == "2" {
v(1.1em)
}
v(-0.1em)
grid_data.push("Chapter " + num)
} else {
for i in range(lvl - 1) {
grid_data.push("")
}
grid_data.push(num)
}
grid_data.push(element.body + box(width: 1fr, it.fill) + " " + it.page)
grid(
columns: columns.at(str(lvl)),
..for data in grid_data {
(data,)
}
)
}
}
} else { // Other outlines
let kind = it.element.kind
let heading_num = counter(heading).at(it.element.location()).first()
let figure_num = counter(figure.where(kind: kind)).at(it.element.location()).first()
let elem_num = numbering("1.1", heading_num, figure_num)
let elem_typ = it.element.caption.supplement.text
let caption = it.element.caption.body
let dots = box(width: 1fr, align(right, repeat(gap: 5pt)[.]))
let columns = (otln_chp_primary_spc.get(), 1fr, 2em)
if figure_num == 1 {
v(otln_new_chp_spc.get())
}
grid(
columns: columns,
elem_typ + " " + elem_num + ":",
par(leading: 0.5em, spacing: 0.4em)[#context {
caption + " " + dots + " "
}],
align(bottom+right, it.page)
)
}
}
align(center)[
#v(1fr)
UNIVERSITY OF CALIFORNIA SAN DIEGO
#v(1fr)
*#title*
#v(1fr) A Dissertation submitted in partial satisfaction of the requirements \
for the degree #degree
#v(1fr)
in
#v(1fr)
#subject
#v(1fr)
by
#v(1fr)
#author
#v(1fr)
]
[Committee in charge:] + linebreak() + linebreak()
for person in committee {
CommitteeProf(person)
}
v(1fr)
let today = datetime.today()
align(center)[
#today.display("[year]")
]
v(1fr)
pagebreak()
v(1fr)
align(center)[
#emoji.copyright \ #author, #today.display("[year]")
All rights reserved.
]
pagebreak()
set page(numbering: "i")
{
show heading: none
PreambleChapter("Dissertation Approval")
}
align(center)[
The Dissertation of #author is approved, and it is acceptable \
in quality and form for publication on microfilm and electronically.
#v(1fr)
University of California San Diego
#today.display("[year]")
#v(1fr)
]
set par(
leading: 2em,
spacing: 2em,
first-line-indent: 0.5in,
justify: true
)
show list: set block(spacing: 2em)
pagebreak()
if dedication != none {
PreambleChapter("Dedication")
dedication
pagebreak()
}
if epigraph != none {
PreambleChapter("Epigraph")
epigraph
pagebreak()
}
context {
PreambleChapter("Table of Contents")
par(leading: otln_leading_spc.get(), spacing: 0em)[
#outline(title: none)
]
}
pagebreak()
context {
if enable_list_of_figures {
PreambleChapter("List of Figures")
par(leading: otln_leading_spc.get(), spacing: 0em)[
#outline(
title: none,
target: figure.where(kind: image),
)
]
pagebreak()
}
}
context {
if enable_list_of_tables {
PreambleChapter("List of Tables")
par(leading: otln_leading_spc.get(), spacing: 0em)[
#outline(
title: none,
target: figure.where(kind: table),
)
]
pagebreak()
}
}
if abbrv != none {
PreambleChapter("LIST OF ABBREVIATIONS")
let abbrv_sorted = abbrv.pairs().sorted(key: k => k.at(0))
set par(justify: true)
context {
table(
stroke: none,
columns: abbrv_columns.get(),
..for (k, v) in abbrv_sorted {
(k, v)
}
)
}
pagebreak()
}
if acknowledgement != none {
PreambleChapter("ACKNOWLEDGEMENTS")
acknowledgement
pagebreak()
}
if vita != none {
PreambleChapter("Vita")
vita
}
if publications != none {
PreambleChapter("Publications")
publications
}
if enable_field_of_study {
PreambleChapter("Field of Study")
par(
leading: 0.5em,
spacing: 0.5em,
first-line-indent: 0em,
)[
Major Field: #subject
#context [
#h(prof_indent) Studies in #research_topic
]
#for person in committee {
if person.chair {
CommitteeProf(person)
}
}
]
}
if vita != none or publications != none or enable_field_of_study {
pagebreak()
}
if abstract != none {
v(1in)
PreambleChapter("Abstract of Dissertation")
align(center)[
#strong(title)
#v(1em)
by
#v(1em)
#author
#v(1em)
#degree in #subject
University of California San Diego, #today.display("[year]")
#for person in committee {
if person.chair {
CommitteeProf(person, indent: false)
}
}
#v(1em)
]
abstract
}
set page(numbering: "1")
counter(page).update(1)
if introduction != none {
PreambleChapter("Introduction")
[#introduction]
}
set heading(
numbering: (..) => counter(heading).display("1.1"),
supplement: ""
)
show heading.where(level: 1): set heading(
supplement: [Chapter],
)
show heading: it => context {
set text(style: "normal", weight: "regular")
if it.level == 1 {
set text(1.6em, weight: "bold")
set par(leading: 2em, justify: false)
counter(figure.where(kind: image)).update(0)
counter(figure.where(kind: table)).update(0)
pagebreak()
{
"Chapter "
counter(heading).display("1.1.1")
linebreak()
}
it.body
} else {
set text(1em + 0.8em/it.level, weight: "bold")
// it
block({
box(width: 45pt, counter(heading).display())
it.body
})
v(-2em)
linebreak()
parbreak()
}
}
// Set footnote size
show footnote.entry: set text(size: 10pt)
doc
}