format with typstyle (#40)
Gitea Action for checking typst compilation / run-ci-linux (push) Successful in 29s Details
release / release (push) Successful in 1m11s Details

This commit is contained in:
Sven Vogel 2024-08-12 18:09:14 +02:00
parent 08a6eaf79f
commit b1aca1b18b
17 changed files with 572 additions and 514 deletions

View File

@ -3,16 +3,16 @@
// https://brand.abb/portal/en/branding-principles/basic-brand-elements/color // https://brand.abb/portal/en/branding-principles/basic-brand-elements/color
// ABB branding colors // ABB branding colors
#let ABB-RED = cmyk(0%, 100%, 95%, 0%) #let ABB-RED = cmyk(0%, 100%, 95%, 0%)
#let ABB-BLACK = cmyk(0%, 0%, 0%, 100%) #let ABB-BLACK = cmyk(0%, 0%, 0%, 100%)
#let ABB-GRAY-01 = cmyk(0%, 0%, 0%, 90%) #let ABB-GRAY-01 = cmyk(0%, 0%, 0%, 90%)
#let ABB-GRAY-02 = cmyk(0%, 0%, 0%, 75%) #let ABB-GRAY-02 = cmyk(0%, 0%, 0%, 75%)
#let ABB-GRAY-03 = cmyk(0%, 0%, 0%, 55%) #let ABB-GRAY-03 = cmyk(0%, 0%, 0%, 55%)
#let ABB-GRAY-04 = cmyk(0%, 0%, 0%, 35%) #let ABB-GRAY-04 = cmyk(0%, 0%, 0%, 35%)
#let ABB-GRAY-05 = cmyk(0%, 0%, 0%, 15%) #let ABB-GRAY-05 = cmyk(0%, 0%, 0%, 15%)
#let ABB-GRAY-06 = cmyk(0%, 0%, 0%, 5%) #let ABB-GRAY-06 = cmyk(0%, 0%, 0%, 5%)
#let ABB-WHITE = cmyk(0%, 0%, 0%, 0%) #let ABB-WHITE = cmyk(0%, 0%, 0%, 0%)
// ABB branding functinal colors // ABB branding functinal colors
#let ABB-BLUE = cmyk(100%, 53%, 2%, 16%) #let ABB-BLUE = cmyk(100%, 53%, 2%, 16%)
#let ABB-GREEN = cmyk(91%, 4%, 100%, 25%) #let ABB-GREEN = cmyk(91%, 4%, 100%, 25%)
#let ABB-YELLOW = cmyk(0%, 9%, 100%, 0%) #let ABB-YELLOW = cmyk(0%, 9%, 100%, 0%)

View File

@ -53,9 +53,9 @@
page: ( page: (
format: "a4", format: "a4",
margin: ( margin: (
left: 3cm, left: 3cm,
right: 2.5cm, right: 2.5cm,
top: 2.5cm, top: 2.5cm,
bottom: 2.5cm)), bottom: 2.5cm)),
text: ( text: (
size: 12pt, size: 12pt,
@ -83,20 +83,20 @@
} }
for (key, val) in base { for (key, val) in base {
if key in update { if key in update {
let update_val = update.at(key) let update_val = update.at(key)
if type(val) == dictionary and type(update_val) == dictionary { if type(val) == dictionary and type(update_val) == dictionary {
base.insert(key, deep-insert-checked(val, update_val)) base.insert(key, deep-insert-checked(val, update_val))
} else if val == none or type(val) == type(update_val) { } else if val == none or type(val) == type(update_val) {
base.insert(key, update_val) base.insert(key, update_val)
} else {
panic("missmatched dictionary entry `" + key + "` type: expected `" + type(val) + "` got `" + type(update_val) + "`")
}
} else { } else {
base.insert(key, val) panic("missmatched dictionary entry `" + key + "` type: expected `" + type(val) + "` got `" + type(update_val) + "`")
} }
} else {
base.insert(key, val)
} }
}
return base return base
} }

View File

