From b5d83ba7de9d812b333d89405a2468fab9991ac5 Mon Sep 17 00:00:00 2001 From: Thomas Forgione Date: Tue, 9 Jul 2024 11:45:16 +0200 Subject: [PATCH] Headers --- main.typ | 40 ++++++++++++++++++++++++++++++++++++++++ template.typ | 48 +++++++++++++++++++++++++++--------------------- 2 files changed, 67 insertions(+), 21 deletions(-) diff --git a/main.typ b/main.typ index 7bf36fa..0c1e0a4 100644 --- a/main.typ +++ b/main.typ @@ -1,3 +1,4 @@ +#import "@preview/chic-hdr:0.4.0": * #import "template.typ" #show: doc => template.phd(doc) @@ -18,6 +19,43 @@ #include "introduction/main.typ" +#show: chic.with( + odd: ( + chic-footer( + right-side: chic-page-number(), + ), + chic-header( + right-side: context { + [ #counter(heading).display((..args) => { + let arr = args.pos() + if arr.len() == 1 { + arr.at(0) + } else { + str(arr.at(0)) + "." + str(arr.at(1)) + } + }) + #chic-heading-name(fill: true, level: 2, dir: "prev") ] + }, + ), + chic-separator(1pt), + chic-offset(7pt), + chic-height(1.5cm) + ), + even: ( + chic-footer( + left-side: chic-page-number(), + ), + chic-header( + left-side: context { + [ Chapter #counter(heading).get().at(0) #chic-heading-name(fill: true, level: 1, dir: "prev") ] + }, + ), + chic-separator(1pt), + chic-offset(7pt), + chic-height(1.5cm) + ), +) + #include "foreword/main.typ" #include "related-work/main.typ" @@ -28,6 +66,8 @@ #include "mobile/main.typ" +#show: doc => { set page(header: [], footer: []); doc } + #pagebreak() #bibliography("bib.bib", style: "chicago-author-date") diff --git a/template.typ b/template.typ index bd7ae86..cc8c8d7 100644 --- a/template.typ +++ b/template.typ @@ -65,17 +65,32 @@ }) show heading.where(level: 1): it => { - align(right, { - v(100pt) - if it.numbering != none { - text(size: 50pt, weight: "bold")[Chapter ] - set heading(numbering: (..nums) => str(nums.pos().at(0))) - text(counter(heading).display(), size: 150pt, fill: rgb(173, 216, 230)) - } - v(50pt) - text(it.body, size: 40pt, weight: "bold") - v(40pt) - }) + if it.numbering != none { + set page(header: [], footer: []) + align(right, { + v(100pt) + if it.numbering != none { + text(size: 50pt, weight: "bold")[Chapter ] + set heading(numbering: (..nums) => str(nums.pos().at(0))) + text(counter(heading).display(), size: 150pt, fill: rgb(173, 216, 230)) + } + v(50pt) + text(it.body, size: 40pt, weight: "bold") + v(40pt) + }) + } else { + align(right, { + v(100pt) + if it.numbering != none { + text(size: 50pt, weight: "bold")[Chapter ] + set heading(numbering: (..nums) => str(nums.pos().at(0))) + text(counter(heading).display(), size: 150pt, fill: rgb(173, 216, 230)) + } + v(50pt) + text(it.body, size: 40pt, weight: "bold") + v(40pt) + }) + } } show heading.where(level: 2): set text(size: 15pt) @@ -85,17 +100,8 @@ } #let beforeChapter = () => { - - pagebreak() - locate(loc => { - // This is not fully working but I don't know how to do better - if calc.rem(loc.position().page, 2) == 0 { - pagebreak() - } - }) - + pagebreak(to: "odd") } #let afterNumberedChapter = () => { - pagebreak() }