14 Commits

10 changed files with 219 additions and 49 deletions

View File

@@ -10,7 +10,8 @@ watch_example:
example: example.pdf
TO_PACK := $(shell find template -type f) template/LICENSE
PACK_TARGETS := $(TO_PACK:%=pack/tultemplate2/%) pack/tultemplate2/example.typ
PACK_TARGETS := $(TO_PACK:%=pack/tultemplate2/%) pack/tultemplate2/example.typ \
pack/tultemplate2/citations.bib
.PHONY: pack
pack: pack/tultemplate2.zip
@@ -25,7 +26,7 @@ pack/tultemplate2.zip: $(PACK_TARGETS)
rm -f $@
cd pack && zip -r tultemplate2.zip tultemplate2
pack/tultemplate2/example.typ: example.typ
pack/tultemplate2/%: %
ln -f $< $@
pack/tultemplate2/template/LICENSE: LICENSE

View File

@@ -191,6 +191,34 @@ Tady je praktická ukázka jednoduchého vložení obrázku s popiskem:
Logo *TUL*
])
Obrázky se zobrazí na začátku dokumentu v seznamu (pokud to daný typ dokumentu vyžaduje).
== Tabulky
Tabulky lze vytvářet takto:
```typst
#figure(table(
columns: 3,
table.header([], [*Sloupec 1*], [*Sloupec 2*]),
[*Řádek 1*], [a], [b],
[*Řádek 2*], [c], [d],
), caption: "Moje krásná tabulka")
```
#highlight[Hlavičku tabulky (první řádek) je dobré zabalit do funkce header (viz. výše)], to je
kvůli tomu, že Typst do vygenerovaného PDF souboru poté přidá metadata (například pro osoby se
zrakovým postižením).
#figure(table(
columns: 3,
table.header([], [*Sloupec 1*], [*Sloupec 2*]),
[*Řádek 1*], [a], [b],
[*Řádek 2*], [c], [d],
), caption: "Moje krásná tabulka")
Tabulky se zobrazí na začátku dokumentu v seznamu (pokud to daný typ dokumentu vyžaduje).
== Citace
Šablona podporuje správu citací pomocí standardního BibTeX @bibtex souboru, stejně jako
@@ -300,23 +328,24 @@ Zvýrazněné hodnoty jsou základní -- pokud vynecháte parametr, pak bude pou
- Ve formátu `(<zkratka_jazyka>: "<nadpis>")`, například `(cs: "Můj nadpis")`
#line()
- `author` (autor/autoři dokumentu)
- Příklad: `"Pavel Novák"` nebo `"Petra Velká, Jindřich Peterka"` (oddělujte jména `", "`)
- 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)
- `"male"` - Mužský rod
- `"female"` - Ženský rod
- `"masculine"` - Mužský rod
- `"feminine"` - Ženský rod
- `"we"` - Množné číslo
#line()
- `supervisor` (vedoucí práce)
- Příklad: `"prof. Jindřich Jindřich"`
#line()
- `programme` (studijní program autora)
- Příklad: `"4242 - Odborná tvorba a zpracování krásných šablon"`
- Ve formátu `(<zkratka_jazyka>: "<název_programu>")`
#line()
- `abstract` (abstrakt)
- Ve formátu `(<zkratka_jazyka>: [<abstrakt>])`, například `(cs: [Můj *krásný* abstrakt.])`
#line()
- `keywords` (klíčová slova zobrazovaná pod abstraktem)
- Ve formátu `("slovo1", "slovo2", ...)`
- Ve formátu `(<zkratka_jazyka>: ("slovo1", "slovo2", ...))`
#line()
- `assignment` (PDF soubor se zadáním)
- Ve formě cesty k souboru, například: `"zadani.pdf"`. Pokud je tento argument vynechán, bude

View File