@ -40,7 +40,7 @@ SOFTWARE.*/
// key not found error // key not found error
#let __not-found-panic-error-msg(key) = { #let __not-found-panic-error-msg(key) = {
__glossarium_error_prefix+"key '"+key+"' not found" __glossarium_error_prefix + "key '" + key + "' not found"
} }
// Reference a term // Reference a term
@ -49,9 +49,9 @@ SOFTWARE.*/
let __glossary_entries = __glossary_entries.final(here()) let __glossary_entries = __glossary_entries.final(here())
if key in __glossary_entries { if key in __glossary_entries {
let entry = __glossary_entries.at(key) let entry = __glossary_entries.at(key)
let gloss = __query_labels_with_key(here(), key, before: true) let gloss = __query_labels_with_key(here(), key, before: true)
let is_first = gloss == () let is_first = gloss == ()
let entlong = entry.at("long", default: "") let entlong = entry.at("long", default: "")
let textLink = if display != none { let textLink = if display != none {
@ -61,7 +61,7 @@ SOFTWARE.*/
} else { } else {
[#entry.short#suffix] [#entry.short#suffix]
} }
[#link(label(entry.key), textLink)#label(__glossary_label_prefix + entry.key)] [#link(label(entry.key), textLink)#label(__glossary_label_prefix + entry.key)]
} else { } else {
panic(__not-found-panic-error-msg(key)) panic(__not-found-panic-error-msg(key))
@ -76,14 +76,14 @@ SOFTWARE.*/
let __glossary_entries = __glossary_entries.final(here()) let __glossary_entries = __glossary_entries.final(here())
if key in __glossary_entries { if key in __glossary_entries {
let entry = __glossary_entries.at(key) let entry = __glossary_entries.at(key)
let gloss = __query_labels_with_key(here(), key, before: true) let gloss = __query_labels_with_key(here(), key, before: true)
let is_first = gloss == () let is_first = gloss == ()
let entlongplural = entry.at("longplural", default: ""); let entlongplural = entry.at("longplural", default: "")
let entlong = if entlongplural == [] or entlongplural == "" { let entlong = if entlongplural == [] or entlongplural == "" {
// if the entry long plural is not provided, then fallback to adding 's' suffix // if the entry long plural is not provided, then fallback to adding 's' suffix
let entlong = entry.at("long", default: ""); let entlong = entry.at("long", default: "")
if entlong != [] and entlong != "" { if entlong != [] and entlong != "" {
[#entlong#suffix] [#entlong#suffix]
} else { } else {
@ -92,20 +92,20 @@ SOFTWARE.*/
} else { } else {
[#entlongplural] [#entlongplural]
} }
let entplural = entry.at("plural", default: ""); let entplural = entry.at("plural", default: "")
let short = if entplural == [] or entplural == "" { let short = if entplural == [] or entplural == "" {
[#entry.short#suffix] [#entry.short#suffix]
} else { } else {
[#entplural] [#entplural]
} }
let textLink = if (is_first or long == true) and entlong != [] and entlong != "" and long != false { let textLink = if (is_first or long == true) and entlong != [] and entlong != "" and long != false {
[#entlong (#short)] [#entlong (#short)]
} else { } else {
[#short] [#short]
} }
[#link(label(entry.key), textLink)#label(__glossary_label_prefix + entry.key)] [#link(label(entry.key), textLink)#label(__glossary_label_prefix + entry.key)]
} else { } else {
panic(__not-found-panic-error-msg(key)) panic(__not-found-panic-error-msg(key))
@ -152,42 +152,45 @@ SOFTWARE.*/
for entry in entry_list { for entry in entry_list {
x.insert(entry.key, entry) x.insert(entry.key, entry)
} }
x x
}) })
let groups = entries.map(x => x.at("group")).dedup() let groups = entries.map(x => x.at("group")).dedup()
for group in groups.sorted() { for group in groups.sorted() {
if group != "" [#heading(group, level: 1, outlined: false) ] if group != "" [#heading(group, level: 1, outlined: false) ]
for entry in entries.sorted(key: x => x.key) { for entry in entries.sorted(key: x => x.key) {
if entry.group == group { if entry.group == group {
[ [
#show figure.where(kind: __glossarium_figure): it => it.caption #show figure.where(kind: __glossarium_figure): it => it.caption
#figure( #figure(
supplement: "", supplement: "",
kind: __glossarium_figure, kind: __glossarium_figure,
numbering: none, numbering: none,
caption: { caption: {
context { context {
let term_references = __query_labels_with_key(here(), entry.key) let term_references = __query_labels_with_key(here(), entry.key)
if term_references.len() != 0 or show-all { if term_references.len() != 0 or show-all {
let desc = entry.at("desc", default: "") let desc = entry.at("desc", default: "")
let long = entry.at("long", default: "") let long = entry.at("long", default: "")
let hasLong = long != "" and long != [] let hasLong = long != "" and long != []
let hasDesc = desc != "" and desc != [] let hasDesc = desc != "" and desc != []
grid( grid(
columns: 2, columns: 2,
column-gutter: 1em, column-gutter: 1em,
text(weight: "bold", entry.short), text(weight: "bold", entry.short),
{ {
if hasLong { if hasLong {
text(weight: "bold", entry.long) text(weight: "bold", entry.long)
} }
if hasLong and hasDesc [:] if hasLong and hasDesc [:]
if hasDesc [ #desc ] else [. ] if hasDesc [ #desc ] else [. ]
if disable-back-references != true { if disable-back-references != true {
term_references.map(x => x.location()).sorted(key: x => x.page()).fold( term_references
.map(x => x.location())
.sorted(key: x => x.page())
.fold(
(values: (), pages: ()), (values: (), pages: ()),
((values, pages), x) => if pages.contains(x.page()) { ((values, pages), x) => if pages.contains(x.page()) {
(values: values, pages: pages) (values: values, pages: pages)
@ -196,25 +199,30 @@ SOFTWARE.*/
pages.push(x.page()) pages.push(x.page())
(values: values, pages: pages) (values: values, pages: pages)
}, },
).values.map(x => { )
let page-numbering = x.page-numbering(); .values
.map(x => {
let page-numbering = x.page-numbering()
if page-numbering == none { if page-numbering == none {
page-numbering = "1" page-numbering = "1"
} }
link(x)[#numbering(page-numbering, ..counter(page).at(x))] link(x)[#numbering(page-numbering, ..counter(page).at(x))]
} }
).join(", ") )
} .join(", ")
} }
) },
} )
} }
}, }
)[] #label(entry.key) },
)[] #label(entry.key)
#parbreak() #parbreak()
] ]
} }
} }
if enable-group-pagebreak { pagebreak(weak: true) } if enable-group-pagebreak {
pagebreak(weak: true)
}
} }
}; };

View File

@ -9,66 +9,72 @@
#let glossary(entries) = { #let glossary(entries) = {
assert(
type(entries) == dictionary,
message: "The glossary is not a dictionary",
)
for (k, v) in entries.pairs() {
assert( assert(
type(entries) == dictionary, type(v) == dictionary,
message: "The glossary is not a dictionary", message: "The glossary entry `" + k + "` is not a dictionary",
) )
for (k, v) in entries.pairs() { for key in v.keys() {
assert( assert(
type(v) == dictionary, key in ("short", "long", "desc", "group"),
message: "The glossary entry `" + k + "` is not a dictionary") message: "Found unexpected key `" + key + "` in glossary entry `" + k,
)
for key in v.keys() {
assert(
key in ("short", "long", "desc", "group"),
message: "Found unexpected key `" + key + "` in glossary entry `" + k)
}
assert(
type(v.short) == str,
message: "The short form of glossary entry `" + k + "` is not a string")
if "long" in v {
assert(
type(v.long) == str,
message: "The long form of glossary entry `" + k + "` is not a string")
}
if "desc" in v {
assert(
type(v.desc) == str,
message: "The description of glossary entry `" + k + "` is not a string")
}
if "group" in v {
assert(
type(v.group) == str,
message: "The optional group of glossary entry `" + k + "` is not a string")
} else {
let group = if "long" in v {
if (context text.lang) == "de" {
"Akronyme"
} else {
"Acronyms"
}
} else {
if (context text.lang) == "de" {
"Begriffe"
} else {
"Terms"
}
}
entries.at(k).group = group
}
} }
assert(
type(v.short) == str,
message: "The short form of glossary entry `" + k + "` is not a string",
)
if "long" in v {
assert(
type(v.long) == str,
message: "The long form of glossary entry `" + k + "` is not a string",
)
}
if "desc" in v {
assert(
type(v.desc) == str,
message: "The description of glossary entry `" + k + "` is not a string",
)
}
if "group" in v {
assert(
type(v.group) == str,
message: "The optional group of glossary entry `" + k + "` is not a string",
)
} else {
let group = if "long" in v {
if (context text.lang) == "de" {
"Akronyme"
} else {
"Acronyms"
}
} else {
if (context text.lang) == "de" {
"Begriffe"
} else {
"Terms"
}
}
entries.at(k).group = group
}
}
return entries.pairs().map(((key, entry)) => ( return entries.pairs().map(((key, entry)) => (
key: key, key: key,
short: eval(entry.short, mode: "markup"), short: eval(entry.short, mode: "markup"),
long: eval(entry.at("long", default: ""), mode: "markup"), long: eval(entry.at("long", default: ""), mode: "markup"),
desc: eval(entry.at("desc", default: ""), mode: "markup"), desc: eval(entry.at("desc", default: ""), mode: "markup"),
group: entry.at("group", default: "") group: entry.at("group", default: ""),
)) ))
} }

View File

@ -7,20 +7,20 @@
// Edited: 27.06.2024 // Edited: 27.06.2024
// License: MIT // License: MIT
#import "conf.typ": validate-config, default-config #import "conf.typ": validate-config, default-config
#import "branding.typ": * #import "branding.typ": *
#import "style.typ": global_styled_doc, content_styled, end_styled #import "style.typ": global_styled_doc, content_styled, end_styled
#import "glossary.typ": glossary #import "glossary.typ": glossary
#import "pages/titlepage.typ": new_title_page #import "pages/titlepage.typ": new_title_page
#import "pages/declaration-of-authorship.typ": new_declaration_of_authorship #import "pages/declaration-of-authorship.typ": new_declaration_of_authorship
#import "pages/confidentiality-statement.typ": new_confidentiality_statement_page #import "pages/confidentiality-statement.typ": new_confidentiality_statement_page
#import "pages/prerelease-note.typ": new_prerelease_note #import "pages/prerelease-note.typ": new_prerelease_note
#import "pages/outline.typ": new_outline #import "pages/outline.typ": new_outline
#import "pages/abstract.typ": new_abstract #import "pages/abstract.typ": new_abstract
#import "pages/preface.typ": new-preface #import "pages/preface.typ": new-preface
#import "pages/appendix.typ": show-appendix #import "pages/appendix.typ": show-appendix
#let group-break()= { #let group-break() = {
[#pagebreak()] [#pagebreak()]
} }
@ -51,12 +51,14 @@
#set document( #set document(
author: config.author.name, author: config.author.name,
keywords: config.thesis.keywords, keywords: config.thesis.keywords,
title: config.thesis.title) title: config.thesis.title,
)
// configure text locale // configure text locale
#set text( #set text(
lang: config.lang, lang: config.lang,
region: config.region) region: config.region,
)
// preppend title page // preppend title page
#new_title_page(config) #new_title_page(config)
@ -83,7 +85,8 @@
print-glossary( print-glossary(
disable-back-references: true, disable-back-references: true,
enable-group-pagebreak: true, enable-group-pagebreak: true,
glossary(config.thesis.glossary)) glossary(config.thesis.glossary),
)
pagebreak(weak: true) pagebreak(weak: true)
} }

View File

@ -6,22 +6,24 @@
// Edited: 28.06.2024 // Edited: 28.06.2024
// License: MIT // License: MIT
#let new_abstract(config) = context { #let new_abstract(config) = (
context {
set align(center + horizon)
// only include summary when a language other than english is used set align(center + horizon)
if text.lang == "de" [
// Summary is supposed to be on separate page
#pagebreak(weak: true)
= Zusammenfassung // only include summary when a language other than english is used
#config.thesis.summary if text.lang == "de" [
] // Summary is supposed to be on separate page
#pagebreak(weak: true)
// abstract is supposed to be on separate page = Zusammenfassung
pagebreak(weak: true) #config.thesis.summary
]
heading("Abstract") // abstract is supposed to be on separate page
config.thesis.abstract pagebreak(weak: true)
}
heading("Abstract")
config.thesis.abstract
}
)

