Update template.typ

This commit is contained in:
Laurenz 2024-02-08 15:24:25 +01:00 committed by GitHub
parent a9076233fc
commit 9e27888d58
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3,461 +3,462 @@
#let acroStates = state("acronymStates", ()); #let acroStates = state("acronymStates", ());
#let thesis( #let thesis(
// the title of your thesis // the title of your thesis
title: none, title: none,
// your name // your name
author: none, author: none,
// your student id / matriculation number // your student id / matriculation number
student_id: none, student_id: none,
// the name of your course, such as "TINF21A" // the name of your course, such as "TINF21A"
course: none, course: none,
signature: none, signature: none,
// the name of your supervisor // the name of your supervisor
supervisor: none, supervisor: none,
// the due date of your thesis // the due date of your thesis
date: none, date: none,
// the time period that the work described in your thesis took place in // the time period that the work described in your thesis took place in
time_period: none, time_period: none,
// the type of your thesis, such as T1000, T2000, etc. // the type of your thesis, such as T1000, T2000, etc.
type: none, type: none,
// your degree, such as "Bachelor of Science" // your degree, such as "Bachelor of Science"
degree: "Bachelor of Science", degree: "Bachelor of Science",
// your major, such as "Computer Science" // your major, such as "Computer Science"
major: "Computer Science", major: "Computer Science",
// Details on your university // Details on your university
university: ( university: (
name: "Cooperative State University Baden-Württemberg", name: "Cooperative State University Baden-Württemberg",
location: "Stuttgart", location: "Stuttgart",
image: "assets/dhbw.svg", image: "assets/dhbw.svg",
), ),
// Details on your company // Details on your company
company: ( company: (
name: "Hewlett Packard Enterprise", name: "Hewlett Packard Enterprise",
image: "assets/hpe.svg", image: "assets/hpe.svg",
), ),
// Does the document require a Confidentiality Clause? // Does the document require a Confidentiality Clause?
confidentiality_clause: false, confidentiality_clause: false,
// Path to your bibliography file // Path to your bibliography file
// You may use `.yml` for Hayagriva format // You may use `.yml` for Hayagriva format
// or `.bib` for BibLaTeX format // or `.bib` for BibLaTeX format
bibliography_path: "literature.yml", bibliography_path: "literature.yaml",
// The contents of your abstract // The contents of your abstract
abstract: include "./abstract.typ", abstract: include "./abstract.typ",
// First chapter of your thesis // First chapter of your thesis
// This is required to generate the content section correctly // This is required to generate the content section correctly
first_chapter_title: "Introduction", first_chapter_title: "Introduction",
// set automatically by using the template via `#show: thesis.with(...) // set automatically by using the template via `#show: thesis.with(...)
body, body,
) = [ ) = [
// Assert all parameters are set // Assert all parameters are set
#assert.ne(title, none) #assert.ne(title, none)
#assert.ne(author, none) #assert.ne(author, none)
#assert.ne(student_id, none) #assert.ne(student_id, none)
#assert.ne(type, none) #assert.ne(type, none)
#assert.ne(course, none) #assert.ne(course, none)
#assert.ne(date, none) #assert.ne(date, none)
#assert.ne(time_period, none) #assert.ne(time_period, none)
#assert.ne(supervisor, none) #assert.ne(supervisor, none)
#set document( #set document(
title: title, title: title,
author: author, author: author,
) )
#set page( #set page(
paper: "a4", paper: "a4",
margin: 2.5cm, margin: 2.5cm,
numbering: none, // don't number the first pages, i.e. titlepage and abstract numbering: none, // don't number the first pages, i.e. titlepage and abstract
) )
// suggested font and font size by the DHBW style guide // suggested font and font size by the DHBW style guide
#set text( #set text(
font: "Linux Libertine", font: "Linux Libertine", // Linux Biolinum O
size: 12pt, // font: "Linux Biolinum O",
hyphenate: false, size: 12pt,
lang: "en", hyphenate: false,
ligatures: true, lang: "en",
) ligatures: true,
)
#set par(
leading: 8pt, // 1.5x line spacing #set par(
justify: true, leading: 8pt, // 1.5x line spacing
linebreaks: "optimized", justify: true,
) linebreaks: "optimized",
)
#set figure(
numbering: "I" #set figure(
) numbering: "I"
)
// don't outline or number the first headings
#set heading( // don't outline or number the first headings
numbering: none, #set heading(
outlined: false, numbering: none,
) outlined: false,
)
// modify the spacing between various headings and the content below them
#show heading: it => { // modify the spacing between various headings and the content below them
let sizes = if it.level == 1 { #show heading: it => {
(64pt, 24pt, 24pt) let sizes = if it.level == 1 {
} else if it.level == 2 { (64pt, 24pt, 24pt)
(32pt, 20pt, 18pt) } else if it.level == 2 {
} else { (32pt, 20pt, 18pt)
(24pt, 16pt, 14pt) } else {
} (24pt, 16pt, 14pt)
}
[
#set text(size: sizes.at(2)) [
#v(sizes.at(0)) #set text(size: sizes.at(2))
#if it.numbering != none [ #v(sizes.at(0))
#counter(heading).display(it.numbering) #h(4pt) #it.body #if it.numbering != none [
] else [#it.body] #counter(heading).display(it.numbering) #h(4pt) #it.body
#v(sizes.at(1)) ] else [#it.body]
] #v(sizes.at(1))
} ]
// Alternative formating for headdings }
// #show heading: it => { // Alternative formating for headdings
// v(1em) // #show heading: it => {
// if it.numbering != none { // v(1em)
// grid( // if it.numbering != none {
// columns: (auto, auto), // grid(
// { // columns: (auto, auto),
// numbering(it.numbering, ..counter(heading).at(it.location())) // {
// h(24pt / it.level) // numbering(it.numbering, ..counter(heading).at(it.location()))
// }, // h(24pt / it.level)
// it.body, // },
// ) // it.body,
// } else { // )
// it.body // } else {
// } // it.body
// v(0.5em) // }
// } // v(0.5em)
// #show heading.where(level: 1): set text(size: 24pt) // }
// #show heading.where(level: 2): set text(size: 20pt) // #show heading.where(level: 1): set text(size: 24pt)
// #show heading.where(level: 3): set text(size: 16pt) // #show heading.where(level: 2): set text(size: 20pt)
// #show heading.where(level: 3): set text(size: 16pt)
// Style figure captions
#show figure : it => block(breakable: false)[ // Style figure captions
#v(15pt, weak: true) // TODO: consider reenabling, broken
#it.body // #show figure : it => block(breakable: false)[
#align(center)[ // #v(15pt, weak: true)
// #v(.5em) // #it.body
#block(width: 80%, text(size: .9em)[ // #align(center)[
#it.supplement #it.counter.display(it.numbering): // // #v(.5em)
#emph(it.caption) // #block(width: 80%, text(size: .9em)[
]) // #it.supplement #it.counter.display(it.numbering):
#v(15pt) // #emph(it.caption.text)
] // ])
] // #v(15pt)
// ]
// rename level 1 headings to "Chapter", otherwise "Section" // ]
#set ref(supplement: it => {
if it.func() == heading and it.level == 1 { // rename level 1 headings to "Chapter", otherwise "Section"
"Chapter" #set ref(supplement: it => {
} else { if it.func() == heading and it.level == 1 {
"Section" "Chapter"
} } else {
}) "Section"
}
// beginning of the document, render the title page })
#set align(center) // beginning of the document, render the title page
// nice #set align(center)
#grid(
columns: (1fr, 1fr), // nice
align(center)[ #grid(
#image(company.image, width: 69%) columns: (1fr, 1fr),
], align(center)[
align(center)[ #image(company.image, width: 69%)
#image(university.image, width: 69%) ],
], align(center)[
) #image(university.image, width: 69%)
#v(64pt) ],
)
#set par(justify: false) #v(64pt)
#text(20pt)[*#title*]
#v(32pt) #set par(justify: false)
#set par(justify: true) #text(20pt)[*#title*]
#v(32pt)
#text(16pt)[*#type*] #set par(justify: true)
#v(16pt)
#text(16pt)[*#type*]
#text(14pt)[for the] #v(16pt)
#text(14pt)[*#degree*] #text(14pt)[for the]
#text(14pt)[from the Course of Studies #major] #text(14pt)[*#degree*]
#v(32pt)
#text(14pt)[from the Course of Studies #major]
#text(14pt)[by] #v(32pt)
#text(16pt)[*#author*] #text(14pt)[by]
#v(16pt)
#text(16pt)[*#author*]
#text(14pt)[#date] #v(16pt)
#set align(bottom) #text(14pt)[#date]
#grid( #set align(bottom)
columns: (1fr, 0.5fr, 1fr),
align(left)[ #grid(
*Time Period* \ columns: (1fr, 0.5fr, 1fr),
*Student ID, Course* \ align(left)[
*Company* \ *Time Period* \
*Supervisor in the Company* *Student ID, Course* \
], *Company* \
none, *Supervisor in the Company*
align(left)[ ],
#time_period \ none,
#student_id, #course \ align(left)[
#company.name \ #time_period \
#supervisor #student_id, #course \
], #company.name \
) #supervisor
],
#pagebreak() )
#set align(top)
#set align(left) #pagebreak()
#set align(top)
// initially set the page numbering to roman #set align(left)
#set page(numbering: "I")
#counter(page).update(1) // initially set the page numbering to roman
#set page(numbering: "I")
// https://www.dhbw.de/fileadmin/user_upload/Dokumente/Broschueren_Handbuch_Betriebe/Infoblatt_Vertraulichkeit.pdf #counter(page).update(1)
#if confidentiality_clause [
== Confidentiality Clause // https://www.dhbw.de/fileadmin/user_upload/Dokumente/Broschueren_Handbuch_Betriebe/Infoblatt_Vertraulichkeit.pdf
#if confidentiality_clause [
The content of this work may not be made accessible to people outside of the == Confidentiality Clause
testing process and the evaluation process neither as a whole nor as excerpts,
unless an authorization stating otherwise is presented by the training facility. The content of this work may not be made accessible to people outside of the
testing process and the evaluation process neither as a whole nor as excerpts,
// #text(lang: "de")[ unless an authorization stating otherwise is presented by the training facility.
// Der Inhalt dieser Arbeit darf weder als Ganzes noch in Auszügen Personen außerhalb des
// Prüfungs- und des Evaluationsverfahrens zugänglich gemacht werden, sofern keine anders // #text(lang: "de")[
// lautende Genehmigung des Dualen Partners vorliegt. // Der Inhalt dieser Arbeit darf weder als Ganzes noch in Auszügen Personen außerhalb des
// ] // Prüfungs- und des Evaluationsverfahrens zugänglich gemacht werden, sofern keine anders
// lautende Genehmigung des Dualen Partners vorliegt.
#pagebreak() // ]
]
#pagebreak()
// render the abstract aligned to the center of the page ]
#set align(horizon)
#set align(center) // render the abstract aligned to the center of the page
#set align(horizon)
== Abstract #set align(center)
#block(width: 70%)[#abstract] == Abstract
#pagebreak() #block(width: 70%)[#abstract]
#set align(top) #pagebreak()
#set align(start)
#set align(top)
= Author's Declaration #set align(start)
Hereby I solemnly declare: = Author's Declaration
+ that this #type, titled #text(style: "italic")[#title] is entirely the product of my Hereby I solemnly declare:
own scholarly work, unless otherwise indicated in the text or references, or acknowledged below;
+ that this #type, titled #text(style: "italic")[#title] is entirely the product of my own scholarly work, unless otherwise indicated in the text or references, or acknowledged below;
+ I have indicated the thoughts adopted directly or indirectly from other sources at the appropriate
places within the document; + I have indicated the thoughts adopted directly or indirectly from other sources at the appropriate places within the document;
+ this #type has not been submitted either in whole or part, for a degree at this or + this #type has not been submitted either in whole or part, for a degree at this or any other university or institution;
any other university or institution;
+ I have not published this #type in the past;
+ I have not published this #type in the past;
// - the printed version is equivalent to the submitted one.
// - the printed version is equivalent to the submitted one.
I am aware that a dishonest declaration will entail legal consequences.
I am aware that a dishonest declaration will entail legal consequences. #v(48pt)
#v(48pt)
#university.location, #date
#university.location, #date // #v(48pt)
// #v(48pt)
#box(width: 196pt, height: 40pt)[
#box(width: 196pt, height: 40pt)[ #if signature == "hide" {
#if signature == "hide" { box(height: 50pt)
box(height: 50pt) } else if signature == none {
} else if signature == none { [
[ Set your signature by setting the `signature` argument
Set your signature by setting the `signature` argument to an image or set it to `hide`, to leave place for signing otherwise
to an image or set it to `hide`, to leave place for signing otherwise #v(2pt)
#v(2pt) ]
] } else {
} else { image(signature)
image(signature) }
} #v(0pt, weak: true)
#v(0pt, weak: true) #line(length: 100%)
#line(length: 100%) #author
#author ]
]
#pagebreak()
#pagebreak()
= Contents
= Contents
#locate(loc => {
#locate(loc => { let headings = query(heading, loc)
let headings = query(heading, loc) let before_content = true
let before_content = true let after_content = false
let after_content = false
for elem in headings {
for elem in headings { // kind of hacky, we track whether the main document has started by looking for a chapter by name
// kind of hacky, we track whether the main document has started by looking for a chapter by name if elem.body == [#first_chapter_title] {
if elem.body == [#first_chapter_title] { before_content = false
before_content = false }
}
// similarly, track the end of the main content by the position of the "Bibliography" chapter
// similarly, track the end of the main content by the position of the "Bibliography" chapter if elem.body == [Bibliography] {
if elem.body == [Bibliography] { after_content = true
after_content = true }
}
// page numbers of the main document are arabic, the first pages are roman
// page numbers of the main document are arabic, the first pages are roman let index_fmt = if before_content {
let index_fmt = if before_content { "I"
"I" } else {
} else { "1"
"1" }
}
let location = elem.location()
let location = elem.location() let page_index = counter(page).at(location).at(0)
let page_index = counter(page).at(location).at(0)
let formatted_index = numbering(index_fmt, page_index)
let formatted_index = numbering(index_fmt, page_index)
// only the main content should be numbered
// only the main content should be numbered let formatted_name = if before_content or after_content {
let formatted_name = if before_content or after_content { elem.body
elem.body } else [
} else [ #numbering("1.1", ..counter(heading).at(location))
#numbering("1.1", ..counter(heading).at(location)) #h(4pt)
#h(4pt) #elem.body
#elem.body ]
]
let is_chapter = elem.level == 1
let is_chapter = elem.level == 1
// indent headings in the table of contents based on their level
// indent headings in the table of contents based on their level let indent = if is_chapter {
let indent = if is_chapter { 0pt
0pt } else if elem.level == 2 {
} else if elem.level == 2 { 2em
2em } else {
} else { 4em
4em }
}
// non-chapter headings have their line filled with dots
// non-chapter headings have their line filled with dots let spacer = if is_chapter { " " } else { " . " }
let spacer = if is_chapter { " " } else { " . " }
if elem.body != [Abstract] and elem.body != [Confidentiality Clause] {
if elem.body != [Abstract] and elem.body != [Confidentiality Clause] { link(
link( location,
location, [
[ #h(indent)
#h(indent) // add extra spacing between chapters
// add extra spacing between chapters #if is_chapter {v(1pt)}
#if is_chapter {v(1pt)} // chapters are bold, sections are not
// chapters are bold, sections are not #if is_chapter [*#formatted_name*] else [#formatted_name]
#if is_chapter [*#formatted_name*] else [#formatted_name] #box(width: 1fr, repeat(spacer))
#box(width: 1fr, repeat(spacer)) #h(8pt)
#h(8pt) #if is_chapter [*#formatted_index*] else [#formatted_index] \
#if is_chapter [*#formatted_index*] else [#formatted_index] \ ],
], )
) }
} }
} })
})
// #outline(target: heading.)
// #outline(target: heading.)
// #show outline.entry.where(
// #show outline.entry.where( // level: 1
// level: 1 // ): it => {
// ): it => { // v(12pt, weak: true)
// v(12pt, weak: true) // strong(it)
// strong(it) // }
// }
// #outline(target: heading, depth: 3, indent: 2em, fill: repeat(" . "))
// #outline(target: heading, depth: 3, indent: 2em, fill: repeat(" . "))
#pagebreak()
#pagebreak()
// start adding headings to the outline after the table of contents
// start adding headings to the outline after the table of contents #set heading(outlined: true)
#set heading(outlined: true)
// = List of Figures
// = List of Figures
#show outline.entry: it => [
#show outline.entry: it => [ #v(12pt, weak: true) #it
#v(12pt, weak: true) #it ]
]
#outline(target: figure, title: "List of Figures", fill: repeat(" . "))
#outline(target: figure, title: "List of Figures", fill: repeat(" . "))
#pagebreak()
#pagebreak()
= Acronyms
= Acronyms
#let acroArr = ();
#let acroArr = (); #for (k, v) in acronyms.pairs().sorted(key: s => lower(s.at(0))) {
#for (k, v) in acronyms.pairs().sorted(key: s => lower(s.at(0))) { acroArr.push([*#k* #label(k)]);
acroArr.push([*#k* #label(k)]); acroArr.push([#v]);
acroArr.push([#v]); }
}
#table(
#table( columns: (1fr, 6fr),
columns: (1fr, 6fr), align: horizon,
align: horizon, stroke: none,
stroke: none, ..acroArr,
..acroArr, )
)
#pagebreak()
#pagebreak()
// update heading and page numberings to begin the main part of the document
// update heading and page numberings to begin the main part of the document #set heading(numbering: "1.1")
#set heading(numbering: "1.1") #set page(numbering: "1 / 1")
#set page(numbering: "1 / 1") #counter(page).update(1)
#counter(page).update(1)
// the actual chapters
// the actual chapters #body
#body
// finally, include the bibliography chapter at the end of the document
// finally, include the bibliography chapter at the end of the document #pagebreak()
#pagebreak() #bibliography(bibliography_path, style: "ieee")
// #bibliography(bibliography_path, style: "ieee")
#bibliography(bibliography_path, style: "ieee")
] ]
// `pref` if to prefer the long form
#let acro(short, pref: false, append: "") = { #let acro(short, pref: false, append: "") = {
let item = acronyms.at(short) let item = acronyms.at(short)
locate(loc => { locate(loc => {
let entries = acroStates.at(loc).filter(e => e == short); let entries = acroStates.at(loc).filter(e => e == short);
if entries.len() > 0 { // Already used once
if pref { if entries.len() > 0 {
link(label(short))[#item#append] if pref {
} else { link(label(short))[#item#append]
link(label(short))[#short#append] } else {
} link(label(short))[#short#append]
} else { }
acroStates.update(e => {e.push(short); e;}); // First usage
if pref { } else {
link(label(short))[#item#append (#short)] acroStates.update(e => {e.push(short); e;});
} else { if pref {
link(label(short))[#short#append (#item)] link(label(short))[#item#append (#short)]
} } else {
} link(label(short))[#short#append (#item)]
}); }
}
});
} }
#let acroOnce(main, inside) = [#main (#inside)] #let acroOnce(main, inside) = [#main (#inside)]
#let todo(content) = par(emph([ #let todo(content) = par(emph([
#h(5pt) #text(weight: "bold")[To-do/WIP:] #content #h(5pt) #text(weight: "bold")[To-do/WIP:] #content
])) ]))