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

113 lines
2.5 KiB
Plaintext
Raw Normal View History

// .--------------------------------------------------------------------------.
// | Document Outline |
// '--------------------------------------------------------------------------'
// Author: Sven Vogel
// Edited: 28.06.2024
// License: MIT
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
2024-07-08 19:57:23 +00:00
// NOTE: will not render in case the listing is empty
2024-06-28 13:20:58 +00:00
#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()
2024-07-08 19:57:23 +00:00
2024-06-28 13:20:58 +00:00
// only show outline if there is something to list
if count > 0 {
pagebreak(weak: true)
outline(
2024-07-08 11:49:04 +00:00
title: title,
2024-07-08 19:57:23 +00:00
target: figure.where(kind: kind),
)
2024-06-28 13:20:58 +00:00
}
}
#let render_figures_outline() = context {
let title = if (text.lang == "de") {
2024-07-08 19:57:23 +00:00
"Abbildungsverzeichnis"
} else if text.lang == "en" {
"List of Figures"
}
2024-06-28 13:20:58 +00:00
render_filtered_outline(title: title, kind: image)
}
#let render_table_outline() = context {
let title = if (text.lang == "de") {
2024-07-08 19:57:23 +00:00
"Tabellenverzeichnis"
} else if text.lang == "en" {
"List of Tables"
}
2024-06-28 13:20:58 +00:00
render_filtered_outline(title: title, kind: table)
}
#let render_raw_outline() = context {
let title = if (text.lang == "de") {
2024-07-08 19:57:23 +00:00
"Quelltextverzeichnis"
} else if text.lang == "en" {
"Code Snippets"
}
2024-06-28 13:20:58 +00:00
render_filtered_outline(title: title, kind: raw)
}
#let render_heading_outline() = context {
let title = if (text.lang == "de") {
2024-07-08 19:57:23 +00:00
"Inhaltsverzeichnis"
} else if text.lang == "en" {
"Table of Contents"
}
2024-06-28 13:20:58 +00:00
pagebreak(weak: true)
outline(
2024-07-08 19:57:23 +00:00
target: heading.where(supplement: [chapter]),
title: title,
indent: auto,
)
2024-06-28 13:20:58 +00:00
}
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-08 19:57:23 +00:00
2024-07-01 11:50:54 +00:00
pagebreak(weak: true)
outline(
2024-07-08 19:57:23 +00:00
target: heading.where(supplement: supplement),
title: title,
indent: auto,
)
2024-07-01 11:50:54 +00:00
}
}
2024-06-28 13:20:58 +00:00
#let new_outline() = {
pagebreak(weak: true)
2024-07-08 19:57:23 +00:00
show outline.entry.where(level: 1): it => {
v(1.5em, weak: true)
2024-06-28 13:20:58 +00:00
strong(it)
}
2024-07-08 11:49:04 +00:00
render_heading_outline()
2024-06-28 13:20:58 +00:00
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
}