View File

@ -6,39 +6,41 @@
// Edited: 28.06.2024 // Edited: 28.06.2024
// License: MIT // License: MIT
#let show-appendix(config: dictionary) = context { #let show-appendix(config: dictionary) = (
counter(heading).update(0) context {
counter(heading).update(0)
let title = if text.lang == "en" { let title = if text.lang == "en" {
"Appendix" "Appendix"
} else { } else {
"Anhang" "Anhang"
}
if "appendices" in config.thesis {
pagebreak(weak: true)
// appendix will be invisible on the appendecies page
// but still listed in the ToC
show heading: it => []
heading(level: 1, numbering: none, title)
// APA style appendix
show heading: it => {
let number = if it.numbering != none {
counter(heading).display(it.numbering)
}
block()[
#title #number - #it.body
]
} }
show heading.where(level: 1): it => v(2em) + it + v(1em) if "appendices" in config.thesis {
show heading.where(level: 2): it => v(1em) + it + v(0.5em) pagebreak(weak: true)
show heading.where(level: 3): it => v(0.5em) + it + v(0.25em)
set heading(numbering: "A.1", supplement: title) // appendix will be invisible on the appendecies page
// but still listed in the ToC
show heading: it => []
heading(level: 1, numbering: none, title)
config.thesis.appendices // APA style appendix
show heading: it => {
let number = if it.numbering != none {
counter(heading).display(it.numbering)
}
block()[
#title #number - #it.body
]
}
show heading.where(level: 1): it => v(2em) + it + v(1em)
show heading.where(level: 2): it => v(1em) + it + v(0.5em)
show heading.where(level: 3): it => v(0.5em) + it + v(0.25em)
set heading(numbering: "A.1", supplement: title)
config.thesis.appendices
}
} }
} )

