Compare commits
18 Commits
tul_citati
...
v1.2.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
9c954f4f9c
|
|||
|
071696a786
|
|||
|
7a2290c00e
|
|||
|
62d398c807
|
|||
|
0be681b0f0
|
|||
|
30fed8c158
|
|||
|
4a293f7405
|
|||
|
1dfefea074
|
|||
|
0f4d928172
|
|||
|
6ce51e199f
|
|||
|
c755d36d44
|
|||
|
b9f91512cb
|
|||
|
a951de2391
|
|||
|
3f824c6fbe
|
|||
|
8442e269b9
|
|||
|
6f7c8210b3
|
|||
|
|
544e3aeca1 | ||
|
434e01e80d
|
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
||||
/*.pdf
|
||||
/pack
|
||||
/result
|
||||
|
||||
9
Makefile
9
Makefile
@@ -7,7 +7,7 @@ watch_documentation:
|
||||
typst watch --font-path template/fonts documentation.typ & xdg-open documentation.pdf
|
||||
|
||||
.PHONY: watch_%
|
||||
watch_%: %.pdf %_assignment.pdf
|
||||
watch_%: %.pdf
|
||||
xdg-open $< & typst watch --root . --font-path template/fonts theses/$*.typ $<
|
||||
|
||||
.PHONY: documentation
|
||||
@@ -32,7 +32,7 @@ bundle: $(BUNDLE_TARGETS)
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -rf pack
|
||||
rm -f documentation.pdf bp_cs.pdf bp_assignment_cs.pdf dp_cs.pdf
|
||||
rm -f ./*.pdf
|
||||
|
||||
pack/tultemplate2.zip: $(PACK_TARGETS)
|
||||
@mkdir -p $(@D)
|
||||
@@ -92,10 +92,7 @@ TEMPLATE_SRCS := $(shell find template -type f)
|
||||
documentation.pdf: documentation.typ $(TEMPLATE_SRCS)
|
||||
typst compile --font-path template/fonts $<
|
||||
|
||||
%_assignment.pdf: theses/%_assignment.typ
|
||||
typst compile --font-path template/fonts --root . $< $@
|
||||
|
||||
%.pdf: theses/%.typ %_assignment.pdf
|
||||
%.pdf: theses/%.typ
|
||||
typst compile --font-path template/fonts --root . $< $@
|
||||
|
||||
include tests/make.mk
|
||||
|
||||
16
README.md
16
README.md
@@ -1,6 +1,6 @@
|
||||
# tultemplate2
|
||||
|
||||
Easy Typst template for TUL documents. Begin by compiling `example.typ` and reading it.
|
||||
Easy Typst template for TUL documents. Begin by compiling `documentation.typ` and reading it.
|
||||
|
||||
## Recommended usage
|
||||
|
||||
@@ -50,7 +50,7 @@ Oh and also... it's hella fast.
|
||||
|
||||
> [!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:
|
||||
> When running in CLI - you'll want to include the embedded fonts (or run using make):
|
||||
> `typst compile --font-path template/fonts example.typ`
|
||||
|
||||
### Dependencies
|
||||
@@ -61,6 +61,10 @@ Oh and also... it's hella fast.
|
||||
- Typst command (`typst` on Snap / `typst` package on Arch-based repos - AUR not required)
|
||||
- `zip` if you want to make packed builds (perhaps for the on-line editor)
|
||||
|
||||
or
|
||||
|
||||
- Nix (use `nix develop` to enter the development shell and you can skip dependency installation)
|
||||
|
||||
### Building your own thesis
|
||||
|
||||
> [!TIP]
|
||||
@@ -86,6 +90,14 @@ make
|
||||
|
||||
This will compile it once and open it using `xdg-open`.
|
||||
|
||||
Or when using Nix:
|
||||
|
||||
```sh
|
||||
nix build
|
||||
```
|
||||
|
||||
That will output `result/documentation.pdf` which you can view.
|
||||
|
||||
### Building thesis examples
|
||||
|
||||
Thesis examples are in `theses`. They also have assignments pulled from an external file.
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#import "template/template.typ": *
|
||||
|
||||
#show: tultemplate2.with(
|
||||
title: (cs: "Návod na použití Typst TUL šablony"),
|
||||
author: "Ondřej Mekina, Matěj Žucha",
|
||||
supervisor: "Ondřej Mekina",
|
||||
title: (cs: [Návod na použití Typst TUL šablony]),
|
||||
author: [Ondřej Mekina, Matěj Žucha],
|
||||
supervisor: [Ondřej Mekina],
|
||||
)
|
||||
|
||||
#profile("release")
|
||||
@@ -364,6 +364,12 @@ Zde je ukázka definice příloh (je také použita na konci tohoto ukázkového
|
||||
)
|
||||
```
|
||||
|
||||
#pagebreak(weak: true)
|
||||
== Argumenty šablony
|
||||
|
||||
#import "template/arguments.typ": print_argument_docs
|
||||
#print_argument_docs()
|
||||
|
||||
= 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.
|
||||
|
||||
61
flake.lock
generated
Normal file
61
flake.lock
generated
Normal file
@@ -0,0 +1,61 @@
|
||||
{
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1762482733,
|
||||
"narHash": "sha256-g/da4FzvckvbiZT075Sb1/YDNDr+tGQgh4N8i5ceYMg=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "e1ebeec86b771e9d387dd02d82ffdc77ac753abc",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs",
|
||||
"utils": "utils"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1731533236,
|
||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
35
flake.nix
Normal file
35
flake.nix
Normal file
@@ -0,0 +1,35 @@
|
||||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, utils }:
|
||||
utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
dependencies = with pkgs; [ typst gnumake jq xdg-utils zip ];
|
||||
in
|
||||
{
|
||||
packages.documentation = pkgs.stdenv.mkDerivation {
|
||||
pname = "documentation";
|
||||
version = "1.2";
|
||||
src = ./.;
|
||||
buildInputs = dependencies;
|
||||
buildPhase = ''
|
||||
make documentation.pdf
|
||||
'';
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
cp -r documentation.pdf $out/ || true
|
||||
'';
|
||||
};
|
||||
|
||||
packages.default = self.packages.${system}.documentation;
|
||||
|
||||
devShell = with pkgs; mkShell {
|
||||
buildInputs = dependencies;
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -8,21 +8,21 @@
|
||||
type: "string",
|
||||
),
|
||||
title_pages: "string | boolean | none",
|
||||
title: "dictionary[string : string] | none",
|
||||
title: "dictionary[string : string | content] | none",
|
||||
author: (
|
||||
name: "string | none",
|
||||
name: "string | content | none",
|
||||
pronouns: "string | none",
|
||||
programme: "dictionary[string : string] | none",
|
||||
specialization: "dictionary[string : string] | none",
|
||||
year_of_study: "integer | none",
|
||||
programme: "dictionary[string : string | content] | none",
|
||||
specialization: "dictionary[string : string | content] | none",
|
||||
year_of_study: "string | content | none",
|
||||
),
|
||||
project: (
|
||||
supervisor: "string | dictionary[string : string] | none",
|
||||
consultant: "string | dictionary[string : string] | none",
|
||||
supervisor: "string | content | dictionary[string : string | content] | none",
|
||||
consultant: "string | content | dictionary[string : string | content] | none",
|
||||
),
|
||||
abstract: (
|
||||
content: "dictionary[string : string | content] | none",
|
||||
keywords: "dictionary[string : array[string]] | none",
|
||||
keywords: "dictionary[string : string | content | array[string]] | none",
|
||||
),
|
||||
acknowledgement: "dictionary[string : string | content] | none",
|
||||
assignment: "dictionary[string : any] | content | string | none",
|
||||
@@ -30,9 +30,9 @@
|
||||
);
|
||||
|
||||
#let assignment_structure = (
|
||||
personal_number: "string",
|
||||
department: "string",
|
||||
academical_year: "string",
|
||||
personal_number: "string | content",
|
||||
department: "string | content",
|
||||
academical_year: "string | content",
|
||||
content: "content",
|
||||
);
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
</locale>
|
||||
<macro name="author">
|
||||
<names variable="author">
|
||||
<name and="text" name-as-sort-order="all" sort-separator=", " delimiter="; " delimiter-precedes-last="never">
|
||||
<name and="text" name-as-sort-order="first" sort-separator=", " delimiter="; " delimiter-precedes-last="never">
|
||||
<name-part name="family" text-case="uppercase"/>
|
||||
<name-part name="given"/>
|
||||
</name>
|
||||
@@ -203,7 +203,7 @@
|
||||
</macro>
|
||||
<macro name="issue">
|
||||
<group delimiter=", ">
|
||||
<text variable="volume" prefix="Vol. "/>
|
||||
<text variable="volume" prefix="Svazek "/>
|
||||
<choose>
|
||||
<if variable="volume">
|
||||
<text variable="issue" prefix="č. "/>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#import "../arguments.typ": req_arg, get_arg
|
||||
#import "../utils.typ": assert_dict_has, is_none
|
||||
#import "common.typ": mainpage, assignment, external_title_pages
|
||||
#import "thesis_base.typ": thesis_base
|
||||
|
||||
#let bp(args) = {
|
||||
let language = req_arg(args, "document.language");
|
||||
|
||||
@@ -8,12 +8,14 @@
|
||||
// thesis types
|
||||
#import "bp.typ": bp
|
||||
#import "dp.typ": dp
|
||||
#import "prj.typ": prj
|
||||
#import "other.typ": other_title_page, other_base
|
||||
#import "thesis_base.typ": thesis_base, thesis_base_title_pages
|
||||
|
||||
#let document_types = (
|
||||
"bp": (bp, thesis_base, thesis_base_title_pages),
|
||||
"dp": (dp, thesis_base, thesis_base_title_pages),
|
||||
"prj": (prj, thesis_base, thesis_base_title_pages),
|
||||
"other": (other_title_page, other_base, (args) => {}),
|
||||
)
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@
|
||||
#let person_info(record, item_name) = {
|
||||
if is_none(record) {
|
||||
none
|
||||
} else if type(record) == str {
|
||||
} else if type(record) == str or type(record) == content {
|
||||
record
|
||||
} else if type(record) == dictionary {
|
||||
if "name" in record {
|
||||
@@ -200,7 +200,7 @@
|
||||
("consultant", person_info(consultant, "consultant"), false),
|
||||
("study_programme", study_programme, false),
|
||||
("study_specialization", study_specialization, false),
|
||||
("year_of_study", map_none(year_of_study, (v) => str(v) + "."), false),
|
||||
("year_of_study", year_of_study, false),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -285,8 +285,11 @@
|
||||
|
||||
// ASSIGNMENT PAGE
|
||||
|
||||
#let assignment(args) = {
|
||||
#let assignment(args, show_fallback: true) = {
|
||||
if is_none(get_arg(args, "assignment")) {
|
||||
if not show_fallback {
|
||||
return;
|
||||
}
|
||||
page(
|
||||
place(center + horizon, text(
|
||||
get_lang_item(req_arg(args, "document.language"), "place_assignment"),
|
||||
@@ -365,6 +368,14 @@
|
||||
|
||||
// ABSTRACT
|
||||
|
||||
#let display_keywords(keywords) = {
|
||||
if type(keywords) == array {
|
||||
keywords.join(", ")
|
||||
} else if type(keywords) == str or type(keywords) == content {
|
||||
keywords
|
||||
}
|
||||
}
|
||||
|
||||
#let abstract(language, args) = {
|
||||
heading(
|
||||
text(req_arg(args, "title").at(language), font: base_font), numbering: none, outlined: false
|
||||
@@ -382,7 +393,7 @@
|
||||
linebreak();
|
||||
linebreak();
|
||||
text(get_lang_item(language, "keywords") + ": ", weight: "bold", font: base_font);
|
||||
text(keywords.at(language).join(", "));
|
||||
display_keywords(keywords.at(language))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -477,26 +488,29 @@
|
||||
show repeat: none;
|
||||
block(text(it, weight: "bold", size: 1.2em), above: 1.5em);
|
||||
};
|
||||
outline(title: get_lang_item(language, "toc"));
|
||||
context {
|
||||
if query(heading.where(bookmarked: true)).len() > 0 {
|
||||
outline(title: get_lang_item(language, "toc"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// BIBLIOGRAPHY
|
||||
|
||||
#let bibliogr(args) = {
|
||||
let (language, citations_file) = req_arg(args, ("document.language", "citations"));
|
||||
if language == "cs" {
|
||||
bibliography(
|
||||
citations_file,
|
||||
style: "../citations/tul-csn690-numeric-square_brackets.csl",
|
||||
title: get_lang_item(language, "bibliography"),
|
||||
);
|
||||
} else if language == "en" {
|
||||
bibliography(
|
||||
citations_file,
|
||||
style: "../citations/iso690-numeric-square_brackets.csl",
|
||||
title: get_lang_item(language, "bibliography"),
|
||||
);
|
||||
} else {
|
||||
panic("unknown language for bibliography '" + language + "'");
|
||||
let styles = (
|
||||
"cs": "../citations/tul-csn690-numeric-square_brackets.csl",
|
||||
"en": "../citations/iso690-numeric-square_brackets.csl",
|
||||
);
|
||||
let style = styles.at(language);
|
||||
context {
|
||||
if query(ref.where(element: none)).len() > 0 {
|
||||
bibliography(
|
||||
citations_file,
|
||||
style: style,
|
||||
title: get_lang_item(language, "bibliography"),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#import "../arguments.typ": req_arg, get_arg, map_arg
|
||||
#import "../utils.typ": assert_dict_has, is_none
|
||||
#import "common.typ": mainpage, assignment, external_title_pages
|
||||
#import "thesis_base.typ": thesis_base
|
||||
|
||||
#let dp(args) = {
|
||||
let language = req_arg(args, "document.language");
|
||||
|
||||
17
template/classic/prj.typ
Normal file
17
template/classic/prj.typ
Normal file
@@ -0,0 +1,17 @@
|
||||
#import "../arguments.typ": req_arg, get_arg
|
||||
#import "../utils.typ": assert_dict_has, is_none
|
||||
#import "common.typ": mainpage, assignment, external_title_pages
|
||||
|
||||
#let prj(args) = {
|
||||
let language = req_arg(args, "document.language");
|
||||
let programme = req_arg(args, "author.programme");
|
||||
assert_dict_has((language,), programme, "study programme");
|
||||
let specialization = req_arg(args, "author.specialization");
|
||||
assert_dict_has((language,), specialization, "study specialization");
|
||||
if language == "cs" {
|
||||
let _ = req_arg(args, "author.pronouns");
|
||||
}
|
||||
|
||||
mainpage(args);
|
||||
assignment(args, show_fallback: false);
|
||||
}
|
||||
@@ -16,6 +16,8 @@
|
||||
"bp_asgn": "Zadání bakalářské práce",
|
||||
"dp": "Diplomová práce",
|
||||
"dp_asgn": "Zadání diplomové práce",
|
||||
"prj": "Projekt",
|
||||
"prj_asgn": "Zadání projektu",
|
||||
|
||||
"city": "Liberec",
|
||||
|
||||
@@ -23,7 +25,7 @@
|
||||
"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í.",
|
||||
"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ší}} {práce:té} 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": {
|
||||
@@ -54,6 +56,21 @@
|
||||
"svůj": "svoji",
|
||||
"jejímu": "jejímu",
|
||||
"zveřejněn": "zveřejněna"
|
||||
},
|
||||
|
||||
"prj": {
|
||||
"práce:ta": "projekt",
|
||||
"práce:tu": "projekt",
|
||||
"práce:té": "projektu",
|
||||
"moji": "můj",
|
||||
"naše": "náš",
|
||||
"naši": "náš",
|
||||
"naší": "náš",
|
||||
"mé": "mého",
|
||||
"můj": "můj",
|
||||
"svůj": "svůj",
|
||||
"jejímu": "jeho",
|
||||
"zveřejněn": "zveřejněn"
|
||||
}
|
||||
},
|
||||
|
||||
@@ -104,6 +121,8 @@
|
||||
"bp_asgn": "Bachelor thesis assignment",
|
||||
"dp": "Diploma thesis",
|
||||
"dp_asgn": "Diploma thesis assignment",
|
||||
"prj": "Project",
|
||||
"prj_asgn": "Project assignment",
|
||||
|
||||
"city": "Liberec",
|
||||
|
||||
@@ -120,6 +139,10 @@
|
||||
|
||||
"dp": {
|
||||
"thesis": "diploma thesis"
|
||||
},
|
||||
|
||||
"prj": {
|
||||
"thesis": "project"
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
298
template/type_signature.typ
Normal file
298
template/type_signature.typ
Normal file
@@ -0,0 +1,298 @@
|
||||
#let doc(inner, argument_name, explanation) = {
|
||||
inner.doc = (argname: argument_name, expl: explanation);
|
||||
inner
|
||||
}
|
||||
|
||||
#let type_primitive(id, name, cs_name) = {
|
||||
(type: "primitive", type_id: id, type_name: name, type_name_cs: cs_name)
|
||||
}
|
||||
|
||||
#let int = type_primitive("integer", "an 'integer'", "celé číslo");
|
||||
#let float = type_primitive("float", "a 'float'", "desetinné číslo");
|
||||
#let bool = type_primitive("boolean", "a 'boolean'", "pravdivostní hodnota");
|
||||
#let string = type_primitive("string", "a 'string'", "textový řetězec");
|
||||
#let content = type_primitive("content", "a 'content'", "obsah generovaný Typst syntaxí");
|
||||
|
||||
#let literal(value) = {
|
||||
(type: "literal", value: value)
|
||||
}
|
||||
|
||||
#let variants(..variants) = {
|
||||
(type: "variants", variants: variants.pos())
|
||||
}
|
||||
|
||||
#let slice(items) = {
|
||||
(type: "slice", items: items)
|
||||
}
|
||||
|
||||
#let tuple(..items) = {
|
||||
(type: "tuple", items: items.pos())
|
||||
}
|
||||
|
||||
#let keyval(key, val) = {
|
||||
(type: "keyval", key: key, val: val)
|
||||
}
|
||||
|
||||
#let dict(keyval) = {
|
||||
(type: "dictionary", key: keyval.key, val: keyval.val)
|
||||
}
|
||||
|
||||
#let struct(..keyvals) = {
|
||||
let copy_doc(from, to) = {
|
||||
if "doc" in from {
|
||||
let to = to;
|
||||
to.doc = from.doc;
|
||||
to
|
||||
} else {
|
||||
to
|
||||
}
|
||||
}
|
||||
|
||||
let keyvals = keyvals.pos();
|
||||
let res = ().to-dict();
|
||||
for keyval in keyvals {
|
||||
if keyval.key.type != "literal" {
|
||||
panic("invalid type signature, struct keys must be literals");
|
||||
}
|
||||
res.insert(keyval.key.value, copy_doc(keyval, keyval.val));
|
||||
}
|
||||
(type: "struct", pairs: res)
|
||||
}
|
||||
|
||||
#let signature_check(value, signature, name_prefix) = {
|
||||
let error_target_name(target, name_prefix) = {
|
||||
name_prefix + if "doc" in target { " ('" + target.doc.argname + "')" } else { "" }
|
||||
}
|
||||
|
||||
let error_value_name(value) = {
|
||||
str(type(value))
|
||||
}
|
||||
|
||||
let dbg_literal(literal) = {
|
||||
if type(literal) == str {
|
||||
"\"" + literal + "\""
|
||||
} else {
|
||||
"'" + str(literal) + "'"
|
||||
}
|
||||
}
|
||||
|
||||
let error_expected_type(target) = {
|
||||
if target.type == "variants" {
|
||||
let variants = target.variants;
|
||||
let last = variants.pop();
|
||||
let res = (variants.map((v) => { error_expected_type(v) })).join(", ");
|
||||
if type(last) != type(none) {
|
||||
if type(res) != type(none) {
|
||||
res + " or " + error_expected_type(last)
|
||||
} else {
|
||||
error_expected_type(last)
|
||||
}
|
||||
} else {
|
||||
res
|
||||
}
|
||||
} else if target.type == "slice" or target.type == "tuple" {
|
||||
"an array"
|
||||
} else if target.type == "dictionary" or target.type == "struct" {
|
||||
"a dictionary/hashmap"
|
||||
} else if target.type == "primitive" {
|
||||
target.type_name
|
||||
} else if target.type == "literal" {
|
||||
dbg_literal(target.value)
|
||||
} else {
|
||||
panic();
|
||||
}
|
||||
}
|
||||
|
||||
let error(target, name_prefix, value, is_value: false, target_doc: none) = {
|
||||
if type(target_doc) != type(none) {
|
||||
error_target_name(target_doc)
|
||||
} else {
|
||||
error_target_name(target, name_prefix)
|
||||
} + " " + if is_value {
|
||||
"is unexpected"
|
||||
} else {
|
||||
"has an unexpected type '" + error_value_name(value) + "'"
|
||||
} + ", expected " + error_expected_type(target)
|
||||
}
|
||||
|
||||
let in_variants(value, variants, matcher) = {
|
||||
for variant in variants {
|
||||
if matcher(value, variant).at(0) == true {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
let matches_type(value, target, name_prefix: "") = {
|
||||
if target.type == "variants" {
|
||||
return if in_variants(value, target.variants, matches_type.with(name_prefix: name_prefix)) {
|
||||
(true,)
|
||||
} else {
|
||||
(false, error(target, name_prefix, value, is_value: true))
|
||||
}
|
||||
} else if target.type == "literal" {
|
||||
return if value != target.value {
|
||||
(false, error(target, name_prefix, value, is_value: true))
|
||||
} else {
|
||||
(true,)
|
||||
}
|
||||
}
|
||||
if type(value) == dictionary {
|
||||
if target.type == "struct" {
|
||||
for key in target.pairs.keys() {
|
||||
if key not in value {
|
||||
return (false, (
|
||||
error_target_name(target, name_prefix) +
|
||||
" is missing an entry for key " +
|
||||
dbg_literal(key)
|
||||
));
|
||||
}
|
||||
}
|
||||
for (key, val) in value.pairs() {
|
||||
if key not in target.pairs {
|
||||
return (
|
||||
false, name_prefix + " contains an unexpected key " + dbg_literal(key)
|
||||
);
|
||||
}
|
||||
matches_type(
|
||||
val, target.pairs.at(key), name_prefix: name_prefix + " " + str(key)
|
||||
)
|
||||
}
|
||||
} else if target.type == "dictionary" {
|
||||
for (key, val) in value.pairs() {
|
||||
let cur = matches_type(key, target.key, name_prefix: name_prefix + " key");
|
||||
if not cur.at(0) {
|
||||
return cur;
|
||||
}
|
||||
let cur = matches_type(
|
||||
val, target.val, name_prefix: name_prefix + " value"
|
||||
);
|
||||
if not cur.at(0) {
|
||||
return cur;
|
||||
}
|
||||
}
|
||||
(true,)
|
||||
} else {
|
||||
(false, error(target, name_prefix, value))
|
||||
}
|
||||
} else if type(value) == array {
|
||||
if target.type == "slice" {
|
||||
for (idx, val) in value.enumerate() {
|
||||
let cur = matches_type(
|
||||
val, target.items, name_prefix: name_prefix + " item at index " + str(idx)
|
||||
);
|
||||
if not cur.at(0) {
|
||||
return cur;
|
||||
}
|
||||
}
|
||||
(true,)
|
||||
} else if target.type == "tuple" {
|
||||
for (idx, target) in target.items.enumerate() {
|
||||
if idx >= value.len() {
|
||||
return (false, name_prefix + " is missing an item: " + error_expected_type(target))
|
||||
}
|
||||
let cur = matches_type(
|
||||
value.at(idx), target, name_prefix: name_prefix + " item at index " + str(idx)
|
||||
);
|
||||
if not cur.at(0) {
|
||||
return cur;
|
||||
}
|
||||
}
|
||||
(true,)
|
||||
} else {
|
||||
(false, error(target, name_prefix, value))
|
||||
}
|
||||
} else {
|
||||
if target.type != "primitive" or str(type(value)) != target.type_id {
|
||||
(false, error(target, name_prefix, value))
|
||||
} else {
|
||||
(true,)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
matches_type(value, signature, name_prefix: name_prefix)
|
||||
}
|
||||
|
||||
#let signature_docs(target, is_nested: false) = {
|
||||
let typeinfo(target, flatten: false, disable_doc: false) = {
|
||||
let try_doc(target, mapper: (v) => { v }) = {
|
||||
if "doc" in target and not disable_doc {
|
||||
mapper(target.doc.expl);
|
||||
} else {
|
||||
""
|
||||
}
|
||||
}
|
||||
|
||||
if target.type == "struct" {
|
||||
if not flatten {
|
||||
[slovník s přesnými atributy (_dictionary_)];
|
||||
try_doc(target, mapper: (v) => { [ -- ]; v; });
|
||||
":";
|
||||
}
|
||||
list(
|
||||
..target.pairs.pairs().map(((key, val)) => {
|
||||
raw(key);
|
||||
try_doc(val, mapper: (v) => { [ -- ]; text(v); });
|
||||
": "
|
||||
typeinfo(val, disable_doc: true);
|
||||
})
|
||||
);
|
||||
} else if target.type == "dictionary" {
|
||||
[slovník (_dictionary_)];
|
||||
try_doc(target, mapper: (v) => { [ -- ]; v; });
|
||||
":";
|
||||
list(
|
||||
{
|
||||
"S klíči typu ";
|
||||
typeinfo(target.val);
|
||||
},
|
||||
{
|
||||
"S hodnotami typu ";
|
||||
typeinfo(target.key);
|
||||
},
|
||||
);
|
||||
} else if target.type == "slice" {
|
||||
|
||||
} else if target.type == "tuple" {
|
||||
|
||||
} else if target.type == "primitive" {
|
||||
text(target.type_name_cs + " (");
|
||||
text(target.type_id, style: "italic");
|
||||
text(")");
|
||||
try_doc(target, mapper: (v) => { [ -- ]; text(v); });
|
||||
} else if target.type == "variants" {
|
||||
list(
|
||||
..target.variants.map((v) => {
|
||||
list.item({
|
||||
typeinfo(v);
|
||||
});
|
||||
})
|
||||
);
|
||||
} else {
|
||||
panic();
|
||||
}
|
||||
}
|
||||
|
||||
let args = ();
|
||||
if target.type == "struct" {
|
||||
for val in target.pairs.values() {
|
||||
args.push(signature_docs(val, is_nested: true));
|
||||
}
|
||||
} else {
|
||||
if "doc" in target and type(target.doc.argname) != type(none) {
|
||||
args.push({
|
||||
raw(target.doc.argname);
|
||||
[: ]
|
||||
typeinfo(target, flatten: true)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if not is_nested {
|
||||
list(..args.flatten());
|
||||
} else {
|
||||
args.flatten()
|
||||
}
|
||||
}
|
||||
0
theses/autoref_cs.typ
Normal file
0
theses/autoref_cs.typ
Normal file
0
theses/autoref_en.typ
Normal file
0
theses/autoref_en.typ
Normal file
@@ -5,12 +5,35 @@
|
||||
faculty: "fm",
|
||||
lang: "cs",
|
||||
document: "bp",
|
||||
title_pages: "bp_cs_assignment.pdf",
|
||||
title: (
|
||||
cs: "Ukázka dokumentu typu Bakalářská práce pro FM TUL v češtině",
|
||||
en: "Example document for a Bachelor's thesis for FM TUL in Czech",
|
||||
assignment: (
|
||||
personal_number: [A00000007],
|
||||
department: [Ústav šablon],
|
||||
academical_year: [2025/2026],
|
||||
content: [
|
||||
= Zásady pro vypracování:
|
||||
+ Seznamte se s možnostmi šablon
|
||||
+ Navrhněte několik možných stylů šablon
|
||||
+ Seznamte se s nástrojem Typst
|
||||
+ Implementujte šablonu
|
||||
+ Zkonzultujte šablonu
|
||||
+ Opravte spoustu věcí
|
||||
+ Zkonzultujte šablonu
|
||||
+ Opravte spoustu věcí
|
||||
+ Zkonzultujte šablonu
|
||||
+ Snad už nebude nic potřeba opravit
|
||||
= Seznam odborné literatury:
|
||||
_Přísně tajné_
|
||||
],
|
||||
),
|
||||
author: "Matěj Žucha",
|
||||
title: (
|
||||
cs: [Ukázka dokumentu typu Bakalářská práce pro FM TUL v češtině],
|
||||
en: [Example document for a Bachelor's thesis for FM TUL in Czech],
|
||||
),
|
||||
author: [Matěj Žucha],
|
||||
author_pronouns: "masculine",
|
||||
programme: (cs: [MI6000000007 Přísně tajné]),
|
||||
specialization: (cs: [Vytváření šablon]),
|
||||
supervisor: [Ondřej Mekina],
|
||||
abstract: (
|
||||
cs: [
|
||||
Tento dokument slouží jako praktická ukázka všech důležitcýh funkcí šablony _tultemplate2_,
|
||||
@@ -22,10 +45,10 @@
|
||||
],
|
||||
),
|
||||
keywords: (
|
||||
cs: ("Ukázka", "Klíčových", "Slov", "Česky"),
|
||||
en: ("Example", "Keywords", "In", "English"),
|
||||
cs: [Ukázka, Klíčových, Slov, Česky],
|
||||
en: [Example, Keywords, In, English],
|
||||
),
|
||||
acknowledgement: (cs: "Lorem ipsum dolor sit amet."),
|
||||
acknowledgement: (cs: [Lorem ipsum dolor sit amet.]),
|
||||
citations: "citations.bib",
|
||||
)
|
||||
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
#import "../template/template.typ": *
|
||||
|
||||
#tultitlepages2(
|
||||
author: "Matěj Žucha",
|
||||
author_pronouns: "masculine",
|
||||
supervisor: "Ondřej Mekina",
|
||||
document: "bp",
|
||||
faculty: "fm",
|
||||
programme: (cs: "MI6000000007 Přísně tajné"),
|
||||
specialization: (cs: "Vytváření šablon"),
|
||||
title: (cs: "Návod na použití Typst TUL šablony"),
|
||||
assignment: (
|
||||
personal_number: "A00000007",
|
||||
department: "Ústav šablon",
|
||||
academical_year: "2025/2026",
|
||||
content: [
|
||||
= Zásady pro vypracování:
|
||||
|
||||
+ Seznamte se s možnostmi šablon
|
||||
+ Navrhněte několik možných stylů šablon
|
||||
+ Seznamte se s nástrojem Typst
|
||||
+ Implementujte šablonu
|
||||
+ Zkonzultujte šablonu
|
||||
+ Opravte spoustu věcí
|
||||
+ Zkonzultujte šablonu
|
||||
+ Opravte spoustu věcí
|
||||
+ Zkonzultujte šablonu
|
||||
+ Snad už nebude nic potřeba opravit
|
||||
|
||||
= Seznam odborné literatury:
|
||||
|
||||
_Přísně tajné_
|
||||
],
|
||||
),
|
||||
)
|
||||
@@ -1,35 +0,0 @@
|
||||
#import "../template/template.typ": *
|
||||
|
||||
#tultitlepages2(
|
||||
lang: "en",
|
||||
author: "Matěj Žucha",
|
||||
supervisor: "Ondřej Mekina",
|
||||
document: "bp",
|
||||
faculty: "fm",
|
||||
programme: (en: "MI6000000007 Top secret"),
|
||||
specialization: (en: "Creating templates"),
|
||||
title: (en: "A guide to use the Typst TUL template"),
|
||||
assignment: (
|
||||
personal_number: "A00000007",
|
||||
department: "Template department",
|
||||
academical_year: "2025/2026",
|
||||
content: [
|
||||
= Guidelines for development:
|
||||
|
||||
+ Familiarize yourself with the template options
|
||||
+ Design several possible template styles
|
||||
+ Familiarize yourself with the Typst tool
|
||||
+ Implement the template
|
||||
+ Consult on the template
|
||||
+ Fix a bunch of things
|
||||
+ Consult on the template
|
||||
+ Fix a bunch of things
|
||||
+ Consult on the template
|
||||
+ Hopefully nothing else needs to be fixed
|
||||
|
||||
= List of professional literature:
|
||||
|
||||
_Top secret_
|
||||
],
|
||||
),
|
||||
)
|
||||
0
theses/dis_cs.typ
Normal file
0
theses/dis_cs.typ
Normal file
0
theses/dis_en.typ
Normal file
0
theses/dis_en.typ
Normal file
@@ -1,35 +0,0 @@
|
||||
#import "../template/template.typ": *
|
||||
|
||||
#tultitlepages2(
|
||||
author: "Matěj Žucha",
|
||||
author_pronouns: "masculine",
|
||||
supervisor: "Ondřej Mekina",
|
||||
document: "dp",
|
||||
faculty: "fm",
|
||||
programme: (cs: "MI6000000007 Přísně tajné"),
|
||||
specialization: (cs: "Vytváření šablon"),
|
||||
title: (cs: "Návod na použití Typst TUL šablony"),
|
||||
assignment: (
|
||||
personal_number: "A00000007",
|
||||
department: "Ústav šablon",
|
||||
academical_year: "2025/2026",
|
||||
content: [
|
||||
= Zásady pro vypracování:
|
||||
|
||||
+ Seznamte se s možnostmi šablon
|
||||
+ Navrhněte několik možných stylů šablon
|
||||
+ Seznamte se s nástrojem Typst
|
||||
+ Implementujte šablonu
|
||||
+ Zkonzultujte šablonu
|
||||
+ Opravte spoustu věcí
|
||||
+ Zkonzultujte šablonu
|
||||
+ Opravte spoustu věcí
|
||||
+ Zkonzultujte šablonu
|
||||
+ Snad už nebude nic potřeba opravit
|
||||
|
||||
= Seznam odborné literatury:
|
||||
|
||||
_Přísně tajné_
|
||||
],
|
||||
),
|
||||
)
|
||||
0
theses/dp_en.typ
Normal file
0
theses/dp_en.typ
Normal file
0
theses/hab_cs.typ
Normal file
0
theses/hab_cs.typ
Normal file
0
theses/hab_en.typ
Normal file
0
theses/hab_en.typ
Normal file
33
theses/prj_cs.typ
Normal file
33
theses/prj_cs.typ
Normal file
@@ -0,0 +1,33 @@
|
||||
#import "../template/template.typ": *
|
||||
|
||||
#show: tultemplate2.with(
|
||||
style: "classic",
|
||||
faculty: "fm",
|
||||
lang: "cs",
|
||||
document: "prj",
|
||||
title: (
|
||||
cs: "Ukázka dokumentu typu Projekt pro FM TUL v češtině",
|
||||
en: "Example document of type Project for FM TUL in Czech",
|
||||
),
|
||||
author: "Matěj Žucha",
|
||||
author_pronouns: "masculine",
|
||||
programme: (cs: "MI6000000007 Přísně tajné"),
|
||||
specialization: (cs: "Vytváření šablon"),
|
||||
supervisor: "Ondřej Mekina",
|
||||
abstract: (
|
||||
cs: [
|
||||
Tento dokument slouží jako praktická ukázka všech důležitcýh funkcí šablony _tultemplate2_,
|
||||
s názornými příklady použítí a jejich podrobným popisem.
|
||||
],
|
||||
en: [
|
||||
This document serves as a practical demonstration of all the important features of the
|
||||
_tultemplate2_ template, with useful examples and their respective descriptions.
|
||||
],
|
||||
),
|
||||
keywords: (
|
||||
cs: ("Ukázka", "Klíčových", "Slov", "Česky"),
|
||||
en: ("Example", "Keywords", "In", "English"),
|
||||
),
|
||||
acknowledgement: (cs: "Lorem ipsum dolor sit amet."),
|
||||
citations: "citations.bib",
|
||||
)
|
||||
0
theses/prj_en.typ
Normal file
0
theses/prj_en.typ
Normal file
0
theses/sp_cs.typ
Normal file
0
theses/sp_cs.typ
Normal file
0
theses/sp_en.typ
Normal file
0
theses/sp_en.typ
Normal file
0
theses/teze_cs.typ
Normal file
0
theses/teze_cs.typ
Normal file
0
theses/teze_en.typ
Normal file
0
theses/teze_en.typ
Normal file
Reference in New Issue
Block a user