@@ -7,6 +7,8 @@
abstract,
toc,
abbrlist,
imagelist,
tablelist,
bibliogr
)
#import "../utils.typ": is_none, assert_dict_has, assert_not_none
@@ -16,12 +18,20 @@
faculty_id, faculty_color, language, assignment_document, citation_file,
// document info
title, author, author_gender, supervisor, study_programme, abstract_content, keywords,
title, author, author_gender, supervisor, study_programme, study_branch, abstract_content,
keywords,
content
) = {
let force_langs = ("cs", "en");
assert_not_none(title, "title");
assert_dict_has(force_langs, title, "title");
assert_not_none(study_programme, "study programme");
assert_dict_has((language,), study_programme, "study programme");
assert_not_none(study_branch, "study branch");
assert_dict_has((language,), study_branch, "study branch");
assert_not_none(abstract_content, "abstract");
assert_dict_has(force_langs, abstract_content, "abstract");
if not is_none(keywords) {
@@ -31,7 +41,7 @@
assert_not_none(author_gender, "author gender");
}
mainpage(faculty_id, language, none, title, author, supervisor, study_programme);
mainpage(faculty_id, language, "bp", title, author, supervisor, study_programme, study_branch);
assignment(language, assignment_document);
default_styling(false, faculty_color, {
disclaimer(language, faculty_id, "bp", author, author_gender);
@@ -39,7 +49,10 @@
abstract("en", title, abstract_content, keywords);
toc(language);
abbrlist(language);
imagelist(language);
tablelist(language);
pagebreak(weak: true);
content
bibliogr(citation_file);
bibliogr(language, citation_file);
});
}

View File

@@ -1,7 +1,7 @@
// tools & utils
#import "../theme.typ": faculty_logotype, tul_logomark, faculty_color
#import "../lang.typ": lang_id, get_lang_item
#import "../utils.typ": assert_in_dict, assert_in_arr, map_none
#import "../utils.typ": assert_in_dict, assert_in_arr, map_none, assert_dict_has
// thesis types
#import "bp.typ": bp
@@ -12,16 +12,21 @@
language, faculty_id, document_type, citation_file, assignment_document,
// document info
title, author, author_gender, supervisor, study_programme, abstract, keywords,
title, author, author_gender, supervisor, study_programme, study_branch, abstract, keywords,
// content
content,
) = {
// argument pre-checking
let document_types = (
"bp": bp,
"other": other,
)
assert_in_dict(document_type, document_types, "document type");
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"));
document_types.at(document_type)(
faculty_id,
@@ -34,6 +39,7 @@
author_gender,
supervisor,
study_programme,
study_branch,
abstract,
keywords,
content,

View File

@@ -7,6 +7,11 @@
#let serif_font = "Merriweather";
#let tul_logomark_size = 6.5em;
// COUNTERS
#let image_count = counter("image_count");
#let table_count = counter("table_count");
// TYPST ELEMENT STYLING
#let default_styling(flip_bonding, faculty_color, content) = {
@@ -32,6 +37,19 @@
set text(font: serif_font);
set par(justify: true);
// figures
let figure_numbering(realcount, c) = {
context realcount.step();
context numbering("1. 1", counter(heading).get().at(0), c)
};
show figure.where(kind: image): set figure(numbering: figure_numbering.with(image_count));
show figure.where(kind: table): set figure(numbering: figure_numbering.with(table_count));
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 +61,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 +76,6 @@
block(it, fill: rgb("#eee"), inset: 1em)
};
set highlight(fill: faculty_color.lighten(90%));
set image(width: 80%);
content
}
@@ -75,7 +96,7 @@
faculty_id,
language,
document_type,
title, author, supervisor, study_programme,
title, author, supervisor, study_programme, study_branch,
) = {
let info_name_value_padding = 5em;
let info_name_min_width = 10em;
@@ -97,7 +118,8 @@
// [field_name, field_value, bold]
let info_fields = (
("study_programme", study_programme, false),
(if author.contains(", ") { "authors" } else { "author" }, author, true),
("study_branch", study_branch, false),
("author", author, true),
("supervisor", supervisor, false),
)
context {
@@ -110,13 +132,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(),
@@ -133,9 +155,9 @@
faculty_id,
language,
document_type,
title, author, supervisor, study_programme,
title, author, supervisor, study_programme, study_branch
) = {
import "../utils.typ": has_all_none
import "../utils.typ": has_all_none, map_none
let nonetype = type(none);
page({
if has_all_none((
@@ -146,8 +168,9 @@
header(faculty_id, language);
align({
info(
faculty_id, language, document_type, title.at(language),
author, supervisor, study_programme,
faculty_id, language, document_type, map_none(title, (v) => v.at(language)),
author, supervisor, map_none(study_programme, (v) => v.at(language)),
map_none(study_branch, (v) => v.at(language)),
);
v(5em);
}, bottom);
@@ -216,6 +239,61 @@
}
}
// _ OUTLINE FIGURE INNER
#let _outline_figure_inner(selector, title, body_mapper) = {
let entry(selector, element) = {
link(
element.location(),
grid(
columns: 3,
gutter: .5em,
stack(
dir: ltr,
text(numbering(
"1. 1",
counter(heading).at(element.location()).at(0),
counter(selector).at(element.location()).at(0),
)),
h(.5em),
text(body_mapper(element)),
),
box(repeat([.], gap: 0.15em)),
str(element.location().page()),
),
)
}
heading(title, numbering: none, outlined: false);
for el in query(figure.where(kind: selector)) {
if is_none(el.caption) {
continue;
}
entry(figure.where(kind: selector), el);
}
}
// _ FIGURE OUTLINE
#let _figure_outline(realcount, target, title) = {
context {
if realcount.final().at(0) == 0 {
return;
}
_outline_figure_inner(target, title, (it) => it.caption.body);
}
}
// IMAGE LIST
#let imagelist(language) = {
_figure_outline(image_count, image, get_lang_item(language, "image_list"));
}
// TABLE LIST
#let tablelist(language) = {
_figure_outline(table_count, table, get_lang_item(language, "table_list"));
}
// ABBREVIATION LIST
#let abbrlist(language) = {