View File

@ -6,51 +6,52 @@
// Edited: 28.06.2024 // Edited: 28.06.2024
// License: MIT // License: MIT
#let new_confidentiality_statement_page(config) = context { #let new_confidentiality_statement_page(config) = (
context {
pagebreak(weak: true) pagebreak(weak: true)
let thesis = config.thesis let thesis = config.thesis
let author = config.author let author = config.author
if text.lang == "de" [ if text.lang == "de" [
#heading(level: 1, "Sperrvermerk", supplement: [special]) #heading(level: 1, "Sperrvermerk", supplement: [special])
] else if text.lang == "en" [ ] else if text.lang == "en" [
#heading(level: 1, "Confidentiality Statement", supplement: [special]) #heading(level: 1, "Confidentiality Statement", supplement: [special])
] ]
if text.lang == "de" [ if text.lang == "de" [
Der Inhalt der dieser Arbeit mit dem Thema Der Inhalt der dieser Arbeit mit dem Thema
] else if text.lang == "en" [ ] else if text.lang == "en" [
The content of this work with the topic The content of this work with the topic
] ]
v(1em) v(1em)
set align(center) set align(center)
text(weight: "bold", thesis.title) text(weight: "bold", thesis.title)
if thesis.subtitle != none { if thesis.subtitle != none {
linebreak() linebreak()
thesis.subtitle thesis.subtitle
} }
set align(left) set align(left)
v(1em) v(1em)
set par(justify: true) set par(justify: true)
if text.lang == "de" [ if text.lang == "de" [
darf weder als Ganzes noch in Auszügen Personen außerhalb des Prüfungsprozesses und des Evalua-tionsverfahrens zugänglich gemacht werden, sofern keine anderslautende Genehmigung der Ausbildungsstätte vorliegt. darf weder als Ganzes noch in Auszügen Personen außerhalb des Prüfungsprozesses und des Evalua-tionsverfahrens zugänglich gemacht werden, sofern keine anderslautende Genehmigung der Ausbildungsstätte vorliegt.
] else if text.lang == "en" [ ] else if text.lang == "en" [
may not be made accessible to persons outside the examination process and the evaluation procedure, either as a whole or in excerpts, unless otherwise authorized by the training institution. may not be made accessible to persons outside the examination process and the evaluation procedure, either as a whole or in excerpts, unless otherwise authorized by the training institution.
] ]
set align(horizon) set align(horizon)
grid( grid(
// set width of columns // set width of columns
// we need two, so make both half the page width // we need two, so make both half the page width
columns: (50%, 50%), columns: (50%, 50%),
@ -59,4 +60,5 @@
align(left, {line(length: 6cm)}), align(left, {line(length: 6cm)}),
align(left, if text.lang == "de" [ Ort, Datum ] else if text.lang == "en" [ Place, Date ] else { panic("no translation for language: ", text.lang) }), align(left, if text.lang == "de" [ Ort, Datum ] else if text.lang == "en" [ Place, Date ] else { panic("no translation for language: ", text.lang) }),
align(left, if text.lang == "de" [ Unterschrift ] else if text.lang == "en" [ Signature ] else { panic("no translation for language: ", text.lang) })) align(left, if text.lang == "de" [ Unterschrift ] else if text.lang == "en" [ Signature ] else { panic("no translation for language: ", text.lang) }))
} }
)

View File

@ -6,53 +6,54 @@
// Edited: 28.06.2024 // Edited: 28.06.2024
// License: MIT // License: MIT
#let new_declaration_of_authorship(config) = context { #let new_declaration_of_authorship(config) = (
context {
pagebreak(weak: true) pagebreak(weak: true)
let thesis = config.thesis let thesis = config.thesis
let author = config.author let author = config.author
if text.lang == "de" [ if text.lang == "de" [
#heading("Selbständigkeitserklärung") #heading("Selbständigkeitserklärung")
] else if text.lang == "en" [ ] else if text.lang == "en" [
#heading("Declaration of Authorship") #heading("Declaration of Authorship")
] ]
v(1em) v(1em)
if text.lang == "de" [ if text.lang == "de" [
Ich versichere hiermit, dass ich meine Prüfung mit dem Thema Ich versichere hiermit, dass ich meine Prüfung mit dem Thema
] else if text.lang == "en" [ ] else if text.lang == "en" [
I hereby confirm that I have written this thesis with the subject I hereby confirm that I have written this thesis with the subject
] ]
v(1em) v(1em)
set align(center) set align(center)
text(weight: "bold", thesis.title) text(weight: "bold", thesis.title)
if thesis.subtitle != none { if thesis.subtitle != none {
linebreak() linebreak()
thesis.subtitle thesis.subtitle
} }
set align(left) set align(left)
v(1em) v(1em)
set par(justify: true) set par(justify: true)
if text.lang == "de" [ if text.lang == "de" [
selbständig verfasst und keine anderen als die angegebenen Quellen und Hilfsmittel benutzt habe. Ich versichere zudem, dass die eingereichte elektronische Fassung mit der gedruckten Fassung übereinstimmt. selbständig verfasst und keine anderen als die angegebenen Quellen und Hilfsmittel benutzt habe. Ich versichere zudem, dass die eingereichte elektronische Fassung mit der gedruckten Fassung übereinstimmt.
] else if text.lang == "en" [ ] else if text.lang == "en" [
independently and have not used any sources or aids other than those specified. I also confirm that the electronic version submitted is identical to the printed version. independently and have not used any sources or aids other than those specified. I also confirm that the electronic version submitted is identical to the printed version.
] ]
set align(horizon) set align(horizon)
grid( grid(
// set width of columns // set width of columns
// we need two, so make both half the page width // we need two, so make both half the page width
columns: (50%, 50%), columns: (50%, 50%),
@ -61,4 +62,5 @@
align(left, {line(length: 6cm)}), align(left, {line(length: 6cm)}),
align(left, if text.lang == "de" [ Ort, Datum ] else if text.lang == "en" [ Place, Date ] else { panic("no translation for language: ", text.lang) }), align(left, if text.lang == "de" [ Ort, Datum ] else if text.lang == "en" [ Place, Date ] else { panic("no translation for language: ", text.lang) }),
align(left, if text.lang == "de" [ Unterschrift ] else if text.lang == "en" [ Signature ] else { panic("no translation for language: ", text.lang) })) align(left, if text.lang == "de" [ Unterschrift ] else if text.lang == "en" [ Signature ] else { panic("no translation for language: ", text.lang) }))
} }
)

