Skip to content

Commit

Permalink
Simplify lib API
Browse files Browse the repository at this point in the history
  • Loading branch information
otytlandsvik committed Sep 15, 2024
1 parent 7fd366c commit 5fc5604
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 49 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- [x] Code blocks (syntax highlights)
- [x] Tables
- [x] Footnotes (?)
- [ ] Style for print (pagebreak to even)
- [ ] Good examples
- [ ] Use of figures, tables, code blocks
- [ ] Side by side
Expand Down
47 changes: 23 additions & 24 deletions lib.typ
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#import "modules/frontpage.typ": frontpage
#import "modules/backpage.typ": backpage
#import "modules/supervisors.typ": supervisors-page
#import "modules/acknowledgements.typ": acknowledgements_page
#import "modules/abstract.typ": abstract_page
#import "modules/epigraph.typ": epigraph_page
Expand Down Expand Up @@ -68,7 +69,7 @@
// Common styles for main matter
#let main_matter(body) = {
set page(numbering: "1",
// Only show numbering in footer when no header is peresent
// Only show numbering in footer when no chapter header is peresent
footer: context {
let chapters = heading.where(level: 1)
if query(chapters).any(it => it.location().page() == here().page()) {
Expand All @@ -92,7 +93,7 @@
#let back_matter(body) = {
// TODO: Should not outline bibliography, but maybe appendix?
set heading(numbering: "A", supplement: [Appendix], outlined: false)
// Without this, the header says "Chapter F"
// Make sure headings start with 'A'
counter(heading.where(level: 1)).update(0)
counter(heading).update(0)
body
Expand Down Expand Up @@ -124,19 +125,25 @@
// Author.
author: "Author",

// The name of the supervisor(s) for your work.
supervisor: ("John Doe"),
// The supervisor(s) for your work. Takes an array of "Title", "Name", [Affiliation]
supervisors: (
(title: "Your Supervisor",
name: "Supervisor Name",
affiliation: [UiT The Arctic University of Norway, \
Faculty of Science and Techonology, \
Department of Computer Science])
),

// The paper size to use.
paper-size: "a4",

// The degree you are working towards
degree: "INF-3983 Capstone",

// What you are majoring in
// What field you are majoring in
major: "Computer Science",

// The faculty and department at which you are workings
// The faculty and department at which you are working
faculty: "Faculty of Science and Technology",
department: "Department of Computer Science",

Expand All @@ -161,6 +168,7 @@
acknowledgements: none,

// The contents for the epigraph page. This will be displayed after the acknowledgements.
// Can be omitted if you don't have one
epigraph: none,

// The contents for the preface page. This will be displayed after the cover page. Can
Expand All @@ -170,6 +178,7 @@
// The result of a call to the `outline` function or `none`.
// Set this to `none`, if you want to disable the table of contents.
// More info: https://typst.app/docs/reference/model/outline/
// TODO: This is unused at the moment
table-of-contents: outline(),

// The result of a call to the `bibliography` function or `none`.
Expand All @@ -181,25 +190,17 @@
chapter-pagebreak: true,

// Whether the document is a print document.
// TODO: This is unused at the moment
is-print: false,

// Display an index of figures (images).
figure-index: (
enabled: true,
title: "Figures",
),
figure-index: true,

// Display an index of tables
table-index: (
enabled: true,
title: "Tables",
),
table-index: true,

// Display an index of listings (code blocks).
listing-index: (
enabled: true,
title: "Listings",
),
listing-index: true,

// List of abbreviations
abbreviations: none,
Expand Down Expand Up @@ -517,9 +518,7 @@
show: front_matter

// List of Supervisors
// NOTE: Should we use the variables in the struct for this?
// isupervisors()
include "modules/supervisors.typ"
supervisors-page(supervisors)

// Epigraph
epigraph_page()[#epigraph]
Expand Down Expand Up @@ -612,13 +611,13 @@
)

// ToF, ToT and ToL are optional
if figure-index.enabled {
if figure-index {
outline(title: "List of Figures", target: fig-t(image))
}
if table-index.enabled {
if table-index {
outline(title: "List of Tables", target: fig-t(table))
}
if listing-index.enabled {
if listing-index {
outline(title: "List of Listings", target: fig-t(raw))
}
}
Expand Down
41 changes: 25 additions & 16 deletions modules/supervisors.typ
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
#page(
paper: "a4",
header: none,
footer: none,
numbering: none,
)[
#text(14pt, weight: "bold", font: "Open Sans", "Supervisors")
#grid(
columns: (120pt, 100pt, 200pt),
gutter: 2em,
[#text(weight: "semibold", "Main supervisor:")], [Weihai Yu],
[UiT The Arctic University of Norway, \
Faculty of Science and Technology, \
Department of Computer Science],
[#text(weight: "semibold", "External supervisor:")], [Jonas Juselius], [Oceanbox A/S]
#let supervisors-page(supervisors) = {
pagebreak(weak: true, to: "even")

// Apply styling to supervisor content
let supervisors-content = supervisors.map(s => {
(
[#text(weight: "semibold", s.title + ":")],
[#s.name],
[#s.affiliation],
)
})

// --- Supervisors ---
page(
numbering: none,
[
#text(14pt, weight: "bold", font: "Open Sans", "Supervisors")
#grid(
// NOTE: If supervisor title, name and affiliation overlap in the PDF, try changing the column widths here
columns: (120pt, 100pt, 200pt),
gutter: 2em,
..supervisors-content.flatten()
)
],
)
]
}
30 changes: 21 additions & 9 deletions template/thesis.typ
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@
--- Joe Armstrong
]

#let abstract = [
In our increasingly interconnected digital landscape, the constant generation and consumption of data on various computing devices present challenges for ensuring constant accessibility, particularly in intermittent network scenarios. The emerging focus on distributed systems is aimed at not only managing sub- stantial data volumes but also guaranteeing storage on devices for low latency and high availability. A paradigm known as _local-first software_ prioritize the storage of data on end-user devices as opposed to relying solely on centralized cloud services.
]
#let abstract = [#lorem(150)]

#let acknowledgements = [#lorem(30)]
#let acknowledgements = [#lorem(50)]

// Put your abbreviations/acronyms here.
// 'key' is what you will reference in the typst code
Expand Down Expand Up @@ -45,13 +43,27 @@
faculty: "<faculty>",
department: "<department>",
major: "<major>",
supervisor: "<supervisor>",
supervisors: (
(
title: "Main Supervisor",
name: "Navn Navnesen",
affiliation: [UiT The Arctic University of Norway, \
Faculty of Science and Technology, \
Department of Computer Science
],
),
(
title: "External Supervisor",
name: "Kari Nordmann",
affiliation: [External Company A/S],
),
),
abstract: abstract,
epigraph: epigraph,
acknowledgements: acknowledgements,
figure-index: (enabled: true),
table-index: (enabled: true),
listing-index: (enabled: true),
figure-index: true,
table-index: true,
listing-index: true,
abbreviations: abbreviations,
submission-date: datetime.today(),
bibliography: bibliography("refs.bib", title: "Bibliography", style: "ieee"),
Expand All @@ -63,7 +75,7 @@
name: "Rust",
color: rgb("#CE412B"),
),
// NOTE: Hacky, but fs doesn't syntax highlight
// NOTE: Hacky, but 'fs' doesn't syntax highlight
fsi: (
name: "F#",
color: rgb("#6a0dad"),
Expand Down

0 comments on commit 5fc5604

Please sign in to comment.