From eba0ec78263b121c8ab016c2571f464edd142f84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Mekina?= Date: Thu, 2 Oct 2025 20:39:26 +0200 Subject: [PATCH] add image and table listings --- template/classic/bp.typ | 4 ++ template/classic/common.typ | 78 ++++++++++++++++++++++++++++++++++--- template/lang.json | 4 ++ 3 files changed, 81 insertions(+), 5 deletions(-) diff --git a/template/classic/bp.typ b/template/classic/bp.typ index 52e797d..1729c48 100644 --- a/template/classic/bp.typ +++ b/template/classic/bp.typ @@ -7,6 +7,8 @@ abstract, toc, abbrlist, + imagelist, + tablelist, bibliogr ) #import "../utils.typ": is_none, assert_dict_has, assert_not_none @@ -47,6 +49,8 @@ abstract("en", title, abstract_content, keywords); toc(language); abbrlist(language); + imagelist(language); + tablelist(language); content bibliogr(language, citation_file); }); diff --git a/template/classic/common.typ b/template/classic/common.typ index f283873..b6d4c18 100644 --- a/template/classic/common.typ +++ b/template/classic/common.typ @@ -32,6 +32,18 @@ set text(font: serif_font); set par(justify: true); + // figures + let figure_numbering(c) = { + context numbering("1. 1", counter(heading).get().at(0), c) + }; + show figure.where(kind: image): set figure(numbering: figure_numbering); + show figure.where(kind: table): set figure(numbering: figure_numbering); + show figure.where(kind: table): set figure.caption(position: top); + show figure: it => { + block(it, above: 2em, below: 2em); + } + set image(width: 80%); + // heading set heading(numbering: "1.1.1 "); show heading: it => { @@ -43,6 +55,10 @@ ); }; show heading.where(level: 1): it => { + // reset figure counters + context counter(figure.where(kind: image)).update(0); + context counter(figure.where(kind: table)).update(0); + pagebreak(weak: true); v(2cm); it @@ -54,7 +70,6 @@ block(it, fill: rgb("#eee"), inset: 1em) }; set highlight(fill: faculty_color.lighten(90%)); - set image(width: 80%); content } @@ -111,13 +126,13 @@ }), info_name_min_width.to-absolute()); grid( columns: 2, - rows: (auto, 1.2em), + gutter: .5em, ..info_fields.filter((v) => { type(v.at(1)) != type(none) }).map((v) => { ( - block( + align(top, block( text(get_lang_item(language, v.at(0)) + ":", style: "italic", font: base_font), - width: max_field_name_width + info_name_value_padding, - ), + width: max_field_name_width + info_name_value_padding + )), text(v.at(1), font: base_font, weight: if v.at(2) { "bold" } else { "regular" }) ) }).flatten(), @@ -218,6 +233,59 @@ } } +// _ OUTLINE +#let _outline_figure_inner(selector, title, body_mapper) = { + show outline.entry: it => { + link( + it.element.location(), + grid( + columns: 3, + gutter: .5em, + stack( + dir: ltr, + text(numbering( + "1. 1", + counter(heading).at(it.element.location()).at(0), + counter(selector).at(it.element.location()).at(0), + )), + h(.5em), + text(body_mapper(it)), + ), + box(repeat([.], gap: 0.15em)), + str(it.element.location().page()), + ), + ) + } + if not is_none(selector) { + outline(target: selector, title: title); + } else { + outline(title: title); + } +} + +// _ FIGURE OUTLINE + +#let _figure_outline(target, title) = { + context { + if counter(figure.where(kind: target)).final() == 0 { + return; + } + _outline_figure_inner(figure.where(kind: target), title, (it) => it.element.caption.body); + } +} + +// IMAGE LIST + +#let imagelist(language) = { + _figure_outline(image, get_lang_item(language, "image_list")); +} + +// TABLE LIST + +#let tablelist(language) = { + _figure_outline(table, get_lang_item(language, "table_list")); +} + // ABBREVIATION LIST #let abbrlist(language) = { diff --git a/template/lang.json b/template/lang.json index a944bfd..6880bc8 100644 --- a/template/lang.json +++ b/template/lang.json @@ -39,6 +39,8 @@ "abstract": "Abstrakt", "keywords": "Klíčová slova", "abbrs": "Seznam zkratek", + "image_list": "Seznam obrázků", + "table_list": "Seznam tabulek", "place_assignment": "Sem vložte zadání" }, @@ -72,6 +74,8 @@ "abstract": "Abstract", "keywords": "Keywords", "abbrs": "List of abbreviations", + "image_list": "List of images", + "table_list": "List of tables", "place_assignment": "Insert your assignment here" }