View File

@ -9,93 +9,106 @@
// render an outline of figures // render an outline of figures
// with a specific title and filter by a specifc kind of figure // with a specific title and filter by a specifc kind of figure
// can optionally insert a pagebreak after the outline // can optionally insert a pagebreak after the outline
// NOTE: will not render in case the listing is empty // NOTE: will not render in case the listing is empty
#let render_filtered_outline(title: str, kind: selector) = context { #let render_filtered_outline(title: str, kind: selector) = (
context {
let elems = query(figure.where(kind: kind), here()) let elems = query(figure.where(kind: kind), here())
let count = elems.len() let count = elems.len()
// only show outline if there is something to list // only show outline if there is something to list
if count > 0 { if count > 0 {
pagebreak(weak: true) pagebreak(weak: true)
outline( outline(
title: title, title: title,
target: figure.where(kind: kind)) target: figure.where(kind: kind),
)
}
} }
} )
#let render_figures_outline() = context { #let render_figures_outline() = (
let title = if (text.lang == "de") { context {
let title = if (text.lang == "de") {
"Abbildungsverzeichnis" "Abbildungsverzeichnis"
} else if text.lang == "en" { } else if text.lang == "en" {
"List of Figures" "List of Figures"
} }
render_filtered_outline(title: title, kind: image) render_filtered_outline(title: title, kind: image)
} }
)
#let render_table_outline() = context { #let render_table_outline() = (
let title = if (text.lang == "de") { context {
let title = if (text.lang == "de") {
"Tabellenverzeichnis" "Tabellenverzeichnis"
} else if text.lang == "en" { } else if text.lang == "en" {
"List of Tables" "List of Tables"
} }
render_filtered_outline(title: title, kind: table) render_filtered_outline(title: title, kind: table)
} }
)
#let render_raw_outline() = context { #let render_raw_outline() = (
let title = if (text.lang == "de") { context {
let title = if (text.lang == "de") {
"Quelltextverzeichnis" "Quelltextverzeichnis"
} else if text.lang == "en" { } else if text.lang == "en" {
"Code Snippets" "Code Snippets"
} }
render_filtered_outline(title: title, kind: raw) render_filtered_outline(title: title, kind: raw)
} }
)
#let render_heading_outline() = context { #let render_heading_outline() = (
let title = if (text.lang == "de") { context {
let title = if (text.lang == "de") {
"Inhaltsverzeichnis" "Inhaltsverzeichnis"
} else if text.lang == "en" { } else if text.lang == "en" {
"Table of Contents" "Table of Contents"
} }
pagebreak(weak: true)
outline(
target: heading.where(supplement: [chapter]),
title: title,
indent: auto)
}
#let render_appendix_outline() = context {
let supplement = if text.lang == "en" {
[Appendix]
} else {
[Anhang]
}
if query(heading.where(supplement: supplement)).len() > 0 {
let title = if (text.lang == "de") {
"Anhangsverzeichnis"
} else if text.lang == "en" {
"Table of Appendices"
}
pagebreak(weak: true) pagebreak(weak: true)
outline( outline(
target: heading.where(supplement: [chapter]),
title: title,
indent: auto,
)
}
)
#let render_appendix_outline() = (
context {
let supplement = if text.lang == "en" {
[Appendix]
} else {
[Anhang]
}
if query(heading.where(supplement: supplement)).len() > 0 {
let title = if (text.lang == "de") {
"Anhangsverzeichnis"
} else if text.lang == "en" {
"Table of Appendices"
}
pagebreak(weak: true)
outline(
target: heading.where(supplement: supplement), target: heading.where(supplement: supplement),
title: title, title: title,
indent: auto) indent: auto,
)
}
} }
} )
#let new_outline() = { #let new_outline() = {
pagebreak(weak: true) pagebreak(weak: true)
show outline.entry.where( show outline.entry.where(level: 1): it => {
level: 1,
): it => {
v(1.5em, weak: true) v(1.5em, weak: true)
strong(it) strong(it)
} }
@ -109,4 +122,4 @@
render_raw_outline() render_raw_outline()
render_appendix_outline() render_appendix_outline()
} }

View File

@ -11,4 +11,4 @@
pagebreak(weak: true) pagebreak(weak: true)
config.thesis.preface config.thesis.preface
} }
} }

View File

