dhbw-abb-typst-template/src/pages/outline.typ

105 lines
2.3 KiB
Plaintext
Raw Normal View History

2024-06-28 13:20:58 +00:00
// 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 {
2024-06-28 13:20:58 +00:00
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(
2024-07-01 12:46:32 +00:00
target: heading.where(supplement: [chapter]),
2024-06-28 13:20:58 +00:00
title: heading(level: 3, title),
indent: auto)
}
2024-07-01 11:50:54 +00:00
#let render_appendix_outline() = context {
2024-07-01 12:46:32 +00:00
let supplement = if text.lang == "en" {
[Appendix]
} else {
[Anhang]
}
if query(heading.where(supplement: supplement)).len() > 0 {
2024-07-01 11:50:54 +00:00
let title = if (text.lang == "de") {
2024-07-01 12:46:32 +00:00
"Anhangsverzeichnis"
} else if text.lang == "en" {
"Table of Appendices"
}
2024-07-01 11:50:54 +00:00
pagebreak(weak: true)
outline(
2024-07-01 12:46:32 +00:00
target: heading.where(supplement: supplement),
2024-07-01 11:50:54 +00:00
title: heading(level: 3, title),
indent: auto)
}
}
2024-06-28 13:20:58 +00:00
#let new_outline() = {
pagebreak(weak: true)
2024-06-28 13:20:58 +00:00
show outline.entry.where(
level: 1,
): it => {
v(18pt, weak: true)
strong(it)
}
render_figures_outline()
render_table_outline()
render_raw_outline()
2024-07-01 11:50:54 +00:00
render_appendix_outline()
2024-06-28 13:20:58 +00:00
render_heading_outline()
}