2024-06-27 13:57:04 +00:00
|
|
|
|
|
|
|
// .--------------------------------------------------------------------------.
|
|
|
|
// | Global style of document |
|
|
|
|
// '--------------------------------------------------------------------------'
|
|
|
|
|
|
|
|
// Author: Sven Vogel
|
|
|
|
// Edited: 27.06.2024
|
|
|
|
// License: MIT
|
|
|
|
|
2024-07-08 07:55:38 +00:00
|
|
|
#import "branding.typ": *
|
|
|
|
|
2024-08-20 07:49:13 +00:00
|
|
|
#let watermark-color = luma(50%).transparentize(70%)
|
2024-07-03 12:16:00 +00:00
|
|
|
|
2024-07-12 13:06:32 +00:00
|
|
|
#let watermark-pattern = pattern(size: (5pt, 5pt))[
|
2024-08-27 19:16:23 +00:00
|
|
|
#place(
|
|
|
|
line(
|
|
|
|
start: (50%, 0%),
|
|
|
|
end: (50%, 100%),
|
|
|
|
stroke: (paint: watermark-color, thickness: 3pt),
|
|
|
|
),
|
|
|
|
)
|
2024-07-12 13:06:32 +00:00
|
|
|
]
|
|
|
|
|
2024-07-05 11:04:27 +00:00
|
|
|
#let watermark(config) = if config.draft {
|
|
|
|
rotate(-22.5deg)[
|
|
|
|
#rect(
|
2024-08-20 07:49:13 +00:00
|
|
|
radius: 1em,
|
|
|
|
inset: 1em,
|
|
|
|
stroke: watermark-color,
|
|
|
|
)[
|
2024-07-12 13:06:32 +00:00
|
|
|
#text(size: 4em, weight: "bold", fill: watermark-pattern, "DRAFT")
|
2024-07-05 11:04:27 +00:00
|
|
|
#linebreak()
|
|
|
|
#text(size: 1.25em, weight: "bold", fill: watermark-color)[
|
|
|
|
This page is part of a preliminary
|
|
|
|
#linebreak()
|
|
|
|
document version.
|
|
|
|
#linebreak()
|
2024-07-08 19:57:23 +00:00
|
|
|
#text(
|
|
|
|
size: 0.75em,
|
|
|
|
"Further usage without the authors consent is not permitted.",
|
|
|
|
)]]]
|
2024-08-20 07:49:13 +00:00
|
|
|
}
|
2024-07-03 12:16:00 +00:00
|
|
|
|
2024-08-20 07:49:13 +00:00
|
|
|
#let numberingH(c) = {
|
|
|
|
return numbering(c.numbering, ..counter(heading).at(c.location()))
|
2024-07-17 13:48:15 +00:00
|
|
|
}
|
|
|
|
|
2024-08-20 07:49:13 +00:00
|
|
|
#let currentH(level: 1) = {
|
2024-07-17 13:48:15 +00:00
|
|
|
let elems = query(selector(heading.where(level: level)).after(here()))
|
|
|
|
|
|
|
|
if elems.len() != 0 and elems.first().location().page() == here().page() {
|
|
|
|
return (numberingH(elems.first()), elems.first().body)
|
|
|
|
} else {
|
|
|
|
elems = query(selector(heading.where(level: level)).before(here()))
|
|
|
|
if elems.len() != 0 {
|
|
|
|
return (numberingH(elems.last()), elems.last().body)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
2024-06-27 13:57:04 +00:00
|
|
|
// global style of document
|
2024-07-05 11:04:27 +00:00
|
|
|
#let global_styled_doc(config, body) = {
|
2024-07-02 08:57:38 +00:00
|
|
|
let thesis = config.thesis
|
|
|
|
let style = config.style
|
2024-07-01 10:13:57 +00:00
|
|
|
|
2024-07-02 08:57:38 +00:00
|
|
|
set text(
|
|
|
|
size: style.text.size,
|
2024-06-28 09:54:30 +00:00
|
|
|
ligatures: true,
|
|
|
|
hyphenate: true,
|
|
|
|
dir: ltr,
|
2024-07-08 07:55:38 +00:00
|
|
|
font: style.text.font,
|
2024-08-20 07:49:13 +00:00
|
|
|
fill: ABB-BLACK,
|
|
|
|
)
|
2024-06-28 09:54:30 +00:00
|
|
|
|
2024-07-02 08:57:38 +00:00
|
|
|
show heading: set text(
|
|
|
|
font: style.heading.font,
|
2024-09-27 15:43:58 +00:00
|
|
|
weight: "bold"
|
2024-08-20 07:49:13 +00:00
|
|
|
)
|
2024-06-28 09:54:30 +00:00
|
|
|
|
2024-08-26 14:10:52 +00:00
|
|
|
let header-supplement = if config.lang == "de" {
|
|
|
|
"Kapitel"
|
|
|
|
} else {
|
|
|
|
"chapter"
|
|
|
|
}
|
|
|
|
|
|
|
|
set heading(supplement: [#header-supplement])
|
2024-07-01 12:46:32 +00:00
|
|
|
|
2024-07-08 07:58:46 +00:00
|
|
|
set math.equation(numbering: "(1)")
|
2024-09-27 15:43:58 +00:00
|
|
|
show math.equation: set text(font: "Fira Math", size: 12pt)
|
2024-07-08 07:58:46 +00:00
|
|
|
|
2024-06-28 09:54:30 +00:00
|
|
|
// Set header spacing
|
2024-07-02 08:57:38 +00:00
|
|
|
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)
|
2024-06-28 09:54:30 +00:00
|
|
|
|
2024-07-02 08:57:38 +00:00
|
|
|
// set theme for code blocks
|
2024-08-20 07:49:13 +00:00
|
|
|
set raw(tab-size: style.code.tab-size)
|
|
|
|
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),
|
|
|
|
)
|
2024-07-19 13:08:11 +00:00
|
|
|
show figure.where(kind: raw): it => align(left)[
|
|
|
|
#let content = it.body
|
2024-07-22 06:41:02 +00:00
|
|
|
#let lang = if content.has("lang") {
|
|
|
|
it.body.lang
|
|
|
|
} else {
|
|
|
|
none
|
|
|
|
}
|
2024-07-19 13:08:11 +00:00
|
|
|
#block(
|
2024-08-20 07:49:13 +00:00
|
|
|
width: 100%,
|
|
|
|
fill: ABB-GRAY-06,
|
|
|
|
stroke: 1pt + ABB-GRAY-05,
|
|
|
|
radius: 0.5em,
|
|
|
|
inset: 0.75em,
|
|
|
|
clip: false,
|
|
|
|
{
|
|
|
|
let (columns, align, make_row) = {
|
|
|
|
if style.code.lines {
|
|
|
|
(
|
2024-07-19 13:08:11 +00:00
|
|
|
(auto, 1fr),
|
|
|
|
(right + top, left),
|
|
|
|
e => {
|
|
|
|
let (i, l) = e
|
|
|
|
let n = i + 1
|
2024-08-27 19:16:23 +00:00
|
|
|
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),
|
2024-08-20 07:56:39 +00:00
|
|
|
)
|
2024-08-27 19:16:23 +00:00
|
|
|
} else {
|
|
|
|
none
|
|
|
|
}
|
|
|
|
(n_str + h(0.5em), raw(block: true, lang: lang, l))
|
|
|
|
},
|
|
|
|
)
|
|
|
|
} else {
|
|
|
|
(
|
|
|
|
(1fr,),
|
|
|
|
(left,),
|
|
|
|
e => {
|
|
|
|
let (i, l) = e
|
|
|
|
raw(block: true, lang: lang, l)
|
|
|
|
},
|
|
|
|
)
|
2024-07-19 13:08:11 +00:00
|
|
|
}
|
2024-08-27 19:16:23 +00:00
|
|
|
}
|
|
|
|
grid(
|
|
|
|
stroke: none,
|
|
|
|
columns: columns,
|
|
|
|
rows: (auto,),
|
|
|
|
gutter: 0pt,
|
|
|
|
inset: 0.25em,
|
|
|
|
align: (col, _) => align.at(col),
|
|
|
|
fill: ABB-GRAY-06,
|
|
|
|
..content
|
|
|
|
.text
|
|
|
|
.split("\n")
|
|
|
|
.enumerate()
|
|
|
|
.map(make_row)
|
|
|
|
.flatten()
|
|
|
|
.map(c => if c.has("text") and c.text == "" {
|
|
|
|
v(1em)
|
|
|
|
} else {
|
|
|
|
c
|
|
|
|
})
|
|
|
|
)
|
|
|
|
},
|
2024-07-19 13:08:11 +00:00
|
|
|
)
|
|
|
|
#v(-1em)
|
|
|
|
#align(center + top, it.caption)
|
|
|
|
]
|
2024-06-27 13:57:04 +00:00
|
|
|
|
2024-07-05 07:49:08 +00:00
|
|
|
show figure: set block(breakable: true)
|
|
|
|
|
2024-07-18 10:18:01 +00:00
|
|
|
// make figure supplements bold
|
|
|
|
// based on: https://github.com/typst/typst/discussions/3871
|
|
|
|
show figure.caption: c => [
|
|
|
|
#if c.body.fields().len() > 0 {
|
2024-09-27 15:43:58 +00:00
|
|
|
text(weight: "medium")[
|
2024-07-18 10:20:38 +00:00
|
|
|
#c.supplement #c.counter.display("1.1.1")
|
2024-07-18 10:18:01 +00:00
|
|
|
]
|
|
|
|
c.separator
|
|
|
|
}
|
|
|
|
#c.body
|
|
|
|
]
|
|
|
|
|
2024-07-18 10:19:35 +00:00
|
|
|
// change the display supplement according to the text langugae
|
|
|
|
// based on: https://github.com/typst/typst/issues/3273
|
|
|
|
show figure.where(kind: raw): set figure(supplement: context {
|
|
|
|
if text.lang == "de" {
|
|
|
|
"Quelltext"
|
|
|
|
} else {
|
|
|
|
"Listing"
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2024-07-08 07:34:33 +00:00
|
|
|
// APA style table
|
|
|
|
set table(
|
|
|
|
inset: 0.5em,
|
|
|
|
align: left,
|
|
|
|
stroke: (x, y) => (
|
|
|
|
left: none,
|
|
|
|
right: none,
|
2024-07-08 19:57:23 +00:00
|
|
|
top: if y == 0 {
|
|
|
|
1.5pt
|
|
|
|
} else if y < 2 {
|
|
|
|
1pt
|
|
|
|
} else {
|
2024-08-27 19:16:23 +00:00
|
|
|
0.5pt
|
2024-07-08 19:57:23 +00:00
|
|
|
},
|
|
|
|
bottom: if y == 0 {
|
|
|
|
1pt
|
|
|
|
} else {
|
|
|
|
1.5pt
|
|
|
|
},
|
|
|
|
),
|
|
|
|
)
|
2024-07-08 07:34:33 +00:00
|
|
|
|
|
|
|
// make table header bold
|
|
|
|
show table.cell.where(y: 0): set text(weight: "bold")
|
|
|
|
|
2024-07-02 08:57:38 +00:00
|
|
|
set block(spacing: 2em)
|
|
|
|
set par(
|
2024-06-28 13:20:58 +00:00
|
|
|
justify: true,
|
|
|
|
first-line-indent: 1em,
|
2024-07-08 19:57:23 +00:00
|
|
|
leading: 1em,
|
|
|
|
)
|
2024-06-28 13:20:58 +00:00
|
|
|
|
2024-07-02 08:57:38 +00:00
|
|
|
// give links a color
|
|
|
|
show link: set text(fill: style.link.color)
|
|
|
|
show ref: set text(fill: style.link.color)
|
2024-06-28 09:54:30 +00:00
|
|
|
|
2024-07-02 08:57:38 +00:00
|
|
|
set heading(numbering: none)
|
|
|
|
set page(
|
2024-07-05 08:18:53 +00:00
|
|
|
paper: style.page.format,
|
2024-07-05 11:04:27 +00:00
|
|
|
foreground: watermark(config),
|
|
|
|
header-ascent: style.header.content-padding,
|
|
|
|
footer-descent: style.header.content-padding,
|
2024-07-02 08:57:38 +00:00
|
|
|
margin: (
|
2024-08-27 19:16:23 +00:00
|
|
|
top: style.page.margin.top + style.header.underline-top-padding + style
|
2024-08-27 17:52:07 +00:00
|
|
|
.header
|
2024-08-27 19:16:23 +00:00
|
|
|
.content-padding,
|
2024-07-05 11:04:27 +00:00
|
|
|
bottom: style.page.margin.bottom + style.footer.content-padding,
|
2024-07-05 08:18:53 +00:00
|
|
|
left: style.page.margin.left,
|
2024-07-08 19:57:23 +00:00
|
|
|
right: style.page.margin.right,
|
|
|
|
),
|
2024-07-01 10:13:57 +00:00
|
|
|
numbering: (..nums) => {
|
|
|
|
let current-page = here().page()
|
2024-07-08 19:57:23 +00:00
|
|
|
if current-page == 1 {
|
2024-07-01 10:13:57 +00:00
|
|
|
[]
|
2024-08-27 17:52:07 +00:00
|
|
|
} else if query(<end-of-prelude>)
|
|
|
|
.first()
|
|
|
|
.location()
|
|
|
|
.page() > current-page {
|
2024-07-01 11:50:54 +00:00
|
|
|
numbering("I", nums.pos().first())
|
2024-08-27 17:52:07 +00:00
|
|
|
} else if query(<end-of-content>)
|
|
|
|
.first()
|
|
|
|
.location()
|
|
|
|
.page() >= current-page {
|
2024-07-03 13:24:01 +00:00
|
|
|
numbering("1", nums.pos().first())
|
2024-07-01 10:13:57 +00:00
|
|
|
} else {
|
2024-07-01 11:50:54 +00:00
|
|
|
numbering("a", nums.pos().first())
|
2024-07-01 10:13:57 +00:00
|
|
|
}
|
|
|
|
},
|
2024-07-03 13:24:01 +00:00
|
|
|
footer: context [
|
|
|
|
#let page-counter = counter(page).get().first()
|
|
|
|
#let page-number = here().page()
|
2024-07-18 08:49:47 +00:00
|
|
|
#set align(center)
|
2024-07-12 13:06:32 +00:00
|
|
|
|
2024-07-03 13:24:01 +00:00
|
|
|
#if page-number == 1 {
|
|
|
|
[]
|
|
|
|
} else if query(<end-of-prelude>).first().location().page() > page-number {
|
2024-07-17 13:48:15 +00:00
|
|
|
set align(center)
|
2024-07-03 13:24:01 +00:00
|
|
|
numbering("I", page-counter)
|
|
|
|
} else if query(<end-of-content>).first().location().page() >= page-number {
|
2024-07-08 19:57:23 +00:00
|
|
|
numbering(
|
|
|
|
"1 / 1",
|
|
|
|
page-counter,
|
|
|
|
counter(page).at(<end-of-content>).last(),
|
|
|
|
)
|
2024-07-03 13:24:01 +00:00
|
|
|
} else {
|
|
|
|
numbering("a", page-counter)
|
|
|
|
}
|
|
|
|
],
|
2024-07-01 10:13:57 +00:00
|
|
|
header: context {
|
|
|
|
set align(left)
|
2024-07-17 13:48:15 +00:00
|
|
|
let current-page = here().page()
|
|
|
|
|
|
|
|
if current-page == 1 {
|
2024-07-01 10:13:57 +00:00
|
|
|
// logo of ABB and DHBW
|
|
|
|
grid(
|
|
|
|
// set width of columns
|
|
|
|
// we need two, so make both half the page width
|
|
|
|
columns: (50%, 50%),
|
|
|
|
// left align logo of ABB
|
2024-11-11 13:37:16 +00:00
|
|
|
align(left, image(style.header.logo-image, height: style.header.logo-height)),
|
2024-07-01 10:13:57 +00:00
|
|
|
// right align logo of DHBW
|
2024-07-02 08:57:38 +00:00
|
|
|
align(right, image("res/DHBW.svg", height: style.header.logo-height)))
|
2024-07-01 10:13:57 +00:00
|
|
|
|
2024-08-27 19:16:23 +00:00
|
|
|
} else if query(<end-of-content>)
|
2024-08-27 17:52:07 +00:00
|
|
|
.first()
|
|
|
|
.location()
|
2024-08-27 19:16:23 +00:00
|
|
|
.page() >= current-page and query(<end-of-prelude>)
|
|
|
|
.first()
|
|
|
|
.location()
|
|
|
|
.page() < current-page + 1 {
|
2024-07-17 13:48:15 +00:00
|
|
|
let heading = currentH()
|
2024-07-01 10:13:57 +00:00
|
|
|
|
2024-07-17 13:48:15 +00:00
|
|
|
heading.at(0)
|
2024-07-18 08:58:23 +00:00
|
|
|
h(0.5em)
|
2024-07-17 13:48:15 +00:00
|
|
|
heading.at(1)
|
2024-07-02 08:57:38 +00:00
|
|
|
v(style.header.underline-top-padding - 1em)
|
2024-07-01 10:13:57 +00:00
|
|
|
line(length: 100%)
|
|
|
|
} else {
|
2024-07-17 13:48:15 +00:00
|
|
|
config.thesis.title
|
2024-07-02 08:57:38 +00:00
|
|
|
v(style.header.underline-top-padding - 1em)
|
2024-07-01 10:13:57 +00:00
|
|
|
line(length: 100%)
|
|
|
|
}
|
2024-07-08 19:57:23 +00:00
|
|
|
},
|
|
|
|
)
|
2024-07-01 10:13:57 +00:00
|
|
|
|
2024-07-02 08:57:38 +00:00
|
|
|
body
|
|
|
|
}
|
2024-07-01 10:13:57 +00:00
|
|
|
|
2024-07-05 11:04:27 +00:00
|
|
|
#let content_styled(config, body) = {
|
2024-07-11 09:41:04 +00:00
|
|
|
set heading(numbering: "1.1.1")
|
2024-07-01 11:50:54 +00:00
|
|
|
|
2024-07-05 11:04:27 +00:00
|
|
|
body
|
|
|
|
}
|
2024-07-01 11:50:54 +00:00
|
|
|
|
2024-07-05 11:04:27 +00:00
|
|
|
#let end_styled(config, body) = {
|
2024-07-11 09:41:04 +00:00
|
|
|
set heading(numbering: "1.1.1")
|
2024-07-01 11:50:54 +00:00
|
|
|
|
2024-07-05 11:04:27 +00:00
|
|
|
body
|
|
|
|
}
|