@ -6,51 +6,53 @@
// Edited: 28.06.2024 // Edited: 28.06.2024
// License: MIT // License: MIT
#let new_prerelease_note(config) = context { #let new_prerelease_note(config) = (
context {
pagebreak(weak: true) pagebreak(weak: true)
let thesis = config.thesis let thesis = config.thesis
let author = config.author let author = config.author
if text.lang == "de" [ if text.lang == "de" [
#heading("Vorabfassung") #heading("Vorabfassung")
] else if text.lang == "en" [ ] else if text.lang == "en" [
#heading("Preliminary Version") #heading("Preliminary Version")
] ]
v(1em) v(1em)
if text.lang == "de" [ if text.lang == "de" [
Bei dieser Ausgabe der Arbeit mit dem Thema Bei dieser Ausgabe der Arbeit mit dem Thema
] else if text.lang == "en" [ ] else if text.lang == "en" [
This edition of the work with the subject This edition of the work with the subject
] ]
v(1em) v(1em)
set align(center) set align(center)
text(weight: "bold", thesis.title) text(weight: "bold", thesis.title)
if thesis.subtitle != none { if thesis.subtitle != none {
linebreak() linebreak()
thesis.subtitle thesis.subtitle
}
set align(left)
v(1em)
set par(justify: true)
if text.lang == "de" [
handelt es sich _nicht_ um die fertige Fassung. Das Dokument kann Inhaltliche-, Grammatikalische- sowie Format-Fehler enthalten. Das Dokument ist im Rahmen der Aufgabenstellung von Seiten der #author.university nicht zur Bewertung freigegeben und ein anderer Verwendungszweck als eine Vorschau ist nicht gestattet.
] else if text.lang == "en" [
is not the final version. The document may contain errors in content, grammar and formatting. The document may not be released for evaluation to #author.university as part of the assignment, and any use other than a preview is not permitted.
]
v(1em)
h(1em)
[#author.name, #datetime.today().display()]
} }
)
set align(left)
v(1em)
set par(justify: true)
if text.lang == "de" [
handelt es sich _nicht_ um die fertige Fassung. Das Dokument kann Inhaltliche-, Grammatikalische- sowie Format-Fehler enthalten. Das Dokument ist im Rahmen der Aufgabenstellung von Seiten der #author.university nicht zur Bewertung freigegeben und ein anderer Verwendungszweck als eine Vorschau ist nicht gestattet.
] else if text.lang == "en" [
is not the final version. The document may contain errors in content, grammar and formatting. The document may not be released for evaluation to #author.university as part of the assignment, and any use other than a preview is not permitted.
]
v(1em)
h(1em)
[#author.name, #datetime.today().display()]
}

View File

@ -6,110 +6,88 @@
// Edited: 28.06.2024 // Edited: 28.06.2024
// License: MIT // License: MIT
#let new_title_page(config) = context [ #let new_title_page(config) = (
context [
#let thesis = config.thesis #let thesis = config.thesis
#let author = config.author #let author = config.author
#set align(center) #set align(center)
// title // title
#v(2cm) #v(2cm)
#text(size: 2em, weight: "semibold", thesis.title) #text(size: 2em, weight: "semibold", thesis.title)
// subtitle // subtitle
#text(size: 1.5em, thesis.subtitle) #text(size: 1.5em, thesis.subtitle)
// type of paper // type of paper
#v(1cm) #v(1cm)
#text(size: 1.5em, weight: "bold", thesis.kind) #text(size: 1.5em, weight: "bold", thesis.kind)
// faculty
#pad(top: 0.5cm)[
#if text.lang == "de" [
Praxisphase des #author.semester Studienjahrs an der Fakultät für #author.faculty
#linebreak()
im Studiengang #author.program
] else if text.lang == "en" [
Practical phase of the #author.semester academic year at the Faculty of #author.faculty
#linebreak()
in the degree program #author.program
] else [
#context panic("no translation for language: ", text.lang)
]
]
// university
#pad(top: 0.5cm)[
#if text.lang == "de" [
an der
] else if text.lang == "en" [
at
] else [
#context panic("no translation for language: ", text.lang)
]
#linebreak()
#author.university
]
#set align(horizon + left)
// faculty
#pad(top: 0.5cm)[
#if text.lang == "de" [ #if text.lang == "de" [
Praxisphase des #author.semester Studienjahrs an der Fakultät für #author.faculty #table(
#linebreak() columns: 2,
im Studiengang #author.program column-gutter: 1cm,
align: left,
stroke: none,
[*Verfasser:*], author.name,
[*Bearbeitungszeitraum:*], thesis.timeframe,
[*Matrikelnummer, Kurs:*], str(author.matriculation-number) + ", " + author.course,
[*Ausbildungsbetrieb:*], author.company,
[*Betrieblicher Betreuer:*], author.supervisor,
[*Abgabedatum:*], thesis.submission-date,
)
] else if text.lang == "en" [ ] else if text.lang == "en" [
Practical phase of the #author.semester academic year at the Faculty of #author.faculty #table(
#linebreak() columns: 2,
in the degree program #author.program column-gutter: 1cm,
align: left,
stroke: none,
[*Author:*], author.name,
[*Editing period:*], thesis.timeframe,
[*Matriculation number, course:*], str(author.matriculation-number) + ", " + author.course,
[*Training company:*], author.company,
[*Company supervisor:*], author.supervisor,
[*Submission date:*], thesis.submission-date,
)
] else [ ] else [
#context panic("no translation for language: ", text.lang) #context panic("no translation for language: ", text.lang)
] ]
]
// university #align(
#pad(top: 0.5cm)[ bottom,
#if text.lang == "de" [ grid(
an der
] else if text.lang == "en" [
at
] else [
#context panic("no translation for language: ", text.lang)
]
#linebreak()
#author.university
]
#set align(horizon + left)
#if text.lang == "de" [
#table(
columns: 2,
column-gutter: 1cm,
align: left,
stroke: none,
[*Verfasser:*],
author.name,
[*Bearbeitungszeitraum:*],
thesis.timeframe,
[*Matrikelnummer, Kurs:*],
str(author.matriculation-number) + ", " + author.course,
[*Ausbildungsbetrieb:*],
author.company,
[*Betrieblicher Betreuer:*],
author.supervisor,
[*Abgabedatum:*],
thesis.submission-date
)
] else if text.lang == "en" [
#table(
columns: 2,
column-gutter: 1cm,
align: left,
stroke: none,
[*Author:*],
author.name,
[*Editing period:*],
thesis.timeframe,
[*Matriculation number, course:*],
str(author.matriculation-number) + ", " + author.course,
[*Training company:*],
author.company,
[*Company supervisor:*],
author.supervisor,
[*Submission date:*],
thesis.submission-date
)
] else [
#context panic("no translation for language: ", text.lang)
]
#align(bottom,
grid(
// set width of columns // set width of columns
// we need two, so make both half the page width // we need two, so make both half the page width
columns: (60%, 40%), columns: (60%, 40%),
@ -121,7 +99,9 @@
#context panic("no translation for language: ", text.lang) #context panic("no translation for language: ", text.lang)
] ]
), ),
align(right, {line(length: 6cm)}))) align(right, {line(length: 6cm)})),
)
#counter(page).update(0) #counter(page).update(0)
] ]
)

