From a709ad276552b032e1ee5d229542e5ca24f55373 Mon Sep 17 00:00:00 2001 From: Sven Vogel Date: Wed, 17 Jul 2024 15:48:15 +0200 Subject: [PATCH 1/3] changed style of header and footer --- src/style.typ | 63 ++++++++++++++++++++++------------------------- template/main.typ | 3 +++ 2 files changed, 32 insertions(+), 34 deletions(-) diff --git a/src/style.typ b/src/style.typ index 41d5716..ce0ba6a 100644 --- a/src/style.typ +++ b/src/style.typ @@ -30,6 +30,24 @@ #linebreak() #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 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 "" +} + // global style of document #let global_styled_doc(config, body) = { let thesis = config.thesis @@ -94,7 +112,7 @@ header-ascent: style.header.content-padding, footer-descent: style.header.content-padding, margin: ( - top: style.page.margin.top + style.header.logo-height + 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, left: style.page.margin.left, right: style.page.margin.right), @@ -111,18 +129,13 @@ } }, footer: context [ - #set align(center) #let page-counter = counter(page).get().first() #let page-number = here().page() - #if page-number > 1 { - line(length: 100%) - v(style.header.underline-top-padding - 1em) - } - #if page-number == 1 { [] } else if query().first().location().page() > page-number { + set align(center) numbering("I", page-counter) } else if query().first().location().page() >= page-number { numbering("1 / 1", page-counter, counter(page).at().last()) @@ -132,7 +145,9 @@ ], header: context { set align(left) - if here().page() == 1 { + let current-page = here().page() + + if current-page == 1 { // logo of ABB and DHBW grid( // set width of columns @@ -143,36 +158,16 @@ // right align logo of DHBW align(right, image("res/DHBW.svg", height: style.header.logo-height))) - } else if query().first().location().page() <= here().page() { - let headers-before = query(selector(heading.where(numbering: "1.", level: 1)).before(here())) + } else if query().first().location().page() >= current-page and query().first().location().page() < current-page + 1 { + let heading = currentH() - let header-title = thesis.title - - if headers-before.len() > 0 { - header-title = headers-before.last().body - } else { - let headers-after = query(selector(heading.where(numbering: "1.1.1", level: 1)).after(here())) - - if headers-after.len() > 0 { - header-title = headers-after.first().body - } - } - - grid( - columns: (1fr, auto), - align: (horizon, bottom), - context [ _ #header-title _ ], - image("res/DHBW.svg", height: style.header.logo-height)) - + heading.at(0) + h(1em) + heading.at(1) v(style.header.underline-top-padding - 1em) line(length: 100%) } else { - grid( - columns: (1fr, auto), - align: (horizon, bottom), - context [ _ #config.thesis.title _ ], - image("res/DHBW.svg", height: style.header.logo-height) - ) + config.thesis.title v(style.header.underline-top-padding - 1em) line(length: 100%) } diff --git a/template/main.typ b/template/main.typ index 8f93a1a..1b7c40a 100644 --- a/template/main.typ +++ b/template/main.typ @@ -118,6 +118,9 @@ fn main() { } ```, caption: [Some code]) +#pagebreak() + + = Conclusion #lorem(320) \ No newline at end of file -- 2.40.1 From 9ae921d52ae52c9b4717b17c237ed9b736be94e0 Mon Sep 17 00:00:00 2001 From: Sven Vogel Date: Thu, 18 Jul 2024 10:49:47 +0200 Subject: [PATCH 2/3] changed footer alignment to center --- src/style.typ | 1 + 1 file changed, 1 insertion(+) diff --git a/src/style.typ b/src/style.typ index ce0ba6a..f9529ef 100644 --- a/src/style.typ +++ b/src/style.typ @@ -131,6 +131,7 @@ footer: context [ #let page-counter = counter(page).get().first() #let page-number = here().page() + #set align(center) #if page-number == 1 { [] -- 2.40.1 From ca4312bfdeea2f5842083c294b6f4b9bace3f212 Mon Sep 17 00:00:00 2001 From: Sven Vogel Date: Thu, 18 Jul 2024 10:58:23 +0200 Subject: [PATCH 3/3] changed header numbering title spacing to 0.5em --- src/style.typ | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/style.typ b/src/style.typ index f9529ef..0af11a0 100644 --- a/src/style.typ +++ b/src/style.typ @@ -163,7 +163,7 @@ let heading = currentH() heading.at(0) - h(1em) + h(0.5em) heading.at(1) v(style.header.underline-top-padding - 1em) line(length: 100%) -- 2.40.1