View File

@@ -1,21 +1,35 @@
#import "../lang.typ": get_lang_item
#import "common.typ": mainpage, default_styling, assignment, disclaimer, abstract, toc, abbrlist
#import "../utils.typ": is_none
#import "common.typ": (
mainpage,
default_styling,
assignment,
disclaimer,
abstract,
toc,
abbrlist,
imagelist,
tablelist,
)
#import "../utils.typ": is_none, assert_not_none, assert_dict_has, assert_in_arr
#let other(
// general settings
faculty_id, faculty_color, language, assignment_document, citation_file,
// document info
title, author, _, supervisor, study_programme, abstract_content, keywords,
title, author, _, supervisor, study_programme, study_branch, abstract_content, keywords,
content
) = {
mainpage(faculty_id, language, none, title, author, supervisor, study_programme);
assert_not_none(title, "title");
assert_dict_has((language,), title, "title");
mainpage(faculty_id, language, none, title, author, supervisor, study_programme, study_branch);
default_styling(true, faculty_color, {
toc(language);
abbrlist(language);
imagelist(language);
tablelist(language);
pagebreak(to: "even", weak: true);
content

View File

@@ -4,17 +4,16 @@
"authors": "Autoři",
"supervisor": "Vedoucí práce",
"study_programme": "Studijní program",
"study_branch": "Studijní obor",
"bp": "Bakalářská práce",
"dp": "Diplomová práce",
"dis": "Disertační práce",
"city": "Liberec",
"toc": "Obsah",
"disclaimer": "Prohlášení",
"disclaimer_content": "Prohlašuji, že {svůj} {práce:tu} jsem vypracoval{a} samostatně jako původní dílo s použitím uvedené literatury a na základě konzultací s vedoucím bakalářské práce a konzultantem.\n\nJsem si vědom{a} toho, že na {moji} {práce:tu} se plně vztahuje zákon č. 121/2000 Sb., o právu autorském, zejména § 60 školní dílo.\n\nBeru na vědomí, že Technická univerzita v Liberci nezasahuje do mých autorských práv užitím {} {práce:té} pro vnitřní potřebu Technické univerzity v Liberci.\n\nUžiji-li {práce:tu} nebo poskytnu-li licenci k {jejímu} využití, jsem si vědom{a} povinnosti informovat o této skutečnosti Technickou univerzitu v Liberci; v tomto případě má Technická univerzita v Liberci právo ode mne požadovat úhradu nákladů, které vynaložila na vytvoření díla, až do jejich skutečné výše.\n\nSoučasně čestně prohlašuji, že text elektronické podoby práce vložený do IS/STAG se shoduje s textem tištěné podoby práce.\n\nBeru na vědomí, že {můj} {práce:ta} bude {zveřejněn} Technickou univerzitou v Liberci v souladu s § 47b zákona č. 111/1998 Sb., o vysokých školách a o změně a doplnění dalších zákonů (zákon o vysokých školách), ve znění pozdějších předpisů.\n\nJsem si vědom{a} následků, které podle zákona o vysokých školách mohou vyplývat z porušení tohoto prohlášení.",
"disclaimer_content": "Prohlašuj{g:i|i|eme}, že {svůj} {práce:tu} js{g:em|em|me} vypracoval{g:|a|i} samostatně jako původní dílo s použitím uvedené literatury a na základě konzultací s vedoucím {{g:mé|mé|naší}} bakalářské práce a konzultantem.\n\nJs{g:em|em|me} si vědom{g:|a|i} toho, že na {{g:moji|moji|naši}} {práce:tu} se plně vztahuje zákon č. 121/2000 Sb., o právu autorském, zejména § 60 školní dílo.\n\nBer{g:u|u|eme} na vědomí, že Technická univerzita v Liberci nezasahuje do {g:mých|mých|našich} autorských práv užitím {{g:mé|mé|naší}} {práce:té} pro vnitřní potřebu Technické univerzity v Liberci.\n\nUžij{g:i|i|eme}-li {práce:tu} nebo poskytn{g:u|u|eme}-li licenci k {jejímu} využití, js{g:em|em|me} si vědom{g:|a|i} povinnosti informovat o této skutečnosti Technickou univerzitu v Liberci; v tomto případě má Technická univerzita v Liberci právo od{g:e|e|} {g:mne|mne|nás} požadovat úhradu nákladů, které vynaložila na vytvoření díla, až do jejich skutečné výše.\n\nSoučasně čestně prohlašuj{g:i|i|eme}, že text elektronické podoby práce vložený do IS/STAG se shoduje s textem tištěné podoby práce.\n\nBer{g:u|u|eme} na vědomí, že {{g:můj|můj|naše}} {práce:ta} bude {zveřejněn} Technickou univerzitou v Liberci v souladu s § 47b zákona č. 111/1998 Sb., o vysokých školách a o změně a doplnění dalších zákonů (zákon o vysokých školách), ve znění pozdějších předpisů.\n\nJs{g:em|em|me} si vědom{g:|a|i} následků, které podle zákona o vysokých školách mohou vyplývat z porušení tohoto prohlášení.",
"disclaimer_replace": {
"bp": {
@@ -22,6 +21,9 @@
"práce:tu": "bakalářskou práci",
"práce:té": "bakalářské práce",
"moji": "moji",
"naše": "naše",
"naši": "naši",
"naší": "naší",
"mé": "mé",
"můj": "moje",
"svůj": "svoji",
@@ -35,6 +37,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í"
},
@@ -44,17 +48,16 @@
"authors": "Authors",
"supervisor": "Supervisor",
"study_programme": "Study programme",
"study_branch": "Study branch",
"bp": "Bachelor thesis",
"dp": "Diploma thesis",
"dis": "Dissertation thesis",
"city": "Liberec",
"toc": "Contents",
"disclaimer": "Declaration",
"disclaimer_content": "I hereby certify, I, myself, have written my {thesis} as an original and primary work using the literature listed below and consulting it with my thesis supervisor and my thesis counsellor.\n\nI acknowledge that my {thesis} is fully governed by Act No. 121/2000 Coll., the Copyright Act, in particular Article 60 School Work.\n\nI acknowledge that the Technical University of Liberec does not infringe my copyrights by using my {thesis} for internal purposes of the Technical University of Liberec.\n\nI am aware of my obligation to inform the Technical University of Liberec on having used or granted license to use the results of my {thesis}; in such a case the Technical University of Liberec may require reimbursement of the costs incurred for creating the result up to their actual amount.\n\nAt the same time, I honestly declare that the text of the printed version of my {thesis} is identical with the text of the electronic version uploaded into the IS STAG.\n\nI acknowledge that the Technical University of Liberec will make my {thesis} public in accordance with paragraph 47b of Act No. 111/1998 Coll., on Higher Education Institutions and on Amendment to Other Acts (the Higher Education Act), as amended.\n\nI am aware of the consequences which may under the Higher Education Act result from a breach of this declaration.",
"disclaimer_content": "{g:I|We} hereby certify, {g:I|we}, {g:myself|ourselves}, have written {g:my|our} {thesis} as an original and primary work using the literature listed below and consulting it with {g:my|our} thesis supervisor and {g:my|our} thesis counsellor.\n\n{g:I|We} acknowledge that {g:my|our} {thesis} is fully governed by Act No. 121/2000 Coll., the Copyright Act, in particular Article 60 School Work.\n\n{g:I|We} acknowledge that the Technical University of Liberec does not infringe {g:my|our} copyrights by using {g:my|our} {thesis} for internal purposes of the Technical University of Liberec.\n\n{g:I|We} {g:am|are} aware of {g:my|our} obligation to inform the Technical University of Liberec on having used or granted license to use the results of {g:my|our} {thesis}; in such a case the Technical University of Liberec may require reimbursement of the costs incurred for creating the result up to their actual amount.\n\nAt the same time, {g:I|we} honestly declare that the text of the printed version of {g:my|our} {thesis} is identical with the text of the electronic version uploaded into the IS STAG.\n\n{g:I|We} acknowledge that the Technical University of Liberec will make {g:my|our} {thesis} public in accordance with paragraph 47b of Act No. 111/1998 Coll., on Higher Education Institutions and on Amendment to Other Acts (the Higher Education Act), as amended.\n\n{g:I|We} {g:am|are} aware of the consequences which may under the Higher Education Act result from a breach of this declaration.",
"disclaimer_replace": {
"bp": {
@@ -67,6 +70,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"
}

View File

@@ -1,4 +1,4 @@
#import "utils.typ": assert_in_dict
#import "utils.typ": assert_in_dict, assert_in_arr, map_none, ok_or
#let lang_ids = (
cs: 0,
@@ -21,16 +21,37 @@
return lang_items.at(lang_abbr).at(item_name);
}
#let replace_czech_gender(raw, gender) = {
let genders = (
feminine: 1,
masculine: 0,
we: 2,
);
assert_in_dict(gender, genders, "author gender");
raw.replace(regex("\{g:([^|]*)\|([^|]*)\|([^}]*)\}"), (match) => {
match.captures.at(genders.at(gender))
});
}
#let replace_english_pronounce(raw, pronounce) = {
let pronounce = ok_or(pronounce, "me");
let pronouns = (
me: 0,
we: 1,
);
assert_in_dict(pronounce, pronouns, "author gender");
raw.replace(regex("\{g:([^|]*)\|([^}]*)\}"), (match) => {
match.captures.at(pronouns.at(pronounce))
});
}
#let disclaimer(language, document_type, author_gender) = {
let disclaimer = get_lang_item(language, "disclaimer_content");
let replacements = get_lang_item(language, "disclaimer_replace").at(document_type);
if language == "cs" {
let gender_transforms = (
male: "",
female: "a",
);
assert_in_dict(author_gender, gender_transforms, "author gender");
disclaimer = disclaimer.replace("{a}", gender_transforms.at(author_gender));
disclaimer = replace_czech_gender(disclaimer, author_gender);
} else if language == "en" {
disclaimer = replace_english_pronounce(disclaimer, author_gender);
}
for (key, value) in replacements.pairs() {
disclaimer = disclaimer.replace("{" + key + "}", value);

View File

@@ -23,13 +23,13 @@
// - faculty (str): Factulty abbreviation. One of "fs", "ft", "fp", "ef", "fua", "fm", "fzs", "cxi".
// - lang (str): Language code. This can be "cs" or "en".
// - document (str): Type of document. This can be "bp" or "other".
// - title (str): The title of the document.
// - 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.
// - supervisor (str): The name of the document's supervisor.
// - programme (str): Study programme.
// - abstract (content): The abstract.
// - keywords (array): The abstract keywords.
// - programme (dictionary): Study programme.
// - abstract (dictionary): The abstract.
// - keywords (dictionary): The abstract keywords.
// - assignment (str): Filepath of the assignment document/page.
// - citations (str): The location of the citation file.
// - content (content): The content of the document
@@ -41,7 +41,7 @@
// document info
title: none, keywords: none, abstract: none, author: none, author_gender: none,
supervisor: none, programme: none,
supervisor: none, programme: none, branch: none,
// links
assignment: none, citations: "citations.bib",
@@ -58,13 +58,16 @@
assert_type_signature(document, "string | none", "document kind argument");
assert_type_signature(title, "dictionary[string : string] | none", "title argument");
assert_type_signature(keywords, "dictionary[string : array[string]] | none", "keywords argument");
assert_type_signature(abstract, "dictionary[string : string] | none", "abstract argument");
assert_type_signature(
abstract, "dictionary[string : string | content] | none", "abstract argument"
);
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(
programme, "dictionary[string : string] | none", "study programme argument"
);
assert_type_signature(branch, "dictionary[string : string] | none", "study branch argument");
assert_type_signature(assignment, "string | none", "assignment document argument");
assert_type_signature(citations, "string", "citations file argument");
@@ -83,7 +86,7 @@
// template call
templates.at(style)(
lang, faculty, document, citations, assignment,
title, author, author_gender, supervisor, programme, abstract, keywords,
title, author, author_gender, supervisor, programme, branch, abstract, keywords,
content
);

View File

@@ -3,4 +3,4 @@
@linux
@Satrapa2011
#bibliography("citations.bib", title: "Bibliography - EN", style: "iso-690-author-date")
#bibliography("citations.bib", title: "Bibliography - EN", style: "iso-690-numeric")