View File

@ -7,4 +7,4 @@
// Edited: 05.07.2024 // Edited: 05.07.2024
// License: MIT // License: MIT
#import "glossary.typ": * #import "glossary.typ": *

View File

@ -18,9 +18,10 @@
#let watermark(config) = if config.draft { #let watermark(config) = if config.draft {
rotate(-22.5deg)[ rotate(-22.5deg)[
#rect( #rect(
radius: 1em, radius: 1em,
inset: 1em, inset: 1em,
stroke: watermark-color)[ stroke: watermark-color,
)[
#text(size: 4em, weight: "bold", fill: watermark-pattern, "DRAFT") #text(size: 4em, weight: "bold", fill: watermark-pattern, "DRAFT")
#linebreak() #linebreak()
#text(size: 1.25em, weight: "bold", fill: watermark-color)[ #text(size: 1.25em, weight: "bold", fill: watermark-color)[
@ -28,13 +29,14 @@
#linebreak() #linebreak()
document version. document version.
#linebreak() #linebreak()
#text(size: 0.75em, "Further usage without the authors consent is not permitted.")]]]} #text(size: 0.75em, "Further usage without the authors consent is not permitted.")]]]
#let numberingH(c)={
return numbering(c.numbering,..counter(heading).at(c.location()))
} }
#let currentH(level: 1)={ #let numberingH(c) = {
return numbering(c.numbering, ..counter(heading).at(c.location()))
}
#let currentH(level: 1) = {
let elems = query(selector(heading.where(level: level)).after(here())) let elems = query(selector(heading.where(level: level)).after(here()))
if elems.len() != 0 and elems.first().location().page() == here().page() { if elems.len() != 0 and elems.first().location().page() == here().page() {
@ -59,11 +61,13 @@
hyphenate: true, hyphenate: true,
dir: ltr, dir: ltr,
font: style.text.font, font: style.text.font,
fill: ABB-BLACK) fill: ABB-BLACK,
)
show heading: set text( show heading: set text(
font: style.heading.font, font: style.heading.font,
weight: "semibold") weight: "semibold",
)
set heading(supplement: [chapter]) set heading(supplement: [chapter])
@ -75,9 +79,15 @@
show heading.where(level: 3): it => v(0.5em) + it + v(0.25em) show heading.where(level: 3): it => v(0.5em) + it + v(0.25em)
// set theme for code blocks // set theme for code blocks
set raw( set raw(tab-size: style.code.tab-size)
tab-size: style.code.tab-size) show raw.where(block: false): it => box(
show raw.where(block: false): it => box(stroke: 1pt + ABB-GRAY-05, radius: 2pt, inset: (left: 2pt, right: 2pt), outset: (top: 4pt, bottom: 4pt), fill: ABB-GRAY-06, text(font: style.code.font, size: style.code.size, it.text)) stroke: 1pt + ABB-GRAY-05,
radius: 2pt,
inset: (left: 2pt, right: 2pt),
outset: (top: 4pt, bottom: 4pt),
fill: ABB-GRAY-06,
text(font: style.code.font, size: style.code.size, it.text),
)
show figure.where(kind: raw): it => align(left)[ show figure.where(kind: raw): it => align(left)[
#let content = it.body #let content = it.body
#let lang = if content.has("lang") { #let lang = if content.has("lang") {
@ -86,51 +96,55 @@
none none
} }
#block( #block(
width: 100%, width: 100%,
fill: ABB-GRAY-06, fill: ABB-GRAY-06,
stroke: 1pt + ABB-GRAY-05, stroke: 1pt + ABB-GRAY-05,
radius: 0.5em, radius: 0.5em,
inset: 0.75em, inset: 0.75em,
clip: false, clip: false,
{ {
let (columns, align, make_row) = { let (columns, align, make_row) = {
if style.code.lines {( if style.code.lines {
(
(auto, 1fr), (auto, 1fr),
(right + top, left), (right + top, left),
e => { e => {
let (i, l) = e let (i, l) = e
let n = i + 1 let n = i + 1
let n_str = if (calc.rem(n, 1) == 0) or (true and i == 0) { text(font: style.code.font, size: style.code.size, fill: ABB-BLACK, str(n)) } else { none } let n_str = if (calc.rem(n, 1) == 0) or (true and i == 0) {
text(font: style.code.font, size: style.code.size, fill: ABB-BLACK, str(n))
} else {
none
}
(n_str + h(0.5em), raw(block: true, lang: lang, l)) (n_str + h(0.5em), raw(block: true, lang: lang, l))
}) },
} )
else { } else {
( ( 1fr, ), (
( left, ), (1fr,),
e => { (left,),
let (i, l) = e e => {
raw(block: true, lang: lang, l) let (i, l) = e
} raw(block: true, lang: lang, l)
) },
} )
} }
grid( }
stroke: none, grid(
columns: columns, stroke: none,
rows: (auto,), columns: columns,
gutter: 0pt, rows: (auto,),
inset: 0.25em, gutter: 0pt,
align: (col, _) => align.at(col), inset: 0.25em,
fill: ABB-GRAY-06, align: (col, _) => align.at(col),
..content fill: ABB-GRAY-06,
.text ..content.text.split("\n").enumerate().map(make_row).flatten().map(c => if c.has("text") and c.text == "" {
.split("\n") v(1em)
.enumerate() } else {
.map(make_row) c
.flatten() })
.map(c => if c.has("text") and c.text == "" { v(1em) } else { c }) )
) },
}
) )
#v(-1em) #v(-1em)
#align(center + top, it.caption) #align(center + top, it.caption)
@ -167,8 +181,20 @@
stroke: (x, y) => ( stroke: (x, y) => (
left: none, left: none,
right: none, right: none,
top: if y == 0 { 1.5pt } else if y < 2 { 1pt } else { 0.5pt }, top: if y == 0 {
bottom: if y == 0 { 1pt } else { 1.5pt } )) 1.5pt
} else if y < 2 {
1pt
} else {
0.5pt
},
bottom: if y == 0 {
1pt
} else {
1.5pt
},
),
)
// make table header bold // make table header bold
show table.cell.where(y: 0): set text(weight: "bold") show table.cell.where(y: 0): set text(weight: "bold")
@ -177,7 +203,8 @@
set par( set par(
justify: true, justify: true,
first-line-indent: 1em, first-line-indent: 1em,
leading: 1em) leading: 1em,
)
// give links a color // give links a color
show link: set text(fill: style.link.color) show link: set text(fill: style.link.color)
@ -193,10 +220,11 @@
top: style.page.margin.top + style.header.underline-top-padding + style.header.content-padding, top: style.page.margin.top + style.header.underline-top-padding + style.header.content-padding,
bottom: style.page.margin.bottom + style.footer.content-padding, bottom: style.page.margin.bottom + style.footer.content-padding,
left: style.page.margin.left, left: style.page.margin.left,
right: style.page.margin.right), right: style.page.margin.right,
),
numbering: (..nums) => { numbering: (..nums) => {
let current-page = here().page() let current-page = here().page()
if current-page == 1{ if current-page == 1 {
[] []
} else if query(<end-of-prelude>).first().location().page() > current-page { } else if query(<end-of-prelude>).first().location().page() > current-page {
numbering("I", nums.pos().first()) numbering("I", nums.pos().first())
@ -237,7 +265,10 @@
// right align logo of DHBW // right align logo of DHBW
align(right, image("res/DHBW.svg", height: style.header.logo-height))) align(right, image("res/DHBW.svg", height: style.header.logo-height)))
} else if query(<end-of-content>).first().location().page() >= current-page and query(<end-of-prelude>).first().location().page() < current-page + 1 { } else if query(<end-of-content>).first().location().page() >= current-page and query(<end-of-prelude>)
.first()
.location()
.page() < current-page + 1 {
let heading = currentH() let heading = currentH()
heading.at(0) heading.at(0)
@ -250,7 +281,8 @@
v(style.header.underline-top-padding - 1em) v(style.header.underline-top-padding - 1em)
line(length: 100%) line(length: 100%)
} }
}) },
)
body body
} }

