Compare commits
18 Commits
a0c75deba0
...
v0.8
Author | SHA1 | Date | |
---|---|---|---|
6e17d96b8b
|
|||
6d27bd5df5
|
|||
178be2e174
|
|||
a90543cdbd
|
|||
aeb112f5a1
|
|||
bf63657df3
|
|||
3f53ed89ba
|
|||
da11cd88fa
|
|||
d915b8cf27
|
|||
afc1ee372f
|
|||
d478d63812
|
|||
527534f885
|
|||
5c35389dca
|
|||
f22b16a803
|
|||
![]() |
f66f36d560 | ||
011ef2c950
|
|||
2787bed48d
|
|||
a691d84e1b
|
66
Makefile
66
Makefile
@@ -1,45 +1,81 @@
|
||||
.PHONY: view_example
|
||||
view_example: example.pdf
|
||||
view_example: documentation.pdf
|
||||
xdg-open $<
|
||||
|
||||
.PHONY: watch_example
|
||||
watch_example:
|
||||
typst watch --font-path template/fonts example.typ & xdg-open example.pdf
|
||||
.PHONY: watch_documentation
|
||||
watch_documentation:
|
||||
typst watch --font-path template/fonts documentation.typ & xdg-open documentation.pdf
|
||||
|
||||
.PHONY: example
|
||||
example: example.pdf
|
||||
.PHONY: documentation
|
||||
documentation: documentation.pdf
|
||||
|
||||
PACKDIR := pack/tultemplate2
|
||||
BUNDLEDIR := pack/bundle
|
||||
|
||||
TO_PACK := $(shell find template -type f) template/LICENSE
|
||||
PACK_TARGETS := $(TO_PACK:%=pack/tultemplate2/%) pack/tultemplate2/example.typ \
|
||||
pack/tultemplate2/citations.bib
|
||||
BUNDLE_TARGETS := $(TO_PACK:%=$(BUNDLEDIR)/%) $(BUNDLEDIR)/citations.bib $(BUNDLEDIR)/Makefile
|
||||
PACK_TARGETS := $(TO_PACK:%=$(PACKDIR)/%) $(PACKDIR)/documentation.typ \
|
||||
$(PACKDIR)/documentation.pdf $(PACKDIR)/citations.bib
|
||||
|
||||
.PHONY: pack
|
||||
pack: pack/tultemplate2.zip
|
||||
|
||||
.PHONY: bundle
|
||||
bundle: $(BUNDLE_TARGETS)
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -rf pack
|
||||
rm -f example.pdf
|
||||
rm -f documentation.pdf
|
||||
|
||||
pack/tultemplate2.zip: $(PACK_TARGETS)
|
||||
@mkdir -p $(@D)
|
||||
rm -f $@
|
||||
cd pack && zip -r tultemplate2.zip tultemplate2
|
||||
|
||||
pack/tultemplate2/%: %
|
||||
ln -f $< $@
|
||||
|
||||
pack/tultemplate2/template/LICENSE: LICENSE
|
||||
$(PACKDIR)/%: %
|
||||
@mkdir -p $(@D)
|
||||
ln -f $< $@
|
||||
|
||||
pack/tultemplate2/template/%: template/%
|
||||
$(BUNDLEDIR)/citations.bib:
|
||||
@mkdir -p $(@D)
|
||||
touch $@
|
||||
|
||||
$(BUNDLEDIR)/Makefile: templategen.mk
|
||||
@mkdir -p $(@D)
|
||||
ln -f $< $@
|
||||
|
||||
$(PACKDIR)/template/LICENSE: LICENSE
|
||||
@mkdir -p $(@D)
|
||||
ln -f $< $@
|
||||
|
||||
$(BUNDLEDIR)/template/LICENSE: LICENSE
|
||||
@mkdir -p $(@D)
|
||||
ln -f $< $@
|
||||
|
||||
$(PACKDIR)/template/tul_citace.csl $(BUNDLEDIR)/template/tul_citace.csl: template/tul_citace.csl
|
||||
@mkdir -p $(@D)
|
||||
cat $< | sed 's/^\s*\(.*\)$$/\1/' | tr -d '\n' > $@
|
||||
|
||||
$(PACKDIR)/template/lang.json: template/lang.json
|
||||
@mkdir -p $(@D)
|
||||
cat $< | jq -c > $@
|
||||
|
||||
$(BUNDLEDIR)/template/lang.json: template/lang.json
|
||||
@mkdir -p $(@D)
|
||||
cat $< | jq -c > $@
|
||||
|
||||
$(PACKDIR)/template/%: template/%
|
||||
@mkdir -p $(@D)
|
||||
ln -f $< $@
|
||||
|
||||
$(BUNDLEDIR)/template/%: template/%
|
||||
@mkdir -p $(@D)
|
||||
ln -f $< $@
|
||||
|
||||
TEMPLATE_SRCS := $(shell find template -type f)
|
||||
|
||||
%.pdf: %.typ $(TEMPLATE_SRCS)
|
||||
documentation.pdf: documentation.typ $(TEMPLATE_SRCS)
|
||||
typst compile --font-path template/fonts $<
|
||||
|
||||
include tests/make.mk
|
||||
|
@@ -6,6 +6,7 @@ Easy Typst template for TUL documents. Begin by compiling `example.typ` and read
|
||||
|
||||
It is recommended to use either:
|
||||
- The on-line Typst editor (https://typst.app/play/) - use some zip build from releases
|
||||
(https://git.zumepro.cz/tul/tultemplate2/releases).
|
||||
- The `typst` CLI tool (available in Arch repos and Snap)
|
||||
|
||||
On Linux, with the `typst` command available, you can just run:
|
||||
@@ -20,3 +21,5 @@ That will compile the example document and view it.
|
||||
|
||||
> [!IMPORTANT]
|
||||
> This repo uses git lfs to pull fonts. Please set it up (or download a packed build from releases).
|
||||
> When running in CLI - you'll want to include the embedded fonts:
|
||||
> `typst compile --font-path template/fonts example.typ`
|
||||
|
@@ -2,9 +2,8 @@
|
||||
|
||||
#show: tultemplate2.with(
|
||||
title: (cs: "Návod na použití Typst TUL šablony"),
|
||||
author: "Ondřej Mekina",
|
||||
author: "Ondřej Mekina, Matěj Žucha",
|
||||
supervisor: "Ondřej Mekina",
|
||||
consultant: "Matěj Žucha"
|
||||
)
|
||||
|
||||
= Lehký úvod do Typstu a této šablony
|
||||
@@ -92,7 +91,7 @@ opravdu hodně vám to usnadní práci.
|
||||
|
||||
// tohle je podnadpis :)
|
||||
#heading(
|
||||
level: 3,
|
||||
level: 2,
|
||||
range(1, 6).map((v) => range(1, v).map((_) => "pod").join("") + "nadpisy").join(", ") + ", ..."
|
||||
)<chained_subheading>
|
||||
|
||||
@@ -327,23 +326,38 @@ Zvýrazněné hodnoty jsou základní -- pokud vynecháte parametr, pak bude pou
|
||||
#line()
|
||||
- `title` (nadpis dokumentu)
|
||||
- Ve formátu `(<zkratka_jazyka>: "<nadpis>")`, například `(cs: "Můj nadpis")`
|
||||
- Pro většinu dokumentů (kromě `other`) jsou vyžadovány verze _cs_ a _en_ (kvůli abstraktu).
|
||||
#line()
|
||||
- `author` (autor/autoři dokumentu)
|
||||
- Příklad: `"Pavel Novák"` nebo `"Petra Velká, Jindřich Peterka"`
|
||||
#line()
|
||||
- `author_gender` (rod autora v českém jazyce - není potřeba pro angličtinu)
|
||||
- `"masculine"` - Mužský rod
|
||||
- `"feminine"` - Ženský rod
|
||||
- `"we"` - Množné číslo
|
||||
- `author_pronouns` (jazykový rod autora - není potřeba pro angličtinu, která má základní hodnotu)
|
||||
- Pro vybraný jazyk _cs_:
|
||||
- `"masculine"` - Mužský rod
|
||||
- `"feminine"` - Ženský rod
|
||||
- `"we"` - Množné číslo
|
||||
- Pro vybraný jazyk _en_:
|
||||
- *`"me"`* - První osoba jednotného čísla
|
||||
- `"we"` - První osoba množného čísla
|
||||
#line()
|
||||
- `supervisor` (vedoucí práce)
|
||||
- Příklad: `"prof. Jindřich Jindřich"`
|
||||
- `supervisor` (vedoucí práce) <arg_supervisor>
|
||||
- V podobě textového řetězce, příklad: `"prof. Jindřich Jindřich"`
|
||||
- Ve formátu `(name: "<jméno>", institute: "<institut>")` (toto lze využít například při DP)
|
||||
#line()
|
||||
- `programme` (studijní program autora)
|
||||
- `consultant` (konzultant práce)
|
||||
- Stejně jako u #link(<arg_supervisor>, [`supervisor`])
|
||||
#line()
|
||||
- `programme` (studijní program) <arg_programme>
|
||||
- Ve formátu `(<zkratka_jazyka>: "<název_programu>")`
|
||||
- Je vyžadován jazyk, který je vybrán pro celou šablonu -- tohle je pojistka, aby uživatel šablony
|
||||
nevynechal vybraný jazyk
|
||||
#line()
|
||||
- `branch` (studijní obor)
|
||||
- Stejně jako #link(<arg_programme>, [`programme`])
|
||||
#line()
|
||||
- `abstract` (abstrakt)
|
||||
- Ve formátu `(<zkratka_jazyka>: [<abstrakt>])`, například `(cs: [Můj *krásný* abstrakt.])`
|
||||
- Dokumenty vyžadují _cs_ i _en_ abstrakt (kromě typu dokumentu `other`).
|
||||
#line()
|
||||
- `keywords` (klíčová slova zobrazovaná pod abstraktem)
|
||||
- Ve formátu `(<zkratka_jazyka>: ("slovo1", "slovo2", ...))`
|
||||
@@ -389,6 +403,36 @@ Při dalších použití bude vypadat takto: #abbr("ZK").
|
||||
Tedy zkratku _nepřidáváte_ přímo do seznamu zkratek, ale elegantně jí používáte přímo v textu.
|
||||
]
|
||||
|
||||
== Přílohy
|
||||
|
||||
V některých typech dokumentů budete chtít přidat přílohy. Přílohy se přikládají v různých podobách:
|
||||
|
||||
- Jako odkaz (URL/URI adresa)
|
||||
- Zmínka externího souboru (například další soubor nahraný do systému)
|
||||
- Přiložený obsah (vygenerovaný Typstem v tomto dokumentu -- je tedy součástí tohoto kódu)
|
||||
- Externí PDF soubor přiložený jako obsah (jiný PDF dokument, vložený do příloh v kompletní
|
||||
podobě -- to je dobré například do tisku, kde můžete přílohy vytisknout s dokumentem)
|
||||
|
||||
#highlight[
|
||||
Přílohy lze definovat *pouze na jednom* místě v dokumentu, aby se zabránilo omylnému opakování
|
||||
příloh. Přílohy doporučujeme definovat *na konci* souboru pro přehlednost.
|
||||
]
|
||||
|
||||
Zde je ukázka definice příloh (je také použita na konci tohoto ukázkového souboru):
|
||||
|
||||
```typst
|
||||
#attachments(
|
||||
attach_link(
|
||||
"Zdrojový kód této šablony",
|
||||
"https://git.zumepro.cz/tul/tultemplate2"
|
||||
),
|
||||
attach_content(
|
||||
"Testovací obsah vygenerovaný Typstem",
|
||||
[Sem lze psát _stylovaný_ obsah.]
|
||||
),
|
||||
)
|
||||
```
|
||||
|
||||
= Workflow a jak si zjednoduššit práci
|
||||
|
||||
Tyhle věci používat _nemusíte_, aby vám šablona fungovala. Nicméně často jsou poměrně fajn.
|
||||
@@ -451,3 +495,8 @@ Takhle si můžete předpřipravit délku odstavců a vyzkoušet si, jestli se r
|
||||
do požadavků. Pak můžete postupně přepisovat/vyplňovat.
|
||||
|
||||
Funkce `todo` vám zároveň zabrání v tom, aby se text Lorem Ipsum vyskytl ve výsledném dokumentu.
|
||||
|
||||
#attachments(
|
||||
attach_link("Zdrojový kód této šablony", "https://git.zumepro.cz/tul/tultemplate2"),
|
||||
attach_content("Testovací obsah vygenerovaný Typstem", [Sem lze psát _stylovaný_ obsah.]),
|
||||
)
|
171
template/attachments.typ
Normal file
171
template/attachments.typ
Normal file
@@ -0,0 +1,171 @@
|
||||
#import "utils.typ": assert_type_signature, is_none
|
||||
#import "lang.typ": get_lang_item
|
||||
|
||||
#let attachment_data = state("attachment_data");
|
||||
|
||||
#let attach_link(name, link) = {
|
||||
assert_type_signature(link, "string", "attach link argument");
|
||||
assert_type_signature(name, "string", "attach link name argument");
|
||||
("link", link, name)
|
||||
}
|
||||
|
||||
#let attach_content(name, inner_content) = {
|
||||
assert_type_signature(inner_content, "content", "attach content argument");
|
||||
assert_type_signature(name, "string", "attach content name argument");
|
||||
("content", inner_content, name)
|
||||
}
|
||||
|
||||
#let attach_pdf(name, filepath) = {
|
||||
assert_type_signature(filepath, "string", "attach pdf argument");
|
||||
assert_type_signature(name, "string", "attach pdf name argument");
|
||||
("pdf", filepath, name)
|
||||
}
|
||||
|
||||
#let attach_file_reference(name, filename) = {
|
||||
assert_type_signature(filename, "string", "attach file reference filename argument");
|
||||
assert_type_signature(name, "string", "attach file reference name argument");
|
||||
("ref", filename, name)
|
||||
}
|
||||
|
||||
#let make_content_anchor(idx) = {
|
||||
"attachment_" + str(idx + 1)
|
||||
}
|
||||
|
||||
#let generate_attachment_content(attachment, idx) = {
|
||||
let attachment_type = attachment.at(0);
|
||||
if attachment_type == "content" {
|
||||
let anchor = make_content_anchor(idx);
|
||||
[#metadata(attachment.at(1)) #label(anchor)];
|
||||
}
|
||||
}
|
||||
|
||||
#let generate_attachment_info(attachment, idx) = {
|
||||
let attachment_type = attachment.at(0);
|
||||
if type(attachment_type) != str {
|
||||
panic("invalid attachment - wrap the attach using: attach_content, attach_pdf, ...");
|
||||
}
|
||||
if attachment_type == "content" {
|
||||
let anchor = make_content_anchor(idx);
|
||||
"(\"content\",\"" + anchor + "\",\"" + attachment.at(2) + "\")"
|
||||
} else if attachment_type == "pdf" {
|
||||
"(\"pdf\",\"" + attachment.at(1) + "\",\"" + attachment.at(2) + "\")"
|
||||
} else if (
|
||||
attachment_type == "pdf" or
|
||||
attachment_type == "link" or
|
||||
attachment_type == "ref"
|
||||
) {
|
||||
"(" + attachment.map((v) => { "\"" + v + "\"" }).join(",") + ",)"
|
||||
} else {
|
||||
panic("unknown attachment type '" + attachment_type + "'");
|
||||
}
|
||||
}
|
||||
|
||||
#let attachments(..attachments) = {
|
||||
let attachments = attachments.pos();
|
||||
assert_type_signature(
|
||||
attachments, "array[array[string | content]] | array[string | content]", "attachments"
|
||||
);
|
||||
context {
|
||||
if not is_none(attachment_data.get()) {
|
||||
panic("re-definition of attachments - attachments must only be defined once");
|
||||
}
|
||||
if attachments.len() == 0 {
|
||||
attachment_data.update("false");
|
||||
} else {
|
||||
attachment_data.update({
|
||||
"(" + if type(attachments) == array and type(attachments.at(0)) == array {
|
||||
for (idx, attachment) in attachments.enumerate() {
|
||||
(generate_attachment_info(attachment, idx),)
|
||||
}.join(", ")
|
||||
} else {
|
||||
generate_attachment_info(attachments, 0)
|
||||
} + ",)"
|
||||
})
|
||||
if type(attachments) == array and type(attachments.at(0)) == array {
|
||||
for (idx, attachment) in attachments.enumerate() {
|
||||
generate_attachment_content(attachment, idx);
|
||||
}
|
||||
} else {
|
||||
generate_attachment_content(attachments, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#let list_entry(language, entry, is_embedded) = {
|
||||
let entry_type = entry.at(0);
|
||||
entry.at(2);
|
||||
if entry_type == "link" {
|
||||
": ";
|
||||
link(entry.at(1));
|
||||
} else if entry_type == "ref" {
|
||||
": soubor ";
|
||||
raw(entry.at(1));
|
||||
}
|
||||
if is_embedded {
|
||||
text(
|
||||
" (" + get_lang_item(language, "attached_bellow") + ")",
|
||||
style: "italic",
|
||||
fill: black.lighten(50%),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#let attachment_list(language) = {
|
||||
context {
|
||||
let data = attachment_data.get();
|
||||
if is_none(data) {
|
||||
return;
|
||||
}
|
||||
let data = eval(data);
|
||||
if data == false {
|
||||
return;
|
||||
}
|
||||
heading(get_lang_item(language, "attachments"), numbering: none);
|
||||
|
||||
// listing
|
||||
let has_embedded = false;
|
||||
let enum_items = ();
|
||||
for attachment in data {
|
||||
let attachment_type = attachment.at(0);
|
||||
let is_embedded = false;
|
||||
if attachment_type == "content" or attachment_type == "pdf" {
|
||||
has_embedded = true;
|
||||
is_embedded = true;
|
||||
}
|
||||
enum_items.push(list_entry(language, attachment, is_embedded));
|
||||
}
|
||||
enum(..enum_items.map((v) => { enum.item(v) }), spacing: 1em);
|
||||
|
||||
if has_embedded {
|
||||
pagebreak(weak: true);
|
||||
}
|
||||
|
||||
// embedded
|
||||
set page(footer: none);
|
||||
for (idx, attachment) in data.enumerate() {
|
||||
let attachment_type = attachment.at(0);
|
||||
if attachment_type == "content" {
|
||||
heading(
|
||||
level: 2,
|
||||
get_lang_item(language, "attachment") + " " + str(idx + 1),
|
||||
numbering: none,
|
||||
outlined: false,
|
||||
);
|
||||
query(label(attachment.at(1))).at(0).value;
|
||||
} else if attachment_type == "pdf" {
|
||||
import "@preview/muchpdf:0.1.1": muchpdf
|
||||
page(place(center + horizon, heading(
|
||||
level: 2,
|
||||
get_lang_item(language, "attachment") + " " +
|
||||
str(idx + 1) + " " +
|
||||
get_lang_item(language, "next_page_attachment"),
|
||||
numbering: none,
|
||||
outlined: false,
|
||||
)), margin: 0em);
|
||||
set page(margin: 0em);
|
||||
muchpdf(read("../" + attachment.at(1), encoding: none), width: 100%);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -5,21 +5,23 @@
|
||||
assignment,
|
||||
disclaimer,
|
||||
abstract,
|
||||
acknowledgement,
|
||||
toc,
|
||||
abbrlist,
|
||||
imagelist,
|
||||
tablelist,
|
||||
bibliogr
|
||||
)
|
||||
#import "../utils.typ": is_none, assert_dict_has, assert_not_none
|
||||
#import "../attachments.typ": attachment_list
|
||||
#import "../utils.typ": is_none, assert_dict_has, assert_not_none, assert_type_signature
|
||||
|
||||
#let bp(
|
||||
// general settings
|
||||
faculty_id, faculty_color, language, assignment_document, citation_file,
|
||||
|
||||
// document info
|
||||
title, author, author_gender, supervisor, consultant, study_programme, study_branch, abstract_content,
|
||||
keywords,
|
||||
title, author, author_pronouns, supervisor, consultant, study_programme, study_branch,
|
||||
year_of_study, abstract_content, acknowledgement_content, keywords,
|
||||
|
||||
content
|
||||
) = {
|
||||
@@ -37,22 +39,31 @@
|
||||
if not is_none(keywords) {
|
||||
assert_dict_has(force_langs, keywords, "keywords");
|
||||
}
|
||||
assert_not_none(acknowledgement_content, "acknowledgement content");
|
||||
if language == "cs" {
|
||||
assert_not_none(author_gender, "author gender");
|
||||
assert_not_none(author_pronouns, "author gender");
|
||||
}
|
||||
|
||||
mainpage(faculty_id, language, "bp", title, author, supervisor, consultant, study_programme, study_branch);
|
||||
assert_type_signature(supervisor, "string | none", "supervisor");
|
||||
assert_type_signature(consultant, "string | none", "consultant");
|
||||
|
||||
mainpage(
|
||||
faculty_id, language, "bp", title, author, supervisor, consultant, study_programme,
|
||||
study_branch, year_of_study,
|
||||
);
|
||||
assignment(language, assignment_document);
|
||||
default_styling(false, faculty_color, {
|
||||
disclaimer(language, faculty_id, "bp", author, author_gender);
|
||||
disclaimer(language, faculty_id, "bp", author, author_pronouns);
|
||||
abstract("cs", title, abstract_content, keywords);
|
||||
abstract("en", title, abstract_content, keywords);
|
||||
acknowledgement(language, author, acknowledgement_content);
|
||||
toc(language);
|
||||
abbrlist(language);
|
||||
imagelist(language);
|
||||
tablelist(language);
|
||||
imagelist(language);
|
||||
abbrlist(language);
|
||||
pagebreak(weak: true);
|
||||
content
|
||||
content;
|
||||
bibliogr(language, citation_file);
|
||||
attachment_list(language);
|
||||
});
|
||||
}
|
||||
|
@@ -12,7 +12,8 @@
|
||||
language, faculty_id, document_type, citation_file, assignment_document,
|
||||
|
||||
// document info
|
||||
title, author, author_gender, supervisor, consultant, study_programme, study_branch, abstract, keywords,
|
||||
title, author, author_pronouns, supervisor, consultant, study_programme, study_branch,
|
||||
year_of_study, abstract, acknowledgement, keywords,
|
||||
|
||||
// content
|
||||
content,
|
||||
@@ -26,22 +27,24 @@
|
||||
map_none(title, (v) => assert_dict_has((language,), v, "title"));
|
||||
map_none(study_programme, (v) => assert_dict_has((language,), v, "study programme"));
|
||||
map_none(study_branch, (v) => assert_dict_has((language,), v, "study branch"));
|
||||
|
||||
map_none(acknowledgement, (v) => assert_dict_has((language,), v, "acknowledgement content"));
|
||||
|
||||
document_types.at(document_type)(
|
||||
faculty_id,
|
||||
faculty_color(faculty_id),
|
||||
language,
|
||||
assignment_document,
|
||||
map_none(assignment_document, (v) => "../../" + v),
|
||||
map_none(citation_file, (v) => "../../" + v),
|
||||
title,
|
||||
author,
|
||||
author_gender,
|
||||
author_pronouns,
|
||||
supervisor,
|
||||
consultant,
|
||||
study_programme,
|
||||
study_branch,
|
||||
year_of_study,
|
||||
abstract,
|
||||
acknowledgement,
|
||||
keywords,
|
||||
content,
|
||||
);
|
||||
|
@@ -1,9 +1,10 @@
|
||||
#import "../theme.typ": faculty_logotype, tul_logomark, faculty_color
|
||||
#import "../lang.typ": get_lang_item
|
||||
#import "../utils.typ": is_none
|
||||
#import "../utils.typ": is_none, assert_dict_has, map_none
|
||||
|
||||
#let base_font = "Inter";
|
||||
#let mono_font = "Noto Sans Mono";
|
||||
#let mono_font_compensation = 1.3em;
|
||||
#let serif_font = "Merriweather";
|
||||
#let tul_logomark_size = 6.5em;
|
||||
|
||||
@@ -71,10 +72,17 @@
|
||||
};
|
||||
|
||||
// other
|
||||
show raw: set text(font: mono_font);
|
||||
show raw: set text(font: mono_font, size: mono_font_compensation);
|
||||
show raw.where(block: true): it => {
|
||||
block(it, fill: rgb("#eee"), inset: 1em)
|
||||
};
|
||||
show link: it => {
|
||||
if type(it.dest) == label or type(it.dest) == location {
|
||||
it;
|
||||
} else {
|
||||
text(it, fill: faculty_color);
|
||||
}
|
||||
}
|
||||
set highlight(fill: faculty_color.lighten(90%));
|
||||
|
||||
content
|
||||
@@ -90,16 +98,40 @@
|
||||
);
|
||||
}
|
||||
|
||||
// DOCUMENT INFO
|
||||
// DOCUMENT INFO
|
||||
|
||||
#let person_info(record, item_name) = {
|
||||
if is_none(record) {
|
||||
none
|
||||
} else if type(record) == str {
|
||||
record
|
||||
} else if type(record) == dictionary {
|
||||
if "name" in record {
|
||||
record.at("name");
|
||||
if "institute" in record {
|
||||
text("\n " + record.at("institute"), style: "italic")
|
||||
}
|
||||
} else {
|
||||
let panic_message = (
|
||||
item_name + " name is required (or try not specifying " + item_name + " at all)"
|
||||
);
|
||||
panic(panic_message);
|
||||
}
|
||||
} else {
|
||||
let panic_message = "invalid " + item_name + " - expected a string or a dictionary";
|
||||
panic(panic_message);
|
||||
}
|
||||
}
|
||||
|
||||
#let info(
|
||||
faculty_id,
|
||||
language,
|
||||
document_type,
|
||||
title, author, supervisor, consultant, study_programme, study_branch,
|
||||
title, author, supervisor, consultant, study_programme, study_branch, year_of_study,
|
||||
) = {
|
||||
let info_name_value_padding = 5em;
|
||||
let info_name_min_width = 10em;
|
||||
let gutter = .7em;
|
||||
|
||||
// document type
|
||||
if type(document_type) != type(none) {
|
||||
@@ -117,11 +149,12 @@
|
||||
// other info
|
||||
// [field_name, field_value, bold]
|
||||
let info_fields = (
|
||||
("author", author, true),
|
||||
("supervisor", person_info(supervisor, "supervisor"), false),
|
||||
("consultant", person_info(consultant, "consultant"), false),
|
||||
("study_programme", study_programme, false),
|
||||
("study_branch", study_branch, false),
|
||||
("author", author, true),
|
||||
("supervisor", supervisor, false),
|
||||
("consultant", consultant, false),
|
||||
("year_of_study", map_none(year_of_study, (v) => str(v) + "."), false),
|
||||
)
|
||||
context {
|
||||
let max_field_name_width = calc.max(..info_fields.map((v) => {
|
||||
@@ -133,7 +166,7 @@
|
||||
}), info_name_min_width.to-absolute());
|
||||
grid(
|
||||
columns: 2,
|
||||
gutter: .5em,
|
||||
gutter: gutter,
|
||||
..info_fields.filter((v) => { type(v.at(1)) != type(none) }).map((v) => {
|
||||
(
|
||||
align(top, block(
|
||||
@@ -145,7 +178,7 @@
|
||||
}).flatten(),
|
||||
);
|
||||
v(1em);
|
||||
h(max_field_name_width + info_name_value_padding);
|
||||
h(max_field_name_width + info_name_value_padding + gutter);
|
||||
text(get_lang_item(language, "city") + " " + str(datetime.today().year()), font: base_font);
|
||||
}
|
||||
}
|
||||
@@ -156,7 +189,7 @@
|
||||
faculty_id,
|
||||
language,
|
||||
document_type,
|
||||
title, author, supervisor, consultant, study_programme, study_branch
|
||||
title, author, supervisor, consultant, study_programme, study_branch, year_of_study,
|
||||
) = {
|
||||
import "../utils.typ": has_all_none, map_none
|
||||
let nonetype = type(none);
|
||||
@@ -171,7 +204,7 @@
|
||||
info(
|
||||
faculty_id, language, document_type, map_none(title, (v) => v.at(language)),
|
||||
author, supervisor, consultant, map_none(study_programme, (v) => v.at(language)),
|
||||
map_none(study_branch, (v) => v.at(language)),
|
||||
map_none(study_branch, (v) => v.at(language)), year_of_study,
|
||||
);
|
||||
v(5em);
|
||||
}, bottom);
|
||||
@@ -203,11 +236,11 @@
|
||||
|
||||
// DISCLAIMER PAGE
|
||||
|
||||
#let disclaimer(language, faculty_id, disclaimer_type, author, author_gender) = {
|
||||
#let disclaimer(language, faculty_id, disclaimer_type, author, author_pronouns) = {
|
||||
import "../lang.typ": disclaimer
|
||||
heading(get_lang_item(language, "disclaimer"), numbering: none, outlined: false);
|
||||
par(
|
||||
text(disclaimer(language, disclaimer_type, author_gender))
|
||||
text(disclaimer(language, disclaimer_type, author_pronouns))
|
||||
);
|
||||
v(5em);
|
||||
grid(
|
||||
@@ -220,6 +253,18 @@
|
||||
);
|
||||
}
|
||||
|
||||
// ACKNOWLEDGEMENT PAGE
|
||||
|
||||
#let acknowledgement(language, author, content) = {
|
||||
if is_none(content) {
|
||||
return;
|
||||
}
|
||||
heading(get_lang_item(language, "acknowledgement"), numbering: none, outlined: false);
|
||||
par(content.at(language));
|
||||
v(2em);
|
||||
align(right, author);
|
||||
}
|
||||
|
||||
// ABSTRACT
|
||||
|
||||
#let abstract(language, title, content, keywords) = {
|
||||
@@ -251,7 +296,7 @@
|
||||
stack(
|
||||
dir: ltr,
|
||||
text(numbering(
|
||||
"1. 1",
|
||||
"1.1",
|
||||
counter(heading).at(element.location()).at(0),
|
||||
counter(selector).at(element.location()).at(0),
|
||||
)),
|
||||
@@ -263,7 +308,7 @@
|
||||
),
|
||||
)
|
||||
}
|
||||
heading(title, numbering: none, outlined: false);
|
||||
heading(title, numbering: none);
|
||||
for el in query(figure.where(kind: selector)) {
|
||||
if is_none(el.caption) {
|
||||
continue;
|
||||
|
@@ -10,6 +10,7 @@
|
||||
imagelist,
|
||||
tablelist,
|
||||
)
|
||||
#import "../attachments.typ": attachment_list
|
||||
#import "../utils.typ": is_none, assert_not_none, assert_dict_has, assert_in_arr
|
||||
|
||||
#let other(
|
||||
@@ -17,23 +18,26 @@
|
||||
faculty_id, faculty_color, language, assignment_document, citation_file,
|
||||
|
||||
// document info
|
||||
title, author, _, supervisor, consultant, study_programme, study_branch, abstract_content, keywords,
|
||||
title, author, _, supervisor, consultant, study_programme, study_branch, year_of_study,
|
||||
abstract_content, _, keywords,
|
||||
|
||||
content
|
||||
) = {
|
||||
assert_not_none(title, "title");
|
||||
assert_dict_has((language,), title, "title");
|
||||
|
||||
mainpage(faculty_id, language, none, title, author, supervisor, consultant, study_programme, study_branch);
|
||||
mainpage(
|
||||
faculty_id, language, none, title, author, supervisor, consultant, study_programme,
|
||||
study_branch, year_of_study,
|
||||
);
|
||||
default_styling(true, faculty_color, {
|
||||
toc(language);
|
||||
abbrlist(language);
|
||||
imagelist(language);
|
||||
tablelist(language);
|
||||
imagelist(language);
|
||||
abbrlist(language);
|
||||
pagebreak(to: "even", weak: true);
|
||||
content
|
||||
|
||||
// bibliography
|
||||
content;
|
||||
bibliography(citation_file, style: "../tul_citace.csl");
|
||||
attachment_list(language);
|
||||
});
|
||||
}
|
||||
|
@@ -6,6 +6,7 @@
|
||||
"consultant": "Konzultant práce",
|
||||
"study_programme": "Studijní program",
|
||||
"study_branch": "Studijní obor",
|
||||
"year_of_study": "Ročník",
|
||||
|
||||
"bp": "Bakalářská práce",
|
||||
|
||||
@@ -36,10 +37,15 @@
|
||||
"date": "[day]. [month]. [year]",
|
||||
|
||||
"abstract": "Abstrakt",
|
||||
"acknowledgement": "Poděkování",
|
||||
"keywords": "Klíčová slova",
|
||||
"abbrs": "Seznam zkratek",
|
||||
"image_list": "Seznam obrázků",
|
||||
"table_list": "Seznam tabulek",
|
||||
"attachments": "Přílohy",
|
||||
"attachment": "Příloha",
|
||||
"next_page_attachment": "začíná na další straně",
|
||||
"attached_bellow": "dále přiloženo",
|
||||
|
||||
"place_assignment": "Sem vložte zadání"
|
||||
},
|
||||
@@ -51,6 +57,7 @@
|
||||
"consultant": "Consultant",
|
||||
"study_programme": "Study programme",
|
||||
"study_branch": "Study branch",
|
||||
"year_of_study": "Year of study",
|
||||
|
||||
"bp": "Bachelor thesis",
|
||||
|
||||
@@ -70,10 +77,15 @@
|
||||
"date": "[year]-[month]-[day]",
|
||||
|
||||
"abstract": "Abstract",
|
||||
"acknowledgement": "Acknowledgement",
|
||||
"keywords": "Keywords",
|
||||
"abbrs": "List of abbreviations",
|
||||
"image_list": "List of images",
|
||||
"table_list": "List of tables",
|
||||
"attachments": "Attachments",
|
||||
"attachment": "Attachment",
|
||||
"next_page_attachment": "begins on the next page",
|
||||
"attached_bellow": "attached bellow",
|
||||
|
||||
"place_assignment": "Insert your assignment here"
|
||||
}
|
||||
|
@@ -45,13 +45,13 @@
|
||||
});
|
||||
}
|
||||
|
||||
#let disclaimer(language, document_type, author_gender) = {
|
||||
#let disclaimer(language, document_type, author_pronouns) = {
|
||||
let disclaimer = get_lang_item(language, "disclaimer_content");
|
||||
let replacements = get_lang_item(language, "disclaimer_replace").at(document_type);
|
||||
if language == "cs" {
|
||||
disclaimer = replace_czech_gender(disclaimer, author_gender);
|
||||
disclaimer = replace_czech_gender(disclaimer, author_pronouns);
|
||||
} else if language == "en" {
|
||||
disclaimer = replace_english_pronounce(disclaimer, author_gender);
|
||||
disclaimer = replace_english_pronounce(disclaimer, author_pronouns);
|
||||
}
|
||||
for (key, value) in replacements.pairs() {
|
||||
disclaimer = disclaimer.replace("{" + key + "}", value);
|
||||
|
@@ -7,6 +7,9 @@
|
||||
// Git: https://git.zumepro.cz/tul/tultemplate2
|
||||
|
||||
#import "prototyping.typ": todo, profile
|
||||
#import "attachments.typ": (
|
||||
attachments, attach_content, attach_pdf, attach_link, attach_file_reference
|
||||
)
|
||||
|
||||
// TUL Template 2
|
||||
//
|
||||
@@ -25,9 +28,11 @@
|
||||
// - document (str): Type of document. This can be "bp" or "other".
|
||||
// - title (dictionary): The title of the document.
|
||||
// - author (str): The name of the document's author.
|
||||
// - author_gender (str): The gender of the document's author. Needed only for the `cs` language.
|
||||
// - author_pronouns (str): The gender of the document's author. Needed only for the `cs` language.
|
||||
// - supervisor (str): The name of the document's supervisor.
|
||||
// - consultant (str): The name of the document's consultant.
|
||||
// - programme (dictionary): Study programme.
|
||||
// - branch (disctionary): Study branch
|
||||
// - abstract (dictionary): The abstract.
|
||||
// - keywords (dictionary): The abstract keywords.
|
||||
// - assignment (str): Filepath of the assignment document/page.
|
||||
@@ -40,8 +45,9 @@
|
||||
style: "classic", faculty: "tul", lang: "cs", document: "other",
|
||||
|
||||
// document info
|
||||
title: none, keywords: none, abstract: none, author: none, author_gender: none,
|
||||
supervisor: none, consultant: none, programme: none, branch: none,
|
||||
title: none, keywords: none, abstract: none, acknowledgement: none, author: none,
|
||||
author_pronouns: none, supervisor: none, consultant: none, programme: none,
|
||||
branch: none, year_of_study: none,
|
||||
|
||||
// links
|
||||
assignment: none, citations: "citations.bib",
|
||||
@@ -61,14 +67,22 @@
|
||||
assert_type_signature(
|
||||
abstract, "dictionary[string : string | content] | none", "abstract argument"
|
||||
);
|
||||
assert_type_signature(
|
||||
acknowledgement, "dictionary[string : string] | none", "acknowledgement content"
|
||||
);
|
||||
assert_type_signature(author, "string | none", "author argument");
|
||||
assert_type_signature(author_gender, "string | none", "author gender argument");
|
||||
assert_type_signature(supervisor, "string | none", "supervisor argument");
|
||||
assert_type_signature(consultant, "string | none", "consultant argument");
|
||||
assert_type_signature(author_pronouns, "string | none", "author gender argument");
|
||||
assert_type_signature(
|
||||
supervisor, "string | dictionary[string : string] | none", "supervisor argument"
|
||||
);
|
||||
assert_type_signature(
|
||||
consultant, "string | dictionary[string : string] | none", "consultant argument"
|
||||
);
|
||||
assert_type_signature(
|
||||
programme, "dictionary[string : string] | none", "study programme argument"
|
||||
);
|
||||
assert_type_signature(branch, "dictionary[string : string] | none", "study branch argument");
|
||||
assert_type_signature(year_of_study, "integer | none", "year of study");
|
||||
assert_type_signature(assignment, "string | none", "assignment document argument");
|
||||
assert_type_signature(citations, "string", "citations file argument");
|
||||
|
||||
@@ -87,8 +101,8 @@
|
||||
// template call
|
||||
templates.at(style)(
|
||||
lang, faculty, document, citations, assignment,
|
||||
title, author, author_gender, supervisor, consultant,
|
||||
programme, branch, abstract, keywords, content
|
||||
title, author, author_pronouns, supervisor, consultant,
|
||||
programme, branch, year_of_study, abstract, acknowledgement, keywords, content
|
||||
);
|
||||
|
||||
import "prototyping.typ": assert_release_ready
|
||||
|
13
templategen.mk
Normal file
13
templategen.mk
Normal file
@@ -0,0 +1,13 @@
|
||||
THESIS_FILE := thesis
|
||||
TYPST_FONTPATH := --font-path template/fonts
|
||||
|
||||
.PHONY: watch
|
||||
watch: $(THESIS_FILE).pdf
|
||||
xdg-open $< & typst watch $(TYPST_FONTPATH) $(THESIS_FILE).typ
|
||||
|
||||
.PHONY: view
|
||||
view: $(THESIS_FILE).pdf
|
||||
xdg-open $<
|
||||
|
||||
%.pdf: %.typ
|
||||
typst compile $(TYPST_FONTPATH) $<
|
Reference in New Issue
Block a user