added: outline

This commit is contained in:
Sven Vogel 2024-06-28 15:20:58 +02:00
parent 381e8d5d42
commit 26f947a0d3
10 changed files with 197 additions and 24 deletions

BIN
examples/digitaldog.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 KiB

View File

@ -5,4 +5,31 @@
= Lorem Ipsum = Lorem Ipsum
#lorem(50) #lorem(25)
#lorem(100)
== Lorem Ipsum 2
#lorem(200)
= Lorem Ipsum 3
#lorem(15)
$ integral_2^8 4x^2 $
#figure(image("digitaldog.jpg", height: 480pt), caption: [ Some image caption ])
#figure(
table(
columns: 2,
"Hello", "World"),
caption: [ Some table ])
#figure(
```rust
fn main() -> {
}
```, caption: [Some code])

17
src/pages/abstract.typ Normal file
View File

@ -0,0 +1,17 @@
#let new_abstract(thesis) = context [
#pagebreak(weak: true)
#align(center + horizon)[
#if text.lang == "de" [
= Zusammenfassung
#thesis.summary
]
#pagebreak(weak: true)
= Abstract
#thesis.abstract
]
]

View File

@ -3,6 +3,7 @@
thesis, thesis,
author) = context [ author) = context [
#v(2em)
#if text.lang == "de" [ #if text.lang == "de" [
#text(size: 20pt, weight: "semibold", font: "Montserrat", "Sperrvermerk") #text(size: 20pt, weight: "semibold", font: "Montserrat", "Sperrvermerk")
] else if text.lang == "en" [ ] else if text.lang == "en" [

View File

@ -1,6 +1,7 @@
#let new_declaration_of_authorship(thesis, author) = context [ #let new_declaration_of_authorship(thesis, author) = context [
#v(2em)
#if text.lang == "de" [ #if text.lang == "de" [
#text(size: 20pt, weight: "semibold", font: "Montserrat", "Selbständigkeitserklärung") #text(size: 20pt, weight: "semibold", font: "Montserrat", "Selbständigkeitserklärung")
] else if text.lang == "en" [ ] else if text.lang == "en" [

77
src/pages/outline.typ Normal file
View File

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

View File

@ -1,6 +1,7 @@
#let new_prerelease_note(thesis, author) = context [ #let new_prerelease_note(thesis, author) = context [
#v(2em)
#if text.lang == "de" [ #if text.lang == "de" [
#text(size: 20pt, weight: "semibold", font: "Montserrat", "Vorabfassung") #text(size: 20pt, weight: "semibold", font: "Montserrat", "Vorabfassung")
] else if text.lang == "en" [ ] else if text.lang == "en" [

View File

@ -28,23 +28,14 @@
#v(1cm) #v(1cm)
#text(size: 1.5em, weight: "bold", thesis.kind) #text(size: 1.5em, weight: "bold", thesis.kind)
// number of semester
#if text.lang == "de" [
Praxisphase des #author.semester Studienjahrs
] else if text.lang == "en" [
Practical phase of the #author.semester academic year
] else [
#context panic("no translation for language: ", text.lang)
]
// faculty // faculty
#pad(top: 0.5cm)[ #pad(top: 0.5cm)[
#if text.lang == "de" [ #if text.lang == "de" [
an der Fakultät für #author.faculty Praxisphase des #author.semester Studienjahrs an der Fakultät für #author.faculty
#linebreak() #linebreak()
im Studiengang #author.program im Studiengang #author.program
] else if text.lang == "en" [ ] else if text.lang == "en" [
at the Faculty of #author.faculty Practical phase of the #author.semester academic year at the Faculty of #author.faculty
#linebreak() #linebreak()
in the degree program #author.program in the degree program #author.program
] else [ ] else [

View File

@ -33,14 +33,20 @@
#set raw(tab-size: 4) #set raw(tab-size: 4)
#set block(spacing: 2em)
#set par(
justify: true,
first-line-indent: 1em,
leading: 1em)
#doc #doc
] ]
#let HeaderPaddingBottom = 3em #let HeaderPaddingBottom = 1.5em
#let LogoHeight = 3em #let LogoHeight = 3em
#let HeaderUnderlinePaddingTop = 8pt #let HeaderUnderlinePaddingTop = 0pt
#let prelude_styled(doc: content, thesis) = context [ #let prelude_styled(body: content, thesis) = context [
#set page( #set page(
header-ascent: HeaderUnderlinePaddingTop + HeaderPaddingBottom, header-ascent: HeaderUnderlinePaddingTop + HeaderPaddingBottom,
numbering: "I", numbering: "I",
@ -56,5 +62,40 @@
#line(length: 100%) #line(length: 100%)
]) ])
#doc #body
]
#let content_styled(body: content, thesis) = [
#set heading(numbering: "1.")
#page(
header-ascent: HeaderUnderlinePaddingTop + HeaderPaddingBottom,
numbering: "1/1",
footer-descent: 1em,
margin: (top: 2.5cm + LogoHeight + HeaderUnderlinePaddingTop + HeaderPaddingBottom, bottom: 2.5cm + 1em),
header: context [
#let headers-before = query(selector(heading.where(numbering: "1.", level: 1)).before(here()))
#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.", 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("pages/res/DHBW.svg", height: LogoHeight)
)
#v(HeaderUnderlinePaddingTop - 1em)
#line(length: 100%)
])[
#body
]
] ]

View File

@ -10,7 +10,7 @@
// start of template pages and styles // start of template pages and styles
#let dhbw-template(doc) = [ #let dhbw-template(doc) = [
#import "style.typ": global_styled_doc, prelude_styled #import "style.typ": global_styled_doc, prelude_styled, content_styled
// apply global style to every element in the argument content // apply global style to every element in the argument content
#global_styled_doc(doc: [ #global_styled_doc(doc: [
@ -19,6 +19,8 @@
#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/abstract.typ": new_abstract
#set text(lang: "de", region: "de") #set text(lang: "de", region: "de")
@ -39,21 +41,36 @@
subtitle: "für die AC500 SPS", subtitle: "für die AC500 SPS",
submission-date: "20. März 2024", submission-date: "20. März 2024",
timeframe: "1. Januar 2023 - 20. März 2024", timeframe: "1. Januar 2023 - 20. März 2024",
kind: "T2000" kind: "T2000",
summary: "",
abstract: "",
) )
// preppend title page // preppend title page
#new_title_page(thesis, author) #new_title_page(thesis, author)
#prelude_styled(thesis, doc: [ #prelude_styled(thesis, body: [
#pagebreak(weak: true)
#new_declaration_of_authorship(thesis, author) #new_declaration_of_authorship(thesis, author)
#pagebreak()
#pagebreak(weak: true)
#new_confidentiality_statement_page(thesis, author) #new_confidentiality_statement_page(thesis, author)
#pagebreak()
#pagebreak(weak: true)
#new_prerelease_note(thesis, author) #new_prerelease_note(thesis, author)
#pagebreak(weak: true)
#new_outline()
#pagebreak(weak: true)
#new_abstract(thesis)
]) ])
#content_styled(thesis, body: [
// code of document follows here // code of document follows here
#doc #doc
]) ])
])
] ]