12 Commits

9 changed files with 194 additions and 27 deletions

View File

@@ -1,53 +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/tul_citace.csl: template/tul_citace.csl
$(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' > $@
pack/tultemplate2/template/lang.json: template/lang.json
$(PACKDIR)/template/lang.json: template/lang.json
@mkdir -p $(@D)
cat $< | jq -c > $@
pack/tultemplate2/template/%: template/%
$(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

View File

@@ -21,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`

View File

@@ -91,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>
@@ -105,6 +105,10 @@ Velmi jednoduché. Stačí na začátek řádku dát znak `=` kolikrát chcete.
A pak obsah
```
#highlight[
V rámci šablony classic lze použít nadpisy *maximálně* třetí úrovně -- jinak šablona vyhodí chybu.
]
== Zvýrazňování textu
Syntaxe je velmi podobná například markdownu. Stačí:
@@ -168,8 +172,7 @@ A některé funkce berou klasický obsah -- v těch je možné psát obsah jako
== Obrázky
Obrázky je možné vkládat samotné i třeba s popiskem.
Obrázek se vloží pomocí funkce `image`:
Obrázek se vloží pomocí funkce `image`.
Přidání popisku a zároveň zalistování obrázku v indexu (aby se na třeba dalo odkazovat) lze
udělat pomocí funkce `figure`.
@@ -323,6 +326,7 @@ Zvýrazněné hodnoty jsou základní -- pokud vynecháte parametr, pak bude pou
- `document` (typ dokumentu)
- *`"other"`* - nespecifikovaný (neformální) typ dokumentu
- `bp` - Bakalářská práce
- `dp` - Diplomová práce
#line()
- `title` (nadpis dokumentu)
- Ve formátu `(<zkratka_jazyka>: "<nadpis>")`, například `(cs: "Můj nadpis")`
@@ -422,8 +426,14 @@ Zde je ukázka definice příloh (je také použita na konci tohoto ukázkového
```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.]),
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.]
),
)
```

View File

@@ -5,6 +5,7 @@
// thesis types
#import "bp.typ": bp
#import "dp.typ": dp
#import "other.typ": other
#let template_classic(
@@ -21,6 +22,7 @@
// argument pre-checking
let document_types = (
"bp": bp,
"dp": dp,
"other": other,
)
assert_in_dict(document_type, document_types, "document type");

View File

@@ -4,6 +4,7 @@
#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;
@@ -35,7 +36,7 @@
// text
set text(font: serif_font);
set par(justify: true);
set par(justify: true, first-line-indent: 0.63cm);
// figures
let figure_numbering(realcount, c) = {
@@ -69,13 +70,28 @@
v(2cm);
it
};
show heading.where(): it => {
if it.level > 3 {
panic("maximum allowed heading level is 3");
} else {
it
}
}
// 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%));
set line(stroke: (paint: faculty_color, thickness: .7pt), length: 100%);
content
}
@@ -370,9 +386,13 @@
#let bibliogr(language, citations_file) = {
if language == "cs" {
bibliography(citations_file, style: "../tul_citace.csl");
bibliography(
citations_file, style: "../tul_citace.csl", title: get_lang_item(language, "bibliography"),
);
} else if language == "en" {
bibliography(citations_file, style: "iso-690-numeric");
bibliography(
citations_file, style: "iso-690-numeric", title: get_lang_item(language, "bibliography"),
);
} else {
panic("unknown language for bibliography '" + language + "'");
}

68
template/classic/dp.typ Normal file
View File

@@ -0,0 +1,68 @@
#import "../lang.typ": get_lang_item
#import "common.typ": (
mainpage,
default_styling,
assignment,
disclaimer,
abstract,
acknowledgement,
toc,
abbrlist,
imagelist,
tablelist,
bibliogr
)
#import "../attachments.typ": attachment_list
#import "../utils.typ": is_none, assert_dict_has, assert_not_none, assert_type_signature, map_none
#let dp(
// general settings
faculty_id, faculty_color, language, assignment_document, citation_file,
// document info
title, author, author_pronouns, supervisor, consultant, study_programme, study_branch,
year_of_study, abstract_content, acknowledgement_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");
map_none(study_branch, (v) => assert_dict_has((language,), v, "study branch"));
assert_not_none(abstract_content, "abstract");
assert_dict_has(force_langs, abstract_content, "abstract");
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_pronouns, "author gender");
}
assert_type_signature(supervisor, "string | none", "supervisor");
assert_type_signature(consultant, "string | none", "consultant");
mainpage(
faculty_id, language, "dp", title, author, supervisor, consultant, study_programme,
study_branch, year_of_study,
);
assignment(language, assignment_document);
default_styling(false, faculty_color, {
disclaimer(language, faculty_id, "dp", author, author_pronouns);
abstract("cs", title, abstract_content, keywords);
abstract("en", title, abstract_content, keywords);
acknowledgement(language, author, acknowledgement_content);
toc(language);
tablelist(language);
imagelist(language);
abbrlist(language);
pagebreak(weak: true);
content;
bibliogr(language, citation_file);
attachment_list(language);
});
}

View File

@@ -9,6 +9,7 @@
abbrlist,
imagelist,
tablelist,
bibliogr,
)
#import "../attachments.typ": attachment_list
#import "../utils.typ": is_none, assert_not_none, assert_dict_has, assert_in_arr
@@ -37,7 +38,7 @@
abbrlist(language);
pagebreak(to: "even", weak: true);
content;
bibliography(citation_file, style: "../tul_citace.csl");
bibliogr(language, citation_file);
attachment_list(language);
});
}

View File

@@ -9,10 +9,12 @@
"year_of_study": "Ročník",
"bp": "Bakalářská práce",
"dp": "Diplomová práce",
"city": "Liberec",
"toc": "Obsah",
"bibliography": "Použitá literatura",
"disclaimer": "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í.",
@@ -31,6 +33,21 @@
"svůj": "svoji",
"jejímu": "jejímu",
"zveřejněn": "zveřejněna"
},
"dp": {
"práce:ta": "diplomová práce",
"práce:tu": "diplomovou práci",
"práce:té": "diplomové práce",
"moji": "moji",
"naše": "naše",
"naši": "naši",
"naší": "naší",
"mé": "mé",
"můj": "moje",
"svůj": "svoji",
"jejímu": "jejímu",
"zveřejněn": "zveřejněna"
}
},
@@ -60,10 +77,12 @@
"year_of_study": "Year of study",
"bp": "Bachelor thesis",
"dp": "Diploma thesis",
"city": "Liberec",
"toc": "Contents",
"bibliography": "Bibliography",
"disclaimer": "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.",
@@ -71,6 +90,10 @@
"disclaimer_replace": {
"bp": {
"thesis": "bachelor thesis"
},
"dp": {
"thesis": "diploma thesis"
}
},

13
templategen.mk Normal file
View 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) $<