View File

@ -4,11 +4,9 @@
#lorem(50) #lorem(50)
== More raw data == More raw data
#lorem(50) #lorem(50)
#figure( #figure(```
``` ```)
```
)

View File

@ -15,7 +15,8 @@
university: "DHBW Mannheim", university: "DHBW Mannheim",
company: "ABB AG", company: "ABB AG",
supervisor: "Benny Goodman", supervisor: "Benny Goodman",
matriculation-number: 123456789), matriculation-number: 123456789,
),
thesis: ( thesis: (
title: "Unofficial ABB/DHBW Typst template", title: "Unofficial ABB/DHBW Typst template",
subtitle: "for reports and thesises", subtitle: "for reports and thesises",
@ -25,10 +26,12 @@
summary: summary, summary: summary,
abstract: abstract, abstract: abstract,
preface: include "preface.typ", preface: include "preface.typ",
keywords: ( "IT", "other stuff" ), keywords: ("IT", "other stuff"),
bibliography: bibliography("refs.bib"), bibliography: bibliography("refs.bib"),
glossary: yaml("glossary.yml"), glossary: yaml("glossary.yml"),
appendices: include "appendix.typ"))) appendices: include "appendix.typ",
),
))
#import "@preview/wrap-it:0.1.0": wrap-content #import "@preview/wrap-it:0.1.0": wrap-content
@ -54,15 +57,16 @@
$ $
angle.l a, b angle.r &= arrow(a) dot arrow(b) \ angle.l a, b angle.r &= arrow(a) dot arrow(b) \
&= a_1 b_1 + a_2 b_2 + ... a_n b_n \ &= a_1 b_1 + a_2 b_2 + ... a_n b_n \
&= sum_(i=1)^n a_i b_i. &= sum_(i=1)^n a_i b_i.
$ $
#lorem(140) #lorem(140)
#wrap-content( #wrap-content(
figure(image("assets/digitaldog.jpg", width: 200pt), caption: [ Some image caption ]), figure(image("assets/digitaldog.jpg", width: 200pt), caption: [ Some image caption ]),
lorem(200)) lorem(200),
)
#figure( #figure(
table( table(
@ -76,8 +80,10 @@ $
[2023-03-18], [Yoga], [200], [2023-03-18], [Yoga], [200],
[2023-03-15], [Swimming], [400], [2023-03-15], [Swimming], [400],
[2023-03-17], [Weightlifting], [250], [2023-03-17], [Weightlifting], [250],
[2023-03-18], [Yoga], [200]), [2023-03-18], [Yoga], [200],
caption: [ Some table ]) ),
caption: [ Some table ],
)
#pagebreak() #pagebreak()
@ -86,14 +92,16 @@ $
#figure( #figure(
```rust ```rust
use std::env; use std::env;
use std::fs::OpenOptions; use std::fs::OpenOptions;
use std::io::Write; use std::io::Write;
fn main() { fn main() {
println!("Hello, World!!!"); println!("Hello, World!!!");
} }
```, caption: [Some code]) ```,
caption: [Some code],
)
#lorem(100) #lorem(100)