deduplicate content for example theses
This commit is contained in:
39
Makefile
39
Makefile
@@ -29,9 +29,9 @@ bundle: $(BUNDLE_TARGETS)
|
||||
watch_documentation: $(BUILD_DIR)/documentation.pdf
|
||||
xdg-open $< & typst watch --font-path template/fonts documentation.typ $<
|
||||
|
||||
.PHONY: watch_%
|
||||
watch_%: $(BUILD_DIR)/%.pdf
|
||||
xdg-open $< & typst watch --root . --font-path template/fonts theses/$*.typ $<
|
||||
.PHONY: thesis_%
|
||||
thesis_%: $(BUILD_DIR)/%.pdf
|
||||
xdg-open $<
|
||||
|
||||
.PHONY: documentation
|
||||
documentation: $(BUILD_DIR)/documentation.pdf
|
||||
@@ -64,12 +64,37 @@ define minify_json
|
||||
cat $(1) | jq -c > $(2)
|
||||
endef
|
||||
|
||||
# == DIRECT BUILDS ==
|
||||
define replace_with_file_line
|
||||
sed "s/$(1)/$$(sed '$(3)q;d' $(2))/g"
|
||||
endef
|
||||
|
||||
# == DOCUMENTATION ==
|
||||
|
||||
$(BUILD_DIR)/documentation.pdf: documentation.typ $(TEMPLATE_SRCS) | $(BUILD_DIR)
|
||||
typst compile --font-path template/fonts $< $@
|
||||
|
||||
$(BUILD_DIR)/%.pdf: theses/%.typ $(TEMPLATE_SRCS) | $(BUILD_DIR)
|
||||
# == THESES EXAMPLES ==
|
||||
|
||||
$(BUILD_DIR)/subs_%.txt: theses/%.typ | $(BUILD_DIR)
|
||||
awk 'BEGIN{RS=""; ORS="\n\n"} NR>2{print}' $< > $@
|
||||
|
||||
$(BUILD_DIR)/header_%.txt: theses/%.typ
|
||||
awk 'BEGIN{RS=""; ORS="\n\n"} NR<3{print}' $< > $@
|
||||
|
||||
$(BUILD_DIR)/content_%_cs.txt: $(BUILD_DIR)/subs_%_cs.txt theses/content_cs.typ
|
||||
cat theses/content_cs.typ | \
|
||||
$(call replace_with_file_line,{{ta}},$<,1) | $(call replace_with_file_line,{{tou}},$<,2) | \
|
||||
awk 'BEGIN{RS=""; ORS="\n\n"} NR>2{print}' > $@
|
||||
|
||||
$(BUILD_DIR)/content_%_en.txt: $(BUILD_DIR)/subs_%_en.txt theses/content_en.typ
|
||||
cat theses/content_en.typ | \
|
||||
$(call replace_with_file_line,{{what}},$<,1) | \
|
||||
awk 'BEGIN{RS=""; ORS="\n\n"} NR>2{print}' > $@
|
||||
|
||||
$(BUILD_DIR)/%.typ: $(BUILD_DIR)/header_%.txt $(BUILD_DIR)/content_%.txt | $(BUILD_DIR)
|
||||
cat $^ > $@
|
||||
|
||||
$(BUILD_DIR)/%.pdf: $(BUILD_DIR)/%.typ $(TEMPLATE_SRCS) | $(BUILD_DIR)
|
||||
typst compile --font-path template/fonts --root . $< $@
|
||||
|
||||
# == PACKS - clean builds for direct use ==
|
||||
@@ -124,8 +149,8 @@ $(BUNDLEDIR)/template/%: template/% | $(BUNDLEDIR)/template
|
||||
@mkdir -p $(@D)
|
||||
ln -f $< $@
|
||||
|
||||
$(BUNDLEDIR)/%.typ: theses/%.typ | $(BUNDLEDIR)
|
||||
awk 'BEGIN{RS=""; ORS="\n\n"} NR>2{print}' $< | sed 's/\.\.\/template\//template\//' > $@
|
||||
$(BUNDLEDIR)/%.typ: $(BUILD_DIR)/content_%.txt | $(BUNDLEDIR)
|
||||
sed 's/\.\.\/template\//template\//' $< > $@
|
||||
|
||||
# == TESTS ==
|
||||
|
||||
|
||||
292
theses/bp_cs.typ
292
theses/bp_cs.typ
@@ -52,293 +52,5 @@
|
||||
citations: "citations.bib",
|
||||
)
|
||||
|
||||
= Co najdete v této šabloně
|
||||
|
||||
Tato šablona má sloužit jako ukázková bakalářská práce napsaná pomocí jazyka *Typst* a šablony
|
||||
*tultemplate2*. Může posloužit jako jednoduchý základ i pro vaši práci, stačí se naučit používat
|
||||
pár užitečných funkcí, jako např. vkládání obrázků, tabulek, citací nebo odkazů.
|
||||
|
||||
Na rozdíl od souboru _documentation.typ_, který je dostupný ke stažení na stránkách projektu, obsahuje
|
||||
tento dokument jenom to nejpotřebnější ze znalostí, co postačí k úspěšnému napsání práce. Pokud vám budou nějaké funkce chybět, můžete se podívat do zmíněného souboru, anebo kontaktovat některého z autorů, kteří se vám pokusí pomoct. Jen pro úplnost je zde ve zkratce něco málo o jazyce typst a motivaci k tvorbě této šablony:
|
||||
|
||||
Typst je profesionální sázecí nástroj podobný markdownu, LaTeXu/TeXu, groffu, atd.
|
||||
|
||||
Typst je moderní obdobou starších nástrojů, které postrádají spoustu důležitých funkcí, bez kterých
|
||||
se v dnešní době prakticky nedá fungovat. Uživatel často musí importovat nepřeberné množství
|
||||
balíčků, které poskytují (podle mě) naprosto základní funkcionalitu - jako například správná podpora
|
||||
UTF-8 znaků, formátování prvků na základě jazykového lokálu, apod.
|
||||
|
||||
= Začínáme se šablonou
|
||||
|
||||
Tuto šablonu jste si pravděpodobně stáhli z generátoru na webu www.tulsablona.cz a vložili ji do Typst
|
||||
online editoru. Tím pádem vidíte kromě zdrojového kódu také výsledný PDF soubor. Jak už asi víte, hlavní
|
||||
rozdíl mezi tradičními textovými procesory jako Microsoft Word nebo LibreOffice Writer a mezi sázecími
|
||||
programy jako LaTeX nebo Typst je právě způsob, kterým se upravuje vzhled a obsah dokumentu.
|
||||
|
||||
Zatímco ve Wordu jsou uživatelé zvyklí, že pomocí tlačítek a klávesových zkratek mění dokument napřímo,
|
||||
Typst (a i LaTeX) používají tzv. zdrojový soubor, který není ničím jiným než obyčejným textovým souborem,
|
||||
a následně na vyžádání umí tento zdrojový soubor zkompilovat tj. proměnit na výsledný dokument, např. ve formátu PDF.
|
||||
|
||||
Proto zde najdete popis všech důležitých funkcí nikoliv jako galerii obrázků toho, na která tlačítka se má
|
||||
klikat, nýbrž jako ukázka a návod všech speciálních sekvencí textu, které Typst podporuje a které šablona vyhodnocuje jinak než obsah zprávy.
|
||||
|
||||
== Odstavce
|
||||
|
||||
Jak jsou někteří z vás možná zvyklí z Markdownu, odstavce, nadpisy a vlastně pro přehlednost všechny
|
||||
logicky oddělené bloky se oddělují prázným řádkem. Toho jste si jistě mohli při prohlížení tohoto souboru
|
||||
všimnout. Můžete si vyzkoušet, co se stane, když
|
||||
použijete jenom ukončení řádku enterem,
|
||||
|
||||
nebo když použijete zmíněný prázdný řádek,
|
||||
|
||||
|
||||
|
||||
anebo co se stane při použití dvou a více prázdných řádků. (spoiler: 1 a více prázdných řádků mají identické
|
||||
chování, pouze ukončení řádku je interpretováno stejně jako např. mezerník nebo tabulátor)
|
||||
|
||||
Uživatel má tím pádem svobodu v tom, jestli ve zdrojovém souboru používá dlouhé řádky plné textu,
|
||||
nebo
|
||||
má
|
||||
raději
|
||||
přehlednější
|
||||
formátování
|
||||
a sám si obsah dělí na řádky, protože ve výsledném PDF souboru se stejně spojí do jednoho celistvého odstavce.
|
||||
Musí akorát ručně dbát na to, aby odstavce nebyly příliš krátké, ani příliš dlouhé.
|
||||
|
||||
S souvislosti s odstavci bych ještě zmínil, že Typst se za vás stará také o zarovnávání písma a slov do bloků
|
||||
a dělení slov mezi řádky, když už se na něj nevejdou. Chováním odpovídá pravidlům českého pravopisu a typografie, takže se o to nemusíte vůbec starat.
|
||||
|
||||
== Klikatelný obsah
|
||||
|
||||
Pokud používáte oficiální Typst online editor, můžete jednoduše klepnout na jakýkoliv text v pravé části (náhledové PDF), který se dá měnit,
|
||||
a editor podle toho automaticky přesune váš kurzor na správné místo.
|
||||
Je to sice drobná, ale zato velmi užitečná funkce.
|
||||
|
||||
== Nadpisy
|
||||
|
||||
První důležitá funkce kromě psaní samotného textu, k čemuž není zapotřebí žádná speciální syntax, jsou nadpisy.
|
||||
Stejně jako v jiných programech, i Typst podporuje nadpisy více úrovní. Pro nadpis první úrovně se používá znaménko
|
||||
rovná se a mezera na začátku řádku, čili ve zdrojovém souboru Typstu je používán takto:
|
||||
|
||||
```typst
|
||||
= Můj nadpis první úrovně
|
||||
```
|
||||
|
||||
Pro nadpis druhé úrovně pak použijeme dvě rovná se, pro nadpis třetí úrovně tři rovná se.
|
||||
Šablona *tultemplate2* Vám ovšem bohužel nedovolí nadpis čtvrté a další úrovně, protože by takový
|
||||
nadpis porušoval směrnice TUL o formátování dokumentů. Ale nemusíte se bát. Pokud takový nadpis
|
||||
uděláte -- šablona vyhodí chybu, aby vás na to upozornila.
|
||||
|
||||
```typst
|
||||
= Nadpis
|
||||
== Podnadpis
|
||||
=== Podpodnadpis
|
||||
|
||||
A pak obsah
|
||||
```
|
||||
|
||||
== Číslování kapitol
|
||||
|
||||
Asi jste si všimli, že každý nadpis začíná číslem dané kapitoly. Toto číslování provádí Typst automaticky, promítne se následně i v sekci Obsah na začátku souboru, nemusíte se tak opět o nic starat.
|
||||
|
||||
= Kontrola šablony při kompilaci
|
||||
|
||||
Tato šablona je vytvořena tak, že když se ji pokusíte zkompilovat s nesprávnou syntaxí nebo s nějakou
|
||||
chybějící důležitou částí hlavičky,
|
||||
nenechá vás to provést. Vždy se podívejte na chybové hlášky, které šablona vypisuje, protože vás snadno navedou k opravě všech chyb.
|
||||
Můžete to vyzkoušet tak, že smažete něco z hlavičky nebo že např. použijete funkci, která není nikde definovaná.
|
||||
|
||||
= Používání funkcí
|
||||
|
||||
Používání většiny funkcionalit Typstu je prováděno pomocí tzv. volání funkce. Je to velmi podobné předchozím ukázkám,
|
||||
akorát místo toho, aby se text obalil pouze jedním symbolem či podobnou jednoduchou značkou, obalíme text jménem dané funkce. Syntaxe vypadá nějak takto:
|
||||
```typst
|
||||
#Název_funkce[samotný text nebo jiné parametry]
|
||||
```
|
||||
Pokud v editoru napíšete symbol hashtagu, začne vám automaticky našeptávat všechny možné funkce a jejich popisy. Přejdeme rovnou k dalším praktickým příkladům.
|
||||
|
||||
== Zvýrazňování textu
|
||||
|
||||
Syntaxe základního zvýraznění je velmi podobná například Markdownu. Stačí použít následující symboly:
|
||||
|
||||
```typst
|
||||
*tučně*
|
||||
_kurzívou_
|
||||
```
|
||||
|
||||
Další stylování lze dělat právě přes funkce, viz třeba:
|
||||
|
||||
```typst
|
||||
#strike[přeškrtnuto]
|
||||
#highlight[zvýrazněno]
|
||||
#underline[podtrženo] // podtržení by se NEMĚLO používat
|
||||
```
|
||||
|
||||
Pro úplnost a ukázku je zde přímo v textu *tučný text*, _text kurzívou_, #strike[přeškrtnutý text] a #highlight[text zvýrazněný podle barvy příslušící vaší fakultě], #underline[podtržený text] (ačkoli typografové doporučují podtržení nepoužívat).
|
||||
|
||||
== Odkazy<links>
|
||||
|
||||
Odkazy je možné dělat na URL/URI zdroje, e-maily, telefony, atd...
|
||||
Odkázat URL (URI) je možné bez zavolání funkce, odkaz stačí prostě a jednodušše napsat:
|
||||
https://git.zumepro.cz/tul/tultemplate2
|
||||
|
||||
```typst
|
||||
https://git.zumepro.cz/tul/tultemplate2
|
||||
```
|
||||
|
||||
Tohle interně volá funkci `link`.
|
||||
|
||||
Pokud odkazujeme na méně časté věci (jako e-maily), můžeme použít funkci `link` přímo.
|
||||
```typst
|
||||
#link("mailto:ondrej@mekina.cz")
|
||||
```
|
||||
|
||||
Dalši předpony (URI schémata) můžete najít třeba na Wikipedii
|
||||
https://en.wikipedia.org/wiki/List_of_URI_schemes.
|
||||
|
||||
== Obrázky
|
||||
|
||||
Obrázky je možné vkládat samotné, nebo i s popiskem.
|
||||
Obrázek se vloží pomocí funkce `image`.
|
||||
|
||||
Přidání popisku a zároveň zalistování obrázku v indexu (aby se na ně třeba dalo odkazovat) lze
|
||||
udělat pomocí funkce `figure`.
|
||||
|
||||
#block([
|
||||
```typst
|
||||
#figure(
|
||||
image("mujobrazek.jpg"),
|
||||
caption: [
|
||||
*Krásný* obrázek, který vypadá jako obrázek.
|
||||
]
|
||||
)
|
||||
```
|
||||
], breakable: false)
|
||||
|
||||
Tady je praktická ukázka jednoduchého vložení obrázku s popiskem:
|
||||
|
||||
#figure(image("../template/assets/tul_logo.svg", width: 25%), caption: [
|
||||
Logo *TUL*
|
||||
])
|
||||
|
||||
První parametr funkce je zobrazovaný obsah, v našem případě zmíněný `image`. K němu můžeme psát různé parametry, v příkladu máme třeba nastavení šířky obrázku v procentech. Jako poslední je parametr `caption`, s jehož pomocí můžeme nastavit popisek obrázku/figury.
|
||||
|
||||
Obrázky se zobrazí na začátku dokumentu v seznamu (pokud to daný typ dokumentu vyžaduje). I toto za vás Typst dělá automaticky, vám tak stačí do textu přidávat obrázky, jak se to hodí, a všechny se poté korektně zobrazí v Seznamu obrázků s odkazem i správně uvedenou stránkou, na které se obrázek nachází. Obrázky jsou také automaticky číslovány podle předepsaného způsobu, podobně jako kapitoly.
|
||||
|
||||
== 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")
|
||||
```
|
||||
|
||||
Parametr `columns` udává počet sloupců tabulky. Poté následuje libovolný počet buněk tabulky, pro lepší přehlednost jsou v příkladu jednotlivé řádky oddělené. Nakonec je zde opět parametr `caption` sloužící k zadání popisku tabulky.
|
||||
|
||||
#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). Jak už jste asi pochopili, i toto provede šablona automaticky.
|
||||
|
||||
== Citace
|
||||
|
||||
Šablona podporuje správu citací pomocí standardního BibTeX @bibtex souboru, stejně jako
|
||||
například LaTeX. Generování citací v BibTeX zápisu umí téměř každá stránka nebo program, které mají pro citace podporu.
|
||||
Kód takovéto citace ve vhodném formátu stačí přidat do souboru _citations.bib_, poté je možné se
|
||||
na ně odkazovat pomocí `@jmeno_citace`, nebo `#cite(<jmeno_citace>)`. Můžu se tak třeba odkázat na
|
||||
citaci Typstu #cite(<typst>).
|
||||
|
||||
Formát souboru _citations.bib_ je naprosto stejný jako pro LaTeX. Tyto citace lze přímo vložit
|
||||
třeba z webu https://www.citace.com ve formátu BibTeX -- Typst tento formát také umí přečíst.
|
||||
Můžete se do souboru s příponou .bib podívat, zjistíte, že je to opravdu jen obyčejný textový soubor se specifickou strukturou.
|
||||
V přiloženém ukázkovém souboru už nějaké citace jsou - např. již použitá citace se jménem `typst`.
|
||||
|
||||
Soubor, ze kterého se načtou citace lze změnit pomocí argumentu šablony (tj. struktura na začátku souboru):
|
||||
|
||||
```typst
|
||||
#show: tultemplate2.with(
|
||||
...
|
||||
citations: "jinysoubor.bib",
|
||||
...
|
||||
)
|
||||
```
|
||||
|
||||
== Vnitřní odkazy a kotvy<ukazka_odkazu>
|
||||
|
||||
Trochu navážeme na Odkazy (@links).
|
||||
|
||||
Můžete dělat i vnitřní odkazy třeba na kapitoly, stránky nebo obrázky s popiskem (zabalené ve
|
||||
`figure`).
|
||||
|
||||
```typst
|
||||
= Dobrá kapitola<dobra_kapitola>
|
||||
|
||||
Podívejme se na Dobrou kapitolu (@dobra_kapitola).
|
||||
```
|
||||
|
||||
Takhle vypadá kotva:
|
||||
|
||||
```typst
|
||||
<nazev_kotvy>
|
||||
```
|
||||
|
||||
Kotvu dáte někam do souboru a můžete na ní odkazovat stejně jako na citace:
|
||||
|
||||
```typst
|
||||
@nazev_kotvy
|
||||
```
|
||||
Můžeme se podívat na názornou ukázku odkazu (@ukazka_odkazu).
|
||||
|
||||
== Zkratky
|
||||
|
||||
LaTeX TUL šablona má k začátku dokumentu seznam zkratek. Proto jsme ho přidali i do této šablony.
|
||||
Seznam zkratek je v této šabloně nastaven tak, aby se zobrazoval pouze pokud je v něm alespoň jedna
|
||||
zkratka (přišlo nám to poměrně logické).
|
||||
|
||||
Zkratku #abbr("ABC", "Abeceda") vytvoříte (definujete) pomocí:
|
||||
|
||||
```typst
|
||||
#abbr("ABC", "Abeceda")
|
||||
```
|
||||
|
||||
Potom zkratku #abbr("ABC") už můžete použít přímo (bez opakované definice):
|
||||
|
||||
```typst
|
||||
#abbr("ABC")
|
||||
```
|
||||
|
||||
Šablona zajistí následující věci:
|
||||
- Zkratka se zobrazí v seznamu zkratek
|
||||
- Při prvním použití zkratky vás šablona donutí zkratku definovat
|
||||
- Definice zkratky bude použita právě jednou (poprvé)
|
||||
|
||||
Při prvním použití zkratky (při definici) bude zkratka v textu vypadat takto:
|
||||
#abbr("ZK", "Zkratka").
|
||||
Při dalších použití bude vypadat takto: #abbr("ZK").
|
||||
|
||||
#highlight[
|
||||
Tedy zkratku _nepřidáváte_ přímo do seznamu zkratek, ale elegantně jí používáte přímo v textu.
|
||||
]
|
||||
|
||||
== Přílohy
|
||||
|
||||
Na konec souboru (nebo klidně doprostřed či na začátek, hlavní je, že pouze jednou) je také možné dát strukturu generující přílohy. Momentálně jsou podporované čtyři typy příloh: odkaz, obsah, PDF soubor vložený na konec dokumentu a odkaz na externí soubor (například přiložený do systému s bakalářskou prací).
|
||||
Jako demonstrace by měla postačit praktická ukázka, která ve zdrojovém kódu následuje hned za tímto odstavcem, a která generuje přílohy tohoto 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.]),
|
||||
)
|
||||
Bakalářská práce
|
||||
bakalářskou práci
|
||||
|
||||
310
theses/bp_en.typ
310
theses/bp_en.typ
@@ -52,312 +52,4 @@
|
||||
citations: "citations.bib",
|
||||
)
|
||||
|
||||
= A quick few words about this template
|
||||
|
||||
This template should serve as an example Bachelor thesis written with the help of the *Typst* programming
|
||||
language and the *tultemplate2* template. It can be used as a starting point for your own report, you just
|
||||
have to learn a few of its useful functions, e.g. how to insert images, tables, citacions or links.
|
||||
|
||||
In contrast with the _documentation.typ_ file, which is available for download on the project's page,
|
||||
this document only contains the most necessary knowledge to complete most reports. If you find this
|
||||
documentt lacking in features, you can look at the aforementioned docs or contact one of the authors,
|
||||
who will try to help you. Just for the sake of completeness, here is a few words about the Typst programming
|
||||
language and about Typst, as well as about the motivation behind the creation of this template:
|
||||
|
||||
Typst is a professional typesetting language similar to markdown, LaTeX/TeX, groff, etc.
|
||||
|
||||
Typst is the modern equivalent of older typesetting tools, which often lack a lot of important features,
|
||||
such that make it next to impossible to work without today. The user must often import an incountable number of packages,
|
||||
which only provide only the most basic of functionalities --- for example proper UTF-8 character support,
|
||||
formatting of elements based on the set locale, etc.
|
||||
|
||||
= Getting Started with the Template
|
||||
|
||||
You have probably downloaded this template from the generator on the website www.tulsablona.cz and inserted
|
||||
it into the Typst online editor. Therefore, besides the source code, you can also see the resulting PDF file.
|
||||
As you probably know, the main difference between traditional word processors like Microsoft Word or LibreOffice
|
||||
Writer and typesetting programs like LaTeX or Typst is the way in which the appearance and content of the document
|
||||
are edited.
|
||||
|
||||
While Word users are used to changing the document directly using buttons and keyboard shortcuts, Typst (and also LaTeX)
|
||||
use a so-called source file, which is nothing more than an ordinary text file, and can then, on request, compile this
|
||||
source file -- i.e., turn it into the final document, for example in PDF format.
|
||||
|
||||
That’s why here you will find a description of all the important functions not as a gallery of images showing which
|
||||
buttons to click, but rather as an example and guide to all the special text sequences that Typst supports and that
|
||||
the template interprets differently from the main content of the report.
|
||||
|
||||
== Paragraphs
|
||||
|
||||
Some of you might know this concept from using Markdown, where paragraphs, headings and for the sake of clarity all
|
||||
logically coherent blocks are separated by an empty line. You might have already spotted this while reading through
|
||||
this document. You can try for yourself what happens when
|
||||
you just end the line
|
||||
|
||||
or when you properly use an empty line,
|
||||
|
||||
|
||||
|
||||
|
||||
or maybe what happens if you use two or more empty rows. (spoiler: 1 or more empty lines share identical behavior,
|
||||
while newlining only is interpreted the same as using spaces or tabs)
|
||||
|
||||
Therefore, the user has freedom of choosing whether he uses long lines full of text,
|
||||
or
|
||||
if
|
||||
he
|
||||
prefers
|
||||
a
|
||||
cleaner
|
||||
formatting
|
||||
and manages the separation of content to lines, because it all gets concatenated into a nice consice paragraph.
|
||||
The user has to manually watch out for the length of the paragraphs, so that they are neither too short or too long.
|
||||
|
||||
In the context of paragraphs, it should be mentioned that Typst also manages the alignment of text and words into blocks
|
||||
and the division of words between lines when they don't fit.
|
||||
This behavior complies with the English grammar and typography rules fully, so you don't have to think about that at all.
|
||||
|
||||
== Clickable content
|
||||
|
||||
When using the official Typst online editor, you can simply click on any text in the right side (the preview PDF),
|
||||
and your cursor will jump directly to that text in the source file.
|
||||
A small but very practical feature.
|
||||
|
||||
== Headings
|
||||
|
||||
The first important feature, apart from writing the text itself (which requires no special syntax), is the usage of headings.
|
||||
Just like in other programs, Typst also supports multi-level headings. For a first-level heading, an equals sign followed
|
||||
by a space is used at the beginning of a line, meaning that in a Typst source file it is written like this:
|
||||
|
||||
```typst
|
||||
= My first level heading
|
||||
```
|
||||
|
||||
For a second-level heading, we then use two equals signs; for a third-level heading, three equals signs…
|
||||
There are enough subheading levels that you’ll probably never run out. However, the TUL guidelines for writing reports
|
||||
forbid usage of level four heading or larger, so you can (and should) only use headings from level 1 to 3.
|
||||
If you try to use fourth-level or larger heading, the template will warn you not to do that and will refuse to compile
|
||||
until you fix this. More on this behavior later.
|
||||
|
||||
```typst
|
||||
= Heading
|
||||
== Subheading
|
||||
=== Subsubheading
|
||||
|
||||
And then your content
|
||||
```
|
||||
|
||||
== Chapter Numbering
|
||||
|
||||
You’ve probably noticed that each heading begins with the number of its respective chapter. Typst handles this numbering
|
||||
automatically, and it’s also reflected in the *Table of Contents* at the start of the document, so you don’t have to
|
||||
worry about it yourself.
|
||||
|
||||
== Template compile-time checks
|
||||
|
||||
This template is created in such a way that when you try to compile it with incorrect syntax or an imoportant
|
||||
part of the header missing, it won't let you. Always see the error messages the template provides,
|
||||
as they will simply guide you to fix your mistakes. You can try this by deleting something from the header,
|
||||
or by using e.g. a function that ins't defined anywhere.
|
||||
|
||||
= Using Functions
|
||||
|
||||
Most Typst features are used through what’s called *function calls*. This is quite similar to the previous examples,
|
||||
except that instead of wrapping text with a single symbol or a simple marker, we wrap it with the name of the function.
|
||||
The syntax looks like this:
|
||||
|
||||
```typst
|
||||
#Function_name[text itself or other parameters]
|
||||
```
|
||||
|
||||
When you type the hash symbol in the editor, it will automatically start suggesting all available functions and their descriptions.
|
||||
Let’s move on to some practical examples.
|
||||
|
||||
== Text Highlighting
|
||||
|
||||
The syntax for basic highlighting is very similar to Markdown. You just need to use the following symbols:
|
||||
|
||||
```typst
|
||||
*bold*
|
||||
_italic_
|
||||
```
|
||||
|
||||
More styling options can be applied through functions, for example:
|
||||
|
||||
```typst
|
||||
#strike[struck through]
|
||||
#highlight[highlighted]
|
||||
#underline[underlined] // underline SHOULD NOT be used
|
||||
```
|
||||
|
||||
For completeness and demonstration, here in the text we have *bold text*, _italic text_, #strike[struck-through text],
|
||||
and #highlight[text highlighted with your faculty’s color], as well as #underline[underlined text]
|
||||
(although typographers generally advise against using underlining).
|
||||
|
||||
== Links<links>
|
||||
|
||||
You can create links to URLs/URIs, emails, phone numbers, and more.
|
||||
A URL (URI) link can be written directly, without calling any function --- just type it in:
|
||||
|
||||
https://git.zumepro.cz/tul/tultemplate2
|
||||
|
||||
```typst
|
||||
https://git.zumepro.cz/tul/tultemplate2
|
||||
```
|
||||
|
||||
Internally, this automatically calls the `link` function.
|
||||
|
||||
If we want to link to less common things (like email addresses), we can call the `link` function explicitly:
|
||||
|
||||
```typst
|
||||
#link("mailto:ondrej@mekina.cz")
|
||||
```
|
||||
|
||||
You can find other prefixes (URI schemes) on Wikipedia:
|
||||
https://en.wikipedia.org/wiki/List_of_URI_schemes.
|
||||
|
||||
== Images
|
||||
|
||||
Images can be inserted either by themselves or with a caption.
|
||||
|
||||
An image is inserted using the `image` function:
|
||||
|
||||
To add a caption and also include the image in the index (so you can reference it later), use the `figure` function:
|
||||
|
||||
#block([
|
||||
```typst
|
||||
#figure(
|
||||
image("myimage.jpg"),
|
||||
caption: [
|
||||
*A beautiful* picture that looks like a picture.
|
||||
]
|
||||
)
|
||||
```
|
||||
], breakable: false)
|
||||
|
||||
Here’s a practical example of inserting an image with a caption:
|
||||
|
||||
#figure(image("../template/assets/tul_logo.svg", width: 25%), caption: [
|
||||
Logo of *TUL*
|
||||
])
|
||||
|
||||
The first parameter of the function is the displayed content --- in our case, the mentioned `image`. You can then specify various parameters for it; in the example, we define the image width as a percentage.
|
||||
The last parameter is `caption`, which lets us set the figure’s (or image’s) caption text.
|
||||
|
||||
If the document type requires it, images will automatically appear in a list at the beginning of the document. Typst handles this automatically for you --- all you need to do is add images wherever appropriate, and they’ll show up correctly in the *List of Figures*, complete with references and page numbers.
|
||||
Images are also numbered automatically according to the predefined style, similar to chapters.
|
||||
|
||||
== Tables
|
||||
|
||||
Tables can be created like this:
|
||||
|
||||
```typst
|
||||
#figure(table(
|
||||
columns: 3,
|
||||
table.header([], [*Column 1*], [*Column 2*]),
|
||||
[*Row 1*], [a], [b],
|
||||
[*Row 2*], [c], [d],
|
||||
), caption: "My beautiful table")
|
||||
```
|
||||
|
||||
The `columns` parameter specifies the number of columns in the table. Then comes any number of table cells --- for clarity, the rows are separated in the example. Finally, there’s again a `caption` parameter, used to provide a caption for the table.
|
||||
|
||||
#highlight[It’s a good idea to wrap the table header (the first row) in the `header` function (as shown above)] --- this ensures Typst includes extra metadata in the generated PDF (for example, for people with visual impairments).
|
||||
|
||||
#figure(table(
|
||||
columns: 3,
|
||||
table.header([], [*Column 1*], [*Column 2*]),
|
||||
[*Row 1*], [a], [b],
|
||||
[*Row 2*], [c], [d],
|
||||
), caption: "My beautiful table")
|
||||
|
||||
Tables also appear at the beginning of the document in a list (if required by the document type).
|
||||
As you’ve probably noticed by now, Typst’s template takes care of this automatically.
|
||||
|
||||
== Citations
|
||||
|
||||
The template supports citation management using a standard BibTeX file @bibtex, just like LaTeX. Almost every website or program that supports citations can generate BibTeX-formatted entries.
|
||||
You simply add the code for such a citation, in the proper format, to the file _citations.bib_. Once added, you can reference it using `@citation_name` or `#cite(<citation_name>)`.
|
||||
For example, I can reference the Typst citation as #cite(<typst>).
|
||||
|
||||
The format of the _citations.bib_ file is exactly the same as in LaTeX. You can even copy entries directly from sites like [citace.com](https://www.citace.com) in BibTeX format --- Typst understands that format, too.
|
||||
If you open a `.bib` file, you’ll see that it’s simply a plain text file with a specific structure.
|
||||
The provided sample file already contains several citations --- for instance, the one named `typst`, which was already used above.
|
||||
|
||||
You can change the file from which citations are loaded using a template argument (i.e., in the structure at the beginning of your Typst document):
|
||||
|
||||
```typst
|
||||
#show: tultemplate2.with(
|
||||
...
|
||||
citations: "anotherfile.bib",
|
||||
...
|
||||
)
|
||||
```
|
||||
|
||||
== Internal Links and Anchors<example_anchor>
|
||||
|
||||
Let’s continue from the *Links* section (@links).
|
||||
|
||||
You can also create internal links --- for instance, to chapters, pages, or labeled images (those wrapped with the `figure` function).
|
||||
|
||||
```typst
|
||||
= A Good Chapter<good_chapter>
|
||||
|
||||
Let’s take a look at A Good Chapter (@good_chapter).
|
||||
```
|
||||
|
||||
Here’s what an anchor looks like:
|
||||
|
||||
```typst
|
||||
<anchor_name>
|
||||
```
|
||||
|
||||
You place the anchor anywhere in the file, and you can reference it the same way you reference citations:
|
||||
|
||||
```typst
|
||||
@anchor_name
|
||||
```
|
||||
|
||||
For example, we can take a look at this illustrative reference (@example_anchor).
|
||||
|
||||
== Abbreviations
|
||||
|
||||
The LaTeX TUL template includes a list of abbreviations at the beginning of the document. Therefore, we’ve included one here as well.
|
||||
This list is configured to appear only if there is *at least one* abbreviation defined --- which seemed quite logical.
|
||||
|
||||
You can create (define) an abbreviation with #abbr("ABC", "Alphabet") like this:
|
||||
|
||||
```typst
|
||||
#abbr("ABC", "Alphabet")
|
||||
```
|
||||
|
||||
After that, you can use the abbreviation #abbr("ABC") directly without redefining it:
|
||||
|
||||
```typst
|
||||
#abbr("ABC")
|
||||
```
|
||||
|
||||
The template automatically ensures the following:
|
||||
- The abbreviation appears in the list of abbreviations
|
||||
- When you use an abbreviation for the first time, the template *requires* you to define it
|
||||
- The definition is used only once (the first time it appears)
|
||||
|
||||
When used for the first time (definition), the abbreviation will look like this:
|
||||
#abbr("ABR", "Abbreviation").
|
||||
In subsequent uses, it will appear as: #abbr("ABR").
|
||||
|
||||
#highlight[
|
||||
In other words, you do _not_ add abbreviations directly to the abbreviation list.
|
||||
You simply use them elegantly within the text itself.
|
||||
]
|
||||
|
||||
== Attachments
|
||||
|
||||
At the end of the file (or anywhere else, as long as it’s included only once), you can add a structure that generates attachments.
|
||||
Currently, two types of attachments are supported --- links and content.
|
||||
As a demonstration, here’s a practical example (included right after this paragraph in the source code), which generates the attachments for this document:
|
||||
|
||||
#attachments(
|
||||
attach_link("Source code of this template", "https://git.zumepro.cz/tul/tultemplate2"),
|
||||
attach_content("Test content generated by Typst", [Here you can write _styled_ content.]),
|
||||
)
|
||||
Bachelor thesis
|
||||
|
||||
295
theses/content_cs.typ
Normal file
295
theses/content_cs.typ
Normal file
@@ -0,0 +1,295 @@
|
||||
#import "../template/template.typ": *
|
||||
|
||||
#show: tultemplate2
|
||||
|
||||
= Co najdete v této šabloně
|
||||
|
||||
Tato šablona má sloužit jako ukázka práce typu `{{ta}}` v jazyce *Typst* a šabloně
|
||||
*tultemplate2*. Může posloužit jako jednoduchý základ i pro vaši práci, stačí se naučit používat
|
||||
pár užitečných funkcí, jako např. vkládání obrázků, tabulek, citací nebo odkazů.
|
||||
|
||||
Na rozdíl od souboru _documentation.typ_, který je dostupný ke stažení na stránkách projektu, obsahuje
|
||||
tento dokument jenom to nejpotřebnější ze znalostí, co postačí k úspěšnému napsání práce. Pokud vám budou nějaké funkce chybět, můžete se podívat do zmíněného souboru, anebo kontaktovat některého z autorů, kteří se vám pokusí pomoct. Jen pro úplnost je zde ve zkratce něco málo o jazyce typst a motivaci k tvorbě této šablony:
|
||||
|
||||
Typst je profesionální sázecí nástroj podobný markdownu, LaTeXu/TeXu, groffu, atd.
|
||||
|
||||
Typst je moderní obdobou starších nástrojů, které postrádají spoustu důležitých funkcí, bez kterých
|
||||
se v dnešní době prakticky nedá fungovat. Uživatel často musí importovat nepřeberné množství
|
||||
balíčků, které poskytují (podle mě) naprosto základní funkcionalitu - jako například správná podpora
|
||||
UTF-8 znaků, formátování prvků na základě jazykového lokálu, apod.
|
||||
|
||||
= Začínáme se šablonou
|
||||
|
||||
Tuto šablonu jste si pravděpodobně stáhli z generátoru na webu www.tulsablona.cz a vložili ji do Typst
|
||||
online editoru. Tím pádem vidíte kromě zdrojového kódu také výsledný PDF soubor. Jak už asi víte, hlavní
|
||||
rozdíl mezi tradičními textovými procesory jako Microsoft Word nebo LibreOffice Writer a mezi sázecími
|
||||
programy jako LaTeX nebo Typst je právě způsob, kterým se upravuje vzhled a obsah dokumentu.
|
||||
|
||||
Zatímco ve Wordu jsou uživatelé zvyklí, že pomocí tlačítek a klávesových zkratek mění dokument napřímo,
|
||||
Typst (a i LaTeX) používají tzv. zdrojový soubor, který není ničím jiným než obyčejným textovým souborem,
|
||||
a následně na vyžádání umí tento zdrojový soubor zkompilovat tj. proměnit na výsledný dokument, např. ve formátu PDF.
|
||||
|
||||
Proto zde najdete popis všech důležitých funkcí nikoliv jako galerii obrázků toho, na která tlačítka se má
|
||||
klikat, nýbrž jako ukázka a návod všech speciálních sekvencí textu, které Typst podporuje a které šablona vyhodnocuje jinak než obsah zprávy.
|
||||
|
||||
== Odstavce
|
||||
|
||||
Jak jsou někteří z vás možná zvyklí z Markdownu, odstavce, nadpisy a vlastně pro přehlednost všechny
|
||||
logicky oddělené bloky se oddělují prázným řádkem. Toho jste si jistě mohli při prohlížení tohoto souboru
|
||||
všimnout. Můžete si vyzkoušet, co se stane, když
|
||||
použijete jenom ukončení řádku enterem,
|
||||
|
||||
nebo když použijete zmíněný prázdný řádek,
|
||||
|
||||
|
||||
|
||||
anebo co se stane při použití dvou a více prázdných řádků. (spoiler: 1 a více prázdných řádků mají identické
|
||||
chování, pouze ukončení řádku je interpretováno stejně jako např. mezerník nebo tabulátor)
|
||||
|
||||
Uživatel má tím pádem svobodu v tom, jestli ve zdrojovém souboru používá dlouhé řádky plné textu,
|
||||
nebo
|
||||
má
|
||||
raději
|
||||
přehlednější
|
||||
formátování
|
||||
a sám si obsah dělí na řádky, protože ve výsledném PDF souboru se stejně spojí do jednoho celistvého odstavce.
|
||||
Musí akorát ručně dbát na to, aby odstavce nebyly příliš krátké, ani příliš dlouhé.
|
||||
|
||||
S souvislosti s odstavci bych ještě zmínil, že Typst se za vás stará také o zarovnávání písma a slov do bloků
|
||||
a dělení slov mezi řádky, když už se na něj nevejdou. Chováním odpovídá pravidlům českého pravopisu a typografie, takže se o to nemusíte vůbec starat.
|
||||
|
||||
== Klikatelný obsah
|
||||
|
||||
Pokud používáte oficiální Typst online editor, můžete jednoduše klepnout na jakýkoliv text v pravé části (náhledové PDF), který se dá měnit,
|
||||
a editor podle toho automaticky přesune váš kurzor na správné místo.
|
||||
Je to sice drobná, ale zato velmi užitečná funkce.
|
||||
|
||||
== Nadpisy
|
||||
|
||||
První důležitá funkce kromě psaní samotného textu, k čemuž není zapotřebí žádná speciální syntax, jsou nadpisy.
|
||||
Stejně jako v jiných programech, i Typst podporuje nadpisy více úrovní. Pro nadpis první úrovně se používá znaménko
|
||||
rovná se a mezera na začátku řádku, čili ve zdrojovém souboru Typstu je používán takto:
|
||||
|
||||
```typst
|
||||
= Můj nadpis první úrovně
|
||||
```
|
||||
|
||||
Pro nadpis druhé úrovně pak použijeme dvě rovná se, pro nadpis třetí úrovně tři rovná se.
|
||||
Šablona *tultemplate2* Vám ovšem bohužel nedovolí nadpis čtvrté a další úrovně, protože by takový
|
||||
nadpis porušoval směrnice TUL o formátování dokumentů. Ale nemusíte se bát. Pokud takový nadpis
|
||||
uděláte -- šablona vyhodí chybu, aby vás na to upozornila.
|
||||
|
||||
```typst
|
||||
= Nadpis
|
||||
== Podnadpis
|
||||
=== Podpodnadpis
|
||||
|
||||
A pak obsah
|
||||
```
|
||||
|
||||
== Číslování kapitol
|
||||
|
||||
Asi jste si všimli, že každý nadpis začíná číslem dané kapitoly. Toto číslování provádí Typst automaticky, promítne se následně i v sekci Obsah na začátku souboru, nemusíte se tak opět o nic starat.
|
||||
|
||||
= Kontrola šablony při kompilaci
|
||||
|
||||
Tato šablona je vytvořena tak, že když se ji pokusíte zkompilovat s nesprávnou syntaxí nebo s nějakou
|
||||
chybějící důležitou částí hlavičky,
|
||||
nenechá vás to provést. Vždy se podívejte na chybové hlášky, které šablona vypisuje, protože vás snadno navedou k opravě všech chyb.
|
||||
Můžete to vyzkoušet tak, že smažete něco z hlavičky nebo že např. použijete funkci, která není nikde definovaná.
|
||||
|
||||
= Používání funkcí
|
||||
|
||||
Používání většiny funkcionalit Typstu je prováděno pomocí tzv. volání funkce. Je to velmi podobné předchozím ukázkám,
|
||||
akorát místo toho, aby se text obalil pouze jedním symbolem či podobnou jednoduchou značkou, obalíme text jménem dané funkce. Syntaxe vypadá nějak takto:
|
||||
```typst
|
||||
#Název_funkce[samotný text nebo jiné parametry]
|
||||
```
|
||||
Pokud v editoru napíšete symbol hashtagu, začne vám automaticky našeptávat všechny možné funkce a jejich popisy. Přejdeme rovnou k dalším praktickým příkladům.
|
||||
|
||||
== Zvýrazňování textu
|
||||
|
||||
Syntaxe základního zvýraznění je velmi podobná například Markdownu. Stačí použít následující symboly:
|
||||
|
||||
```typst
|
||||
*tučně*
|
||||
_kurzívou_
|
||||
```
|
||||
|
||||
Další stylování lze dělat právě přes funkce, viz třeba:
|
||||
|
||||
```typst
|
||||
#strike[přeškrtnuto]
|
||||
#highlight[zvýrazněno]
|
||||
#underline[podtrženo] // podtržení by se NEMĚLO používat
|
||||
```
|
||||
|
||||
Pro úplnost a ukázku je zde přímo v textu *tučný text*, _text kurzívou_, #strike[přeškrtnutý text] a #highlight[text zvýrazněný podle barvy příslušící vaší fakultě], #underline[podtržený text] (ačkoli typografové doporučují podtržení nepoužívat).
|
||||
|
||||
== Odkazy<links>
|
||||
|
||||
Odkazy je možné dělat na URL/URI zdroje, e-maily, telefony, atd...
|
||||
Odkázat URL (URI) je možné bez zavolání funkce, odkaz stačí prostě a jednodušše napsat:
|
||||
https://git.zumepro.cz/tul/tultemplate2
|
||||
|
||||
```typst
|
||||
https://git.zumepro.cz/tul/tultemplate2
|
||||
```
|
||||
|
||||
Tohle interně volá funkci `link`.
|
||||
|
||||
Pokud odkazujeme na méně časté věci (jako e-maily), můžeme použít funkci `link` přímo.
|
||||
```typst
|
||||
#link("mailto:ondrej@mekina.cz")
|
||||
```
|
||||
|
||||
Dalši předpony (URI schémata) můžete najít třeba na Wikipedii
|
||||
https://en.wikipedia.org/wiki/List_of_URI_schemes.
|
||||
|
||||
== Obrázky
|
||||
|
||||
Obrázky je možné vkládat samotné, nebo i s popiskem.
|
||||
Obrázek se vloží pomocí funkce `image`.
|
||||
|
||||
Přidání popisku a zároveň zalistování obrázku v indexu (aby se na ně třeba dalo odkazovat) lze
|
||||
udělat pomocí funkce `figure`.
|
||||
|
||||
#block([
|
||||
```typst
|
||||
#figure(
|
||||
image("mujobrazek.jpg"),
|
||||
caption: [
|
||||
*Krásný* obrázek, který vypadá jako obrázek.
|
||||
]
|
||||
)
|
||||
```
|
||||
], breakable: false)
|
||||
|
||||
Tady je praktická ukázka jednoduchého vložení obrázku s popiskem:
|
||||
|
||||
#figure(image("../template/assets/tul_logo.svg", width: 25%), caption: [
|
||||
Logo *TUL*
|
||||
])
|
||||
|
||||
První parametr funkce je zobrazovaný obsah, v našem případě zmíněný `image`. K němu můžeme psát různé parametry, v příkladu máme třeba nastavení šířky obrázku v procentech. Jako poslední je parametr `caption`, s jehož pomocí můžeme nastavit popisek obrázku/figury.
|
||||
|
||||
Obrázky se zobrazí na začátku dokumentu v seznamu (pokud to daný typ dokumentu vyžaduje). I toto za vás Typst dělá automaticky, vám tak stačí do textu přidávat obrázky, jak se to hodí, a všechny se poté korektně zobrazí v Seznamu obrázků s odkazem i správně uvedenou stránkou, na které se obrázek nachází. Obrázky jsou také automaticky číslovány podle předepsaného způsobu, podobně jako kapitoly.
|
||||
|
||||
== 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")
|
||||
```
|
||||
|
||||
Parametr `columns` udává počet sloupců tabulky. Poté následuje libovolný počet buněk tabulky, pro lepší přehlednost jsou v příkladu jednotlivé řádky oddělené. Nakonec je zde opět parametr `caption` sloužící k zadání popisku tabulky.
|
||||
|
||||
#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). Jak už jste asi pochopili, i toto provede šablona automaticky.
|
||||
|
||||
== Citace
|
||||
|
||||
Šablona podporuje správu citací pomocí standardního BibTeX @bibtex souboru, stejně jako
|
||||
například LaTeX. Generování citací v BibTeX zápisu umí téměř každá stránka nebo program, které mají pro citace podporu.
|
||||
Kód takovéto citace ve vhodném formátu stačí přidat do souboru _citations.bib_, poté je možné se
|
||||
na ně odkazovat pomocí `@jmeno_citace`, nebo `#cite(<jmeno_citace>)`. Můžu se tak třeba odkázat na
|
||||
citaci Typstu #cite(<typst>).
|
||||
|
||||
Formát souboru _citations.bib_ je naprosto stejný jako pro LaTeX. Tyto citace lze přímo vložit
|
||||
třeba z webu https://www.citace.com ve formátu BibTeX -- Typst tento formát také umí přečíst.
|
||||
Můžete se do souboru s příponou .bib podívat, zjistíte, že je to opravdu jen obyčejný textový soubor se specifickou strukturou.
|
||||
V přiloženém ukázkovém souboru už nějaké citace jsou - např. již použitá citace se jménem `typst`.
|
||||
|
||||
Soubor, ze kterého se načtou citace lze změnit pomocí argumentu šablony (tj. struktura na začátku souboru):
|
||||
|
||||
```typst
|
||||
#show: tultemplate2.with(
|
||||
...
|
||||
citations: "jinysoubor.bib",
|
||||
...
|
||||
)
|
||||
```
|
||||
|
||||
== Vnitřní odkazy a kotvy<ukazka_odkazu>
|
||||
|
||||
Trochu navážeme na Odkazy (@links).
|
||||
|
||||
Můžete dělat i vnitřní odkazy třeba na kapitoly, stránky nebo obrázky s popiskem (zabalené ve
|
||||
`figure`).
|
||||
|
||||
```typst
|
||||
= Dobrá kapitola<dobra_kapitola>
|
||||
|
||||
Podívejme se na Dobrou kapitolu (@dobra_kapitola).
|
||||
```
|
||||
|
||||
Takhle vypadá kotva:
|
||||
|
||||
```typst
|
||||
<nazev_kotvy>
|
||||
```
|
||||
|
||||
Kotvu dáte někam do souboru a můžete na ní odkazovat stejně jako na citace:
|
||||
|
||||
```typst
|
||||
@nazev_kotvy
|
||||
```
|
||||
Můžeme se podívat na názornou ukázku odkazu (@ukazka_odkazu).
|
||||
|
||||
== Zkratky
|
||||
|
||||
LaTeX TUL šablona má k začátku dokumentu seznam zkratek. Proto jsme ho přidali i do této šablony.
|
||||
Seznam zkratek je v této šabloně nastaven tak, aby se zobrazoval pouze pokud je v něm alespoň jedna
|
||||
zkratka (přišlo nám to poměrně logické).
|
||||
|
||||
Zkratku #abbr("ABC", "Abeceda") vytvoříte (definujete) pomocí:
|
||||
|
||||
```typst
|
||||
#abbr("ABC", "Abeceda")
|
||||
```
|
||||
|
||||
Potom zkratku #abbr("ABC") už můžete použít přímo (bez opakované definice):
|
||||
|
||||
```typst
|
||||
#abbr("ABC")
|
||||
```
|
||||
|
||||
Šablona zajistí následující věci:
|
||||
- Zkratka se zobrazí v seznamu zkratek
|
||||
- Při prvním použití zkratky vás šablona donutí zkratku definovat
|
||||
- Definice zkratky bude použita právě jednou (poprvé)
|
||||
|
||||
Při prvním použití zkratky (při definici) bude zkratka v textu vypadat takto:
|
||||
#abbr("ZK", "Zkratka").
|
||||
Při dalších použití bude vypadat takto: #abbr("ZK").
|
||||
|
||||
#highlight[
|
||||
Tedy zkratku _nepřidáváte_ přímo do seznamu zkratek, ale elegantně jí používáte přímo v textu.
|
||||
]
|
||||
|
||||
== Přílohy
|
||||
|
||||
Na konec souboru (nebo klidně doprostřed či na začátek, hlavní je, že pouze jednou) je také možné dát strukturu generující přílohy. Momentálně jsou podporované čtyři typy příloh: odkaz, obsah, PDF soubor vložený na konec dokumentu a odkaz na externí soubor (například přiložený do systému s {{tou}}).
|
||||
Jako demonstrace by měla postačit praktická ukázka, která ve zdrojovém kódu následuje hned za tímto odstavcem, a která generuje přílohy tohoto 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.]),
|
||||
)
|
||||
|
||||
314
theses/content_en.typ
Normal file
314
theses/content_en.typ
Normal file
@@ -0,0 +1,314 @@
|
||||
#import "../template/template.typ": *
|
||||
|
||||
#show: tultemplate2
|
||||
|
||||
= A quick few words about this template
|
||||
|
||||
This template should serve as an example {{what}} written with the help of the *Typst* programming
|
||||
language and the *tultemplate2* template. It can be used as a starting point for your own report, you just
|
||||
have to learn a few of its useful functions, e.g. how to insert images, tables, citacions or links.
|
||||
|
||||
In contrast with the _documentation.typ_ file, which is available for download on the project's page,
|
||||
this document only contains the most necessary knowledge to complete most reports. If you find this
|
||||
documentt lacking in features, you can look at the aforementioned docs or contact one of the authors,
|
||||
who will try to help you. Just for the sake of completeness, here is a few words about the Typst programming
|
||||
language and about Typst, as well as about the motivation behind the creation of this template:
|
||||
|
||||
Typst is a professional typesetting language similar to markdown, LaTeX/TeX, groff, etc.
|
||||
|
||||
Typst is the modern equivalent of older typesetting tools, which often lack a lot of important features,
|
||||
such that make it next to impossible to work without today. The user must often import an incountable number of packages,
|
||||
which only provide only the most basic of functionalities --- for example proper UTF-8 character support,
|
||||
formatting of elements based on the set locale, etc.
|
||||
|
||||
= Getting Started with the Template
|
||||
|
||||
You have probably downloaded this template from the generator on the website www.tulsablona.cz and inserted
|
||||
it into the Typst online editor. Therefore, besides the source code, you can also see the resulting PDF file.
|
||||
As you probably know, the main difference between traditional word processors like Microsoft Word or LibreOffice
|
||||
Writer and typesetting programs like LaTeX or Typst is the way in which the appearance and content of the document
|
||||
are edited.
|
||||
|
||||
While Word users are used to changing the document directly using buttons and keyboard shortcuts, Typst (and also LaTeX)
|
||||
use a so-called source file, which is nothing more than an ordinary text file, and can then, on request, compile this
|
||||
source file -- i.e., turn it into the final document, for example in PDF format.
|
||||
|
||||
That’s why here you will find a description of all the important functions not as a gallery of images showing which
|
||||
buttons to click, but rather as an example and guide to all the special text sequences that Typst supports and that
|
||||
the template interprets differently from the main content of the report.
|
||||
|
||||
== Paragraphs
|
||||
|
||||
Some of you might know this concept from using Markdown, where paragraphs, headings and for the sake of clarity all
|
||||
logically coherent blocks are separated by an empty line. You might have already spotted this while reading through
|
||||
this document. You can try for yourself what happens when
|
||||
you just end the line
|
||||
|
||||
or when you properly use an empty line,
|
||||
|
||||
|
||||
|
||||
|
||||
or maybe what happens if you use two or more empty rows. (spoiler: 1 or more empty lines share identical behavior,
|
||||
while newlining only is interpreted the same as using spaces or tabs)
|
||||
|
||||
Therefore, the user has freedom of choosing whether he uses long lines full of text,
|
||||
or
|
||||
if
|
||||
he
|
||||
prefers
|
||||
a
|
||||
cleaner
|
||||
formatting
|
||||
and manages the separation of content to lines, because it all gets concatenated into a nice consice paragraph.
|
||||
The user has to manually watch out for the length of the paragraphs, so that they are neither too short or too long.
|
||||
|
||||
In the context of paragraphs, it should be mentioned that Typst also manages the alignment of text and words into blocks
|
||||
and the division of words between lines when they don't fit.
|
||||
This behavior complies with the English grammar and typography rules fully, so you don't have to think about that at all.
|
||||
|
||||
== Clickable content
|
||||
|
||||
When using the official Typst online editor, you can simply click on any text in the right side (the preview PDF),
|
||||
and your cursor will jump directly to that text in the source file.
|
||||
A small but very practical feature.
|
||||
|
||||
== Headings
|
||||
|
||||
The first important feature, apart from writing the text itself (which requires no special syntax), is the usage of headings.
|
||||
Just like in other programs, Typst also supports multi-level headings. For a first-level heading, an equals sign followed
|
||||
by a space is used at the beginning of a line, meaning that in a Typst source file it is written like this:
|
||||
|
||||
```typst
|
||||
= My first level heading
|
||||
```
|
||||
|
||||
For a second-level heading, we then use two equals signs; for a third-level heading, three equals signs…
|
||||
There are enough subheading levels that you’ll probably never run out. However, the TUL guidelines for writing reports
|
||||
forbid usage of level four heading or larger, so you can (and should) only use headings from level 1 to 3.
|
||||
If you try to use fourth-level or larger heading, the template will warn you not to do that and will refuse to compile
|
||||
until you fix this. More on this behavior later.
|
||||
|
||||
```typst
|
||||
= Heading
|
||||
== Subheading
|
||||
=== Subsubheading
|
||||
|
||||
And then your content
|
||||
```
|
||||
|
||||
== Chapter Numbering
|
||||
|
||||
You’ve probably noticed that each heading begins with the number of its respective chapter. Typst handles this numbering
|
||||
automatically, and it’s also reflected in the *Table of Contents* at the start of the document, so you don’t have to
|
||||
worry about it yourself.
|
||||
|
||||
== Template compile-time checks
|
||||
|
||||
This template is created in such a way that when you try to compile it with incorrect syntax or an imoportant
|
||||
part of the header missing, it won't let you. Always see the error messages the template provides,
|
||||
as they will simply guide you to fix your mistakes. You can try this by deleting something from the header,
|
||||
or by using e.g. a function that ins't defined anywhere.
|
||||
|
||||
= Using Functions
|
||||
|
||||
Most Typst features are used through what’s called *function calls*. This is quite similar to the previous examples,
|
||||
except that instead of wrapping text with a single symbol or a simple marker, we wrap it with the name of the function.
|
||||
The syntax looks like this:
|
||||
|
||||
```typst
|
||||
#Function_name[text itself or other parameters]
|
||||
```
|
||||
|
||||
When you type the hash symbol in the editor, it will automatically start suggesting all available functions and their descriptions.
|
||||
Let’s move on to some practical examples.
|
||||
|
||||
== Text Highlighting
|
||||
|
||||
The syntax for basic highlighting is very similar to Markdown. You just need to use the following symbols:
|
||||
|
||||
```typst
|
||||
*bold*
|
||||
_italic_
|
||||
```
|
||||
|
||||
More styling options can be applied through functions, for example:
|
||||
|
||||
```typst
|
||||
#strike[struck through]
|
||||
#highlight[highlighted]
|
||||
#underline[underlined] // underline SHOULD NOT be used
|
||||
```
|
||||
|
||||
For completeness and demonstration, here in the text we have *bold text*, _italic text_, #strike[struck-through text],
|
||||
and #highlight[text highlighted with your faculty’s color], as well as #underline[underlined text]
|
||||
(although typographers generally advise against using underlining).
|
||||
|
||||
== Links<links>
|
||||
|
||||
You can create links to URLs/URIs, emails, phone numbers, and more.
|
||||
A URL (URI) link can be written directly, without calling any function --- just type it in:
|
||||
|
||||
https://git.zumepro.cz/tul/tultemplate2
|
||||
|
||||
```typst
|
||||
https://git.zumepro.cz/tul/tultemplate2
|
||||
```
|
||||
|
||||
Internally, this automatically calls the `link` function.
|
||||
|
||||
If we want to link to less common things (like email addresses), we can call the `link` function explicitly:
|
||||
|
||||
```typst
|
||||
#link("mailto:ondrej@mekina.cz")
|
||||
```
|
||||
|
||||
You can find other prefixes (URI schemes) on Wikipedia:
|
||||
https://en.wikipedia.org/wiki/List_of_URI_schemes.
|
||||
|
||||
== Images
|
||||
|
||||
Images can be inserted either by themselves or with a caption.
|
||||
|
||||
An image is inserted using the `image` function:
|
||||
|
||||
To add a caption and also include the image in the index (so you can reference it later), use the `figure` function:
|
||||
|
||||
#block([
|
||||
```typst
|
||||
#figure(
|
||||
image("myimage.jpg"),
|
||||
caption: [
|
||||
*A beautiful* picture that looks like a picture.
|
||||
]
|
||||
)
|
||||
```
|
||||
], breakable: false)
|
||||
|
||||
Here’s a practical example of inserting an image with a caption:
|
||||
|
||||
#figure(image("../template/assets/tul_logo.svg", width: 25%), caption: [
|
||||
Logo of *TUL*
|
||||
])
|
||||
|
||||
The first parameter of the function is the displayed content --- in our case, the mentioned `image`. You can then specify various parameters for it; in the example, we define the image width as a percentage.
|
||||
The last parameter is `caption`, which lets us set the figure’s (or image’s) caption text.
|
||||
|
||||
If the document type requires it, images will automatically appear in a list at the beginning of the document. Typst handles this automatically for you --- all you need to do is add images wherever appropriate, and they’ll show up correctly in the *List of Figures*, complete with references and page numbers.
|
||||
Images are also numbered automatically according to the predefined style, similar to chapters.
|
||||
|
||||
== Tables
|
||||
|
||||
Tables can be created like this:
|
||||
|
||||
```typst
|
||||
#figure(table(
|
||||
columns: 3,
|
||||
table.header([], [*Column 1*], [*Column 2*]),
|
||||
[*Row 1*], [a], [b],
|
||||
[*Row 2*], [c], [d],
|
||||
), caption: "My beautiful table")
|
||||
```
|
||||
|
||||
The `columns` parameter specifies the number of columns in the table. Then comes any number of table cells --- for clarity, the rows are separated in the example. Finally, there’s again a `caption` parameter, used to provide a caption for the table.
|
||||
|
||||
#highlight[It’s a good idea to wrap the table header (the first row) in the `header` function (as shown above)] --- this ensures Typst includes extra metadata in the generated PDF (for example, for people with visual impairments).
|
||||
|
||||
#figure(table(
|
||||
columns: 3,
|
||||
table.header([], [*Column 1*], [*Column 2*]),
|
||||
[*Row 1*], [a], [b],
|
||||
[*Row 2*], [c], [d],
|
||||
), caption: "My beautiful table")
|
||||
|
||||
Tables also appear at the beginning of the document in a list (if required by the document type).
|
||||
As you’ve probably noticed by now, Typst’s template takes care of this automatically.
|
||||
|
||||
== Citations
|
||||
|
||||
The template supports citation management using a standard BibTeX file @bibtex, just like LaTeX. Almost every website or program that supports citations can generate BibTeX-formatted entries.
|
||||
You simply add the code for such a citation, in the proper format, to the file _citations.bib_. Once added, you can reference it using `@citation_name` or `#cite(<citation_name>)`.
|
||||
For example, I can reference the Typst citation as #cite(<typst>).
|
||||
|
||||
The format of the _citations.bib_ file is exactly the same as in LaTeX. You can even copy entries directly from sites like [citace.com](https://www.citace.com) in BibTeX format --- Typst understands that format, too.
|
||||
If you open a `.bib` file, you’ll see that it’s simply a plain text file with a specific structure.
|
||||
The provided sample file already contains several citations --- for instance, the one named `typst`, which was already used above.
|
||||
|
||||
You can change the file from which citations are loaded using a template argument (i.e., in the structure at the beginning of your Typst document):
|
||||
|
||||
```typst
|
||||
#show: tultemplate2.with(
|
||||
...
|
||||
citations: "anotherfile.bib",
|
||||
...
|
||||
)
|
||||
```
|
||||
|
||||
== Internal Links and Anchors<example_anchor>
|
||||
|
||||
Let’s continue from the *Links* section (@links).
|
||||
|
||||
You can also create internal links --- for instance, to chapters, pages, or labeled images (those wrapped with the `figure` function).
|
||||
|
||||
```typst
|
||||
= A Good Chapter<good_chapter>
|
||||
|
||||
Let’s take a look at A Good Chapter (@good_chapter).
|
||||
```
|
||||
|
||||
Here’s what an anchor looks like:
|
||||
|
||||
```typst
|
||||
<anchor_name>
|
||||
```
|
||||
|
||||
You place the anchor anywhere in the file, and you can reference it the same way you reference citations:
|
||||
|
||||
```typst
|
||||
@anchor_name
|
||||
```
|
||||
|
||||
For example, we can take a look at this illustrative reference (@example_anchor).
|
||||
|
||||
== Abbreviations
|
||||
|
||||
The LaTeX TUL template includes a list of abbreviations at the beginning of the document. Therefore, we’ve included one here as well.
|
||||
This list is configured to appear only if there is *at least one* abbreviation defined --- which seemed quite logical.
|
||||
|
||||
You can create (define) an abbreviation with #abbr("ABC", "Alphabet") like this:
|
||||
|
||||
```typst
|
||||
#abbr("ABC", "Alphabet")
|
||||
```
|
||||
|
||||
After that, you can use the abbreviation #abbr("ABC") directly without redefining it:
|
||||
|
||||
```typst
|
||||
#abbr("ABC")
|
||||
```
|
||||
|
||||
The template automatically ensures the following:
|
||||
- The abbreviation appears in the list of abbreviations
|
||||
- When you use an abbreviation for the first time, the template *requires* you to define it
|
||||
- The definition is used only once (the first time it appears)
|
||||
|
||||
When used for the first time (definition), the abbreviation will look like this:
|
||||
#abbr("ABR", "Abbreviation").
|
||||
In subsequent uses, it will appear as: #abbr("ABR").
|
||||
|
||||
#highlight[
|
||||
In other words, you do _not_ add abbreviations directly to the abbreviation list.
|
||||
You simply use them elegantly within the text itself.
|
||||
]
|
||||
|
||||
== Attachments
|
||||
|
||||
At the end of the file (or anywhere else, as long as it’s included only once), you can add a structure that generates attachments.
|
||||
Currently, two types of attachments are supported --- links and content.
|
||||
As a demonstration, here’s a practical example (included right after this paragraph in the source code), which generates the attachments for this document:
|
||||
|
||||
#attachments(
|
||||
attach_link("Source code of this template", "https://git.zumepro.cz/tul/tultemplate2"),
|
||||
attach_content("Test content generated by Typst", [Here you can write _styled_ content.]),
|
||||
)
|
||||
|
||||
292
theses/dp_cs.typ
292
theses/dp_cs.typ
@@ -52,293 +52,5 @@
|
||||
citations: "citations.bib",
|
||||
)
|
||||
|
||||
= Co najdete v této šabloně
|
||||
|
||||
Tato šablona má sloužit jako ukázková diplomová práce napsaná pomocí jazyka *Typst* a šablony
|
||||
*tultemplate2*. Může posloužit jako jednoduchý základ i pro vaši práci, stačí se naučit používat
|
||||
pár užitečných funkcí, jako např. vkládání obrázků, tabulek, citací nebo odkazů.
|
||||
|
||||
Na rozdíl od souboru _documentation.typ_, který je dostupný ke stažení na stránkách projektu, obsahuje
|
||||
tento dokument jenom to nejpotřebnější ze znalostí, co postačí k úspěšnému napsání práce. Pokud vám budou nějaké funkce chybět, můžete se podívat do zmíněného souboru, anebo kontaktovat některého z autorů, kteří se vám pokusí pomoct. Jen pro úplnost je zde ve zkratce něco málo o jazyce typst a motivaci k tvorbě této šablony:
|
||||
|
||||
Typst je profesionální sázecí nástroj podobný markdownu, LaTeXu/TeXu, groffu, atd.
|
||||
|
||||
Typst je moderní obdobou starších nástrojů, které postrádají spoustu důležitých funkcí, bez kterých
|
||||
se v dnešní době prakticky nedá fungovat. Uživatel často musí importovat nepřeberné množství
|
||||
balíčků, které poskytují (podle mě) naprosto základní funkcionalitu - jako například správná podpora
|
||||
UTF-8 znaků, formátování prvků na základě jazykového lokálu, apod.
|
||||
|
||||
= Začínáme se šablonou
|
||||
|
||||
Tuto šablonu jste si pravděpodobně stáhli z generátoru na webu www.tulsablona.cz a vložili ji do Typst
|
||||
online editoru. Tím pádem vidíte kromě zdrojového kódu také výsledný PDF soubor. Jak už asi víte, hlavní
|
||||
rozdíl mezi tradičními textovými procesory jako Microsoft Word nebo LibreOffice Writer a mezi sázecími
|
||||
programy jako LaTeX nebo Typst je právě způsob, kterým se upravuje vzhled a obsah dokumentu.
|
||||
|
||||
Zatímco ve Wordu jsou uživatelé zvyklí, že pomocí tlačítek a klávesových zkratek mění dokument napřímo,
|
||||
Typst (a i LaTeX) používají tzv. zdrojový soubor, který není ničím jiným než obyčejným textovým souborem,
|
||||
a následně na vyžádání umí tento zdrojový soubor zkompilovat tj. proměnit na výsledný dokument, např. ve formátu PDF.
|
||||
|
||||
Proto zde najdete popis všech důležitých funkcí nikoliv jako galerii obrázků toho, na která tlačítka se má
|
||||
klikat, nýbrž jako ukázka a návod všech speciálních sekvencí textu, které Typst podporuje a které šablona vyhodnocuje jinak než obsah zprávy.
|
||||
|
||||
== Odstavce
|
||||
|
||||
Jak jsou někteří z vás možná zvyklí z Markdownu, odstavce, nadpisy a vlastně pro přehlednost všechny
|
||||
logicky oddělené bloky se oddělují prázným řádkem. Toho jste si jistě mohli při prohlížení tohoto souboru
|
||||
všimnout. Můžete si vyzkoušet, co se stane, když
|
||||
použijete jenom ukončení řádku enterem,
|
||||
|
||||
nebo když použijete zmíněný prázdný řádek,
|
||||
|
||||
|
||||
|
||||
anebo co se stane při použití dvou a více prázdných řádků. (spoiler: 1 a více prázdných řádků mají identické
|
||||
chování, pouze ukončení řádku je interpretováno stejně jako např. mezerník nebo tabulátor)
|
||||
|
||||
Uživatel má tím pádem svobodu v tom, jestli ve zdrojovém souboru používá dlouhé řádky plné textu,
|
||||
nebo
|
||||
má
|
||||
raději
|
||||
přehlednější
|
||||
formátování
|
||||
a sám si obsah dělí na řádky, protože ve výsledném PDF souboru se stejně spojí do jednoho celistvého odstavce.
|
||||
Musí akorát ručně dbát na to, aby odstavce nebyly příliš krátké, ani příliš dlouhé.
|
||||
|
||||
S souvislosti s odstavci bych ještě zmínil, že Typst se za vás stará také o zarovnávání písma a slov do bloků
|
||||
a dělení slov mezi řádky, když už se na něj nevejdou. Chováním odpovídá pravidlům českého pravopisu a typografie, takže se o to nemusíte vůbec starat.
|
||||
|
||||
== Klikatelný obsah
|
||||
|
||||
Pokud používáte oficiální Typst online editor, můžete jednoduše klepnout na jakýkoliv text v pravé části (náhledové PDF), který se dá měnit,
|
||||
a editor podle toho automaticky přesune váš kurzor na správné místo.
|
||||
Je to sice drobná, ale zato velmi užitečná funkce.
|
||||
|
||||
== Nadpisy
|
||||
|
||||
První důležitá funkce kromě psaní samotného textu, k čemuž není zapotřebí žádná speciální syntax, jsou nadpisy.
|
||||
Stejně jako v jiných programech, i Typst podporuje nadpisy více úrovní. Pro nadpis první úrovně se používá znaménko
|
||||
rovná se a mezera na začátku řádku, čili ve zdrojovém souboru Typstu je používán takto:
|
||||
|
||||
```typst
|
||||
= Můj nadpis první úrovně
|
||||
```
|
||||
|
||||
Pro nadpis druhé úrovně pak použijeme dvě rovná se, pro nadpis třetí úrovně tři rovná se.
|
||||
Šablona *tultemplate2* Vám ovšem bohužel nedovolí nadpis čtvrté a další úrovně, protože by takový
|
||||
nadpis porušoval směrnice TUL o formátování dokumentů. Ale nemusíte se bát. Pokud takový nadpis
|
||||
uděláte -- šablona vyhodí chybu, aby vás na to upozornila.
|
||||
|
||||
```typst
|
||||
= Nadpis
|
||||
== Podnadpis
|
||||
=== Podpodnadpis
|
||||
|
||||
A pak obsah
|
||||
```
|
||||
|
||||
== Číslování kapitol
|
||||
|
||||
Asi jste si všimli, že každý nadpis začíná číslem dané kapitoly. Toto číslování provádí Typst automaticky, promítne se následně i v sekci Obsah na začátku souboru, nemusíte se tak opět o nic starat.
|
||||
|
||||
= Kontrola šablony při kompilaci
|
||||
|
||||
Tato šablona je vytvořena tak, že když se ji pokusíte zkompilovat s nesprávnou syntaxí nebo s nějakou
|
||||
chybějící důležitou částí hlavičky,
|
||||
nenechá vás to provést. Vždy se podívejte na chybové hlášky, které šablona vypisuje, protože vás snadno navedou k opravě všech chyb.
|
||||
Můžete to vyzkoušet tak, že smažete něco z hlavičky nebo že např. použijete funkci, která není nikde definovaná.
|
||||
|
||||
= Používání funkcí
|
||||
|
||||
Používání většiny funkcionalit Typstu je prováděno pomocí tzv. volání funkce. Je to velmi podobné předchozím ukázkám,
|
||||
akorát místo toho, aby se text obalil pouze jedním symbolem či podobnou jednoduchou značkou, obalíme text jménem dané funkce. Syntaxe vypadá nějak takto:
|
||||
```typst
|
||||
#Název_funkce[samotný text nebo jiné parametry]
|
||||
```
|
||||
Pokud v editoru napíšete symbol hashtagu, začne vám automaticky našeptávat všechny možné funkce a jejich popisy. Přejdeme rovnou k dalším praktickým příkladům.
|
||||
|
||||
== Zvýrazňování textu
|
||||
|
||||
Syntaxe základního zvýraznění je velmi podobná například Markdownu. Stačí použít následující symboly:
|
||||
|
||||
```typst
|
||||
*tučně*
|
||||
_kurzívou_
|
||||
```
|
||||
|
||||
Další stylování lze dělat právě přes funkce, viz třeba:
|
||||
|
||||
```typst
|
||||
#strike[přeškrtnuto]
|
||||
#highlight[zvýrazněno]
|
||||
#underline[podtrženo] // podtržení by se NEMĚLO používat
|
||||
```
|
||||
|
||||
Pro úplnost a ukázku je zde přímo v textu *tučný text*, _text kurzívou_, #strike[přeškrtnutý text] a #highlight[text zvýrazněný podle barvy příslušící vaší fakultě], #underline[podtržený text] (ačkoli typografové doporučují podtržení nepoužívat).
|
||||
|
||||
== Odkazy<links>
|
||||
|
||||
Odkazy je možné dělat na URL/URI zdroje, e-maily, telefony, atd...
|
||||
Odkázat URL (URI) je možné bez zavolání funkce, odkaz stačí prostě a jednodušše napsat:
|
||||
https://git.zumepro.cz/tul/tultemplate2
|
||||
|
||||
```typst
|
||||
https://git.zumepro.cz/tul/tultemplate2
|
||||
```
|
||||
|
||||
Tohle interně volá funkci `link`.
|
||||
|
||||
Pokud odkazujeme na méně časté věci (jako e-maily), můžeme použít funkci `link` přímo.
|
||||
```typst
|
||||
#link("mailto:ondrej@mekina.cz")
|
||||
```
|
||||
|
||||
Dalši předpony (URI schémata) můžete najít třeba na Wikipedii
|
||||
https://en.wikipedia.org/wiki/List_of_URI_schemes.
|
||||
|
||||
== Obrázky
|
||||
|
||||
Obrázky je možné vkládat samotné, nebo i s popiskem.
|
||||
Obrázek se vloží pomocí funkce `image`.
|
||||
|
||||
Přidání popisku a zároveň zalistování obrázku v indexu (aby se na ně třeba dalo odkazovat) lze
|
||||
udělat pomocí funkce `figure`.
|
||||
|
||||
#block([
|
||||
```typst
|
||||
#figure(
|
||||
image("mujobrazek.jpg"),
|
||||
caption: [
|
||||
*Krásný* obrázek, který vypadá jako obrázek.
|
||||
]
|
||||
)
|
||||
```
|
||||
], breakable: false)
|
||||
|
||||
Tady je praktická ukázka jednoduchého vložení obrázku s popiskem:
|
||||
|
||||
#figure(image("../template/assets/tul_logo.svg", width: 25%), caption: [
|
||||
Logo *TUL*
|
||||
])
|
||||
|
||||
První parametr funkce je zobrazovaný obsah, v našem případě zmíněný `image`. K němu můžeme psát různé parametry, v příkladu máme třeba nastavení šířky obrázku v procentech. Jako poslední je parametr `caption`, s jehož pomocí můžeme nastavit popisek obrázku/figury.
|
||||
|
||||
Obrázky se zobrazí na začátku dokumentu v seznamu (pokud to daný typ dokumentu vyžaduje). I toto za vás Typst dělá automaticky, vám tak stačí do textu přidávat obrázky, jak se to hodí, a všechny se poté korektně zobrazí v Seznamu obrázků s odkazem i správně uvedenou stránkou, na které se obrázek nachází. Obrázky jsou také automaticky číslovány podle předepsaného způsobu, podobně jako kapitoly.
|
||||
|
||||
== 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")
|
||||
```
|
||||
|
||||
Parametr `columns` udává počet sloupců tabulky. Poté následuje libovolný počet buněk tabulky, pro lepší přehlednost jsou v příkladu jednotlivé řádky oddělené. Nakonec je zde opět parametr `caption` sloužící k zadání popisku tabulky.
|
||||
|
||||
#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). Jak už jste asi pochopili, i toto provede šablona automaticky.
|
||||
|
||||
== Citace
|
||||
|
||||
Šablona podporuje správu citací pomocí standardního BibTeX @bibtex souboru, stejně jako
|
||||
například LaTeX. Generování citací v BibTeX zápisu umí téměř každá stránka nebo program, které mají pro citace podporu.
|
||||
Kód takovéto citace ve vhodném formátu stačí přidat do souboru _citations.bib_, poté je možné se
|
||||
na ně odkazovat pomocí `@jmeno_citace`, nebo `#cite(<jmeno_citace>)`. Můžu se tak třeba odkázat na
|
||||
citaci Typstu #cite(<typst>).
|
||||
|
||||
Formát souboru _citations.bib_ je naprosto stejný jako pro LaTeX. Tyto citace lze přímo vložit
|
||||
třeba z webu https://www.citace.com ve formátu BibTeX -- Typst tento formát také umí přečíst.
|
||||
Můžete se do souboru s příponou .bib podívat, zjistíte, že je to opravdu jen obyčejný textový soubor se specifickou strukturou.
|
||||
V přiloženém ukázkovém souboru už nějaké citace jsou - např. již použitá citace se jménem `typst`.
|
||||
|
||||
Soubor, ze kterého se načtou citace lze změnit pomocí argumentu šablony (tj. struktura na začátku souboru):
|
||||
|
||||
```typst
|
||||
#show: tultemplate2.with(
|
||||
...
|
||||
citations: "jinysoubor.bib",
|
||||
...
|
||||
)
|
||||
```
|
||||
|
||||
== Vnitřní odkazy a kotvy<ukazka_odkazu>
|
||||
|
||||
Trochu navážeme na Odkazy (@links).
|
||||
|
||||
Můžete dělat i vnitřní odkazy třeba na kapitoly, stránky nebo obrázky s popiskem (zabalené ve
|
||||
`figure`).
|
||||
|
||||
```typst
|
||||
= Dobrá kapitola<dobra_kapitola>
|
||||
|
||||
Podívejme se na Dobrou kapitolu (@dobra_kapitola).
|
||||
```
|
||||
|
||||
Takhle vypadá kotva:
|
||||
|
||||
```typst
|
||||
<nazev_kotvy>
|
||||
```
|
||||
|
||||
Kotvu dáte někam do souboru a můžete na ní odkazovat stejně jako na citace:
|
||||
|
||||
```typst
|
||||
@nazev_kotvy
|
||||
```
|
||||
Můžeme se podívat na názornou ukázku odkazu (@ukazka_odkazu).
|
||||
|
||||
== Zkratky
|
||||
|
||||
LaTeX TUL šablona má k začátku dokumentu seznam zkratek. Proto jsme ho přidali i do této šablony.
|
||||
Seznam zkratek je v této šabloně nastaven tak, aby se zobrazoval pouze pokud je v něm alespoň jedna
|
||||
zkratka (přišlo nám to poměrně logické).
|
||||
|
||||
Zkratku #abbr("ABC", "Abeceda") vytvoříte (definujete) pomocí:
|
||||
|
||||
```typst
|
||||
#abbr("ABC", "Abeceda")
|
||||
```
|
||||
|
||||
Potom zkratku #abbr("ABC") už můžete použít přímo (bez opakované definice):
|
||||
|
||||
```typst
|
||||
#abbr("ABC")
|
||||
```
|
||||
|
||||
Šablona zajistí následující věci:
|
||||
- Zkratka se zobrazí v seznamu zkratek
|
||||
- Při prvním použití zkratky vás šablona donutí zkratku definovat
|
||||
- Definice zkratky bude použita právě jednou (poprvé)
|
||||
|
||||
Při prvním použití zkratky (při definici) bude zkratka v textu vypadat takto:
|
||||
#abbr("ZK", "Zkratka").
|
||||
Při dalších použití bude vypadat takto: #abbr("ZK").
|
||||
|
||||
#highlight[
|
||||
Tedy zkratku _nepřidáváte_ přímo do seznamu zkratek, ale elegantně jí používáte přímo v textu.
|
||||
]
|
||||
|
||||
== Přílohy
|
||||
|
||||
Na konec souboru (nebo klidně doprostřed či na začátek, hlavní je, že pouze jednou) je také možné dát strukturu generující přílohy. Momentálně jsou podporované čtyři typy příloh: odkaz, obsah, PDF soubor vložený na konec dokumentu a odkaz na externí soubor (například přiložený do systému s diplomovou prací).
|
||||
Jako demonstrace by měla postačit praktická ukázka, která ve zdrojovém kódu následuje hned za tímto odstavcem, a která generuje přílohy tohoto 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.]),
|
||||
)
|
||||
Diplomová práce
|
||||
diplomovou prací
|
||||
|
||||
310
theses/dp_en.typ
310
theses/dp_en.typ
@@ -52,312 +52,4 @@
|
||||
citations: "citations.bib",
|
||||
)
|
||||
|
||||
= A quick few words about this template
|
||||
|
||||
This template should serve as an example Diploma thesis written with the help of the *Typst* programming
|
||||
language and the *tultemplate2* template. It can be used as a starting point for your own report, you just
|
||||
have to learn a few of its useful functions, e.g. how to insert images, tables, citacions or links.
|
||||
|
||||
In contrast with the _documentation.typ_ file, which is available for download on the project's page,
|
||||
this document only contains the most necessary knowledge to complete most reports. If you find this
|
||||
documentt lacking in features, you can look at the aforementioned docs or contact one of the authors,
|
||||
who will try to help you. Just for the sake of completeness, here is a few words about the Typst programming
|
||||
language and about Typst, as well as about the motivation behind the creation of this template:
|
||||
|
||||
Typst is a professional typesetting language similar to markdown, LaTeX/TeX, groff, etc.
|
||||
|
||||
Typst is the modern equivalent of older typesetting tools, which often lack a lot of important features,
|
||||
such that make it next to impossible to work without today. The user must often import an incountable number of packages,
|
||||
which only provide only the most basic of functionalities - for example proper UTF-8 character support,
|
||||
formatting of elements based on the set locale, etc.
|
||||
|
||||
= Getting Started with the Template
|
||||
|
||||
You have probably downloaded this template from the generator on the website www.tulsablona.cz and inserted
|
||||
it into the Typst online editor. Therefore, besides the source code, you can also see the resulting PDF file.
|
||||
As you probably know, the main difference between traditional word processors like Microsoft Word or LibreOffice
|
||||
Writer and typesetting programs like LaTeX or Typst is the way in which the appearance and content of the document
|
||||
are edited.
|
||||
|
||||
While Word users are used to changing the document directly using buttons and keyboard shortcuts, Typst (and also LaTeX)
|
||||
use a so-called source file, which is nothing more than an ordinary text file, and can then, on request, compile this
|
||||
source file -- i.e., turn it into the final document, for example in PDF format.
|
||||
|
||||
That’s why here you will find a description of all the important functions not as a gallery of images showing which
|
||||
buttons to click, but rather as an example and guide to all the special text sequences that Typst supports and that
|
||||
the template interprets differently from the main content of the report.
|
||||
|
||||
== Paragraphs
|
||||
|
||||
Some of you might know this concept from using Markdown, where paragraphs, headings and for the sake of clarity all
|
||||
logically coherent blocks are separated by an empty line. You might have already spotted this while reading through
|
||||
this document. You can try for yourself what happens when
|
||||
you just end the line
|
||||
|
||||
or when you properly use an empty line,
|
||||
|
||||
|
||||
|
||||
|
||||
or maybe what happens if you use two or more empty rows. (spoiler: 1 or more empty lines share identical behavior,
|
||||
while newlining only is interpreted the same as using spaces or tabs)
|
||||
|
||||
Therefore, the user has freedom of choosing whether he uses long lines full of text,
|
||||
or
|
||||
if
|
||||
he
|
||||
prefers
|
||||
a
|
||||
cleaner
|
||||
formatting
|
||||
and manages the separation of content to lines, because it all gets concatenated into a nice consice paragraph.
|
||||
The user has to manually watch out for the length of the paragraphs, so that they are neither too short or too long.
|
||||
|
||||
In the context of paragraphs, it should be mentioned that Typst also manages the alignment of text and words into blocks
|
||||
and the division of words between lines when they don't fit.
|
||||
This behavior complies with the English grammar and typography rules fully, so you don't have to think about that at all.
|
||||
|
||||
== Clickable content
|
||||
|
||||
When using the official Typst online editor, you can simply click on any text in the right side (the preview PDF),
|
||||
and your cursor will jump directly to that text in the source file.
|
||||
A small but very practical feature.
|
||||
|
||||
== Headings
|
||||
|
||||
The first important feature, apart from writing the text itself (which requires no special syntax), is the usage of headings.
|
||||
Just like in other programs, Typst also supports multi-level headings. For a first-level heading, an equals sign followed
|
||||
by a space is used at the beginning of a line, meaning that in a Typst source file it is written like this:
|
||||
|
||||
```typst
|
||||
= My first level heading
|
||||
```
|
||||
|
||||
For a second-level heading, we then use two equals signs; for a third-level heading, three equals signs...
|
||||
There are enough subheading levels that you’ll probably never run out. However, the TUL guidelines for writing reports
|
||||
forbid usage of level four heading or larger, so you can (and should) only use headings from level 1 to 3.
|
||||
If you try to use fourth-level or larger heading, the template will warn you not to do that and will refuse to compile
|
||||
until you fix this. More on this behavior later.
|
||||
|
||||
```typst
|
||||
= Heading
|
||||
== Subheading
|
||||
=== Subsubheading
|
||||
|
||||
And then your content
|
||||
```
|
||||
|
||||
== Chapter Numbering
|
||||
|
||||
You’ve probably noticed that each heading begins with the number of its respective chapter. Typst handles this numbering
|
||||
automatically, and it’s also reflected in the *Table of Contents* at the start of the document, so you don’t have to
|
||||
worry about it yourself.
|
||||
|
||||
== Template compile-time checks
|
||||
|
||||
This template is created in such a way that when you try to compile it with incorrect syntax or an imoportant
|
||||
part of the header missing, it won't let you. Always see the error messages the template provides,
|
||||
as they will simply guide you to fix your mistakes. You can try this by deleting something from the header,
|
||||
or by using e.g. a function that ins't defined anywhere.
|
||||
|
||||
= Using Functions
|
||||
|
||||
Most Typst features are used through what’s called *function calls*. This is quite similar to the previous examples,
|
||||
except that instead of wrapping text with a single symbol or a simple marker, we wrap it with the name of the function.
|
||||
The syntax looks like this:
|
||||
|
||||
```typst
|
||||
#Function_name[text itself or other parameters]
|
||||
```
|
||||
|
||||
When you type the hash symbol in the editor, it will automatically start suggesting all available functions and their descriptions.
|
||||
Let’s move on to some practical examples.
|
||||
|
||||
== Text Highlighting
|
||||
|
||||
The syntax for basic highlighting is very similar to Markdown. You just need to use the following symbols:
|
||||
|
||||
```typst
|
||||
*bold*
|
||||
_italic_
|
||||
```
|
||||
|
||||
More styling options can be applied through functions, for example:
|
||||
|
||||
```typst
|
||||
#strike[struck through]
|
||||
#highlight[highlighted]
|
||||
#underline[underlined] // underline SHOULD NOT be used
|
||||
```
|
||||
|
||||
For completeness and demonstration, here in the text we have *bold text*, _italic text_, #strike[struck-through text],
|
||||
and #highlight[text highlighted with your faculty’s color], as well as #underline[underlined text]
|
||||
(although typographers generally advise against using underlining).
|
||||
|
||||
== Links<links>
|
||||
|
||||
You can create links to URLs/URIs, emails, phone numbers, and more.
|
||||
A URL (URI) link can be written directly, without calling any function --- just type it in:
|
||||
|
||||
https://git.zumepro.cz/tul/tultemplate2
|
||||
|
||||
```typst
|
||||
https://git.zumepro.cz/tul/tultemplate2
|
||||
```
|
||||
|
||||
Internally, this automatically calls the `link` function.
|
||||
|
||||
If we want to link to less common things (like email addresses), we can call the `link` function explicitly:
|
||||
|
||||
```typst
|
||||
#link("mailto:ondrej@mekina.cz")
|
||||
```
|
||||
|
||||
You can find other prefixes (URI schemes) on Wikipedia:
|
||||
https://en.wikipedia.org/wiki/List_of_URI_schemes.
|
||||
|
||||
== Images
|
||||
|
||||
Images can be inserted either by themselves or with a caption.
|
||||
|
||||
An image is inserted using the `image` function:
|
||||
|
||||
To add a caption and also include the image in the index (so you can reference it later), use the `figure` function:
|
||||
|
||||
#block([
|
||||
```typst
|
||||
#figure(
|
||||
image("myimage.jpg"),
|
||||
caption: [
|
||||
*A beautiful* picture that looks like a picture.
|
||||
]
|
||||
)
|
||||
```
|
||||
], breakable: false)
|
||||
|
||||
Here’s a practical example of inserting an image with a caption:
|
||||
|
||||
#figure(image("../template/assets/tul_logo.svg", width: 25%), caption: [
|
||||
Logo of *TUL*
|
||||
])
|
||||
|
||||
The first parameter of the function is the displayed content --- in our case, the mentioned `image`. You can then specify various parameters for it; in the example, we define the image width as a percentage.
|
||||
The last parameter is `caption`, which lets us set the figure’s (or image’s) caption text.
|
||||
|
||||
If the document type requires it, images will automatically appear in a list at the beginning of the document. Typst handles this automatically for you --- all you need to do is add images wherever appropriate, and they’ll show up correctly in the *List of Figures*, complete with references and page numbers.
|
||||
Images are also numbered automatically according to the predefined style, similar to chapters.
|
||||
|
||||
== Tables
|
||||
|
||||
Tables can be created like this:
|
||||
|
||||
```typst
|
||||
#figure(table(
|
||||
columns: 3,
|
||||
table.header([], [*Column 1*], [*Column 2*]),
|
||||
[*Row 1*], [a], [b],
|
||||
[*Row 2*], [c], [d],
|
||||
), caption: "My beautiful table")
|
||||
```
|
||||
|
||||
The `columns` parameter specifies the number of columns in the table. Then comes any number of table cells --- for clarity, the rows are separated in the example. Finally, there’s again a `caption` parameter, used to provide a caption for the table.
|
||||
|
||||
#highlight[It’s a good idea to wrap the table header (the first row) in the `header` function (as shown above)] --- this ensures Typst includes extra metadata in the generated PDF (for example, for people with visual impairments).
|
||||
|
||||
#figure(table(
|
||||
columns: 3,
|
||||
table.header([], [*Column 1*], [*Column 2*]),
|
||||
[*Row 1*], [a], [b],
|
||||
[*Row 2*], [c], [d],
|
||||
), caption: "My beautiful table")
|
||||
|
||||
Tables also appear at the beginning of the document in a list (if required by the document type).
|
||||
As you’ve probably noticed by now, Typst’s template takes care of this automatically.
|
||||
|
||||
== Citations
|
||||
|
||||
The template supports citation management using a standard BibTeX file @bibtex, just like LaTeX. Almost every website or program that supports citations can generate BibTeX-formatted entries.
|
||||
You simply add the code for such a citation, in the proper format, to the file _citations.bib_. Once added, you can reference it using `@citation_name` or `#cite(<citation_name>)`.
|
||||
For example, I can reference the Typst citation as #cite(<typst>).
|
||||
|
||||
The format of the _citations.bib_ file is exactly the same as in LaTeX. You can even copy entries directly from sites like [citace.com](https://www.citace.com) in BibTeX format --- Typst understands that format, too.
|
||||
If you open a `.bib` file, you’ll see that it’s simply a plain text file with a specific structure.
|
||||
The provided sample file already contains several citations --- for instance, the one named `typst`, which was already used above.
|
||||
|
||||
You can change the file from which citations are loaded using a template argument (i.e., in the structure at the beginning of your Typst document):
|
||||
|
||||
```typst
|
||||
#show: tultemplate2.with(
|
||||
...
|
||||
citations: "anotherfile.bib",
|
||||
...
|
||||
)
|
||||
```
|
||||
|
||||
== Internal Links and Anchors<example_anchor>
|
||||
|
||||
Let’s continue from the *Links* section (@links).
|
||||
|
||||
You can also create internal links --- for instance, to chapters, pages, or labeled images (those wrapped with the `figure` function).
|
||||
|
||||
```typst
|
||||
= A Good Chapter<good_chapter>
|
||||
|
||||
Let’s take a look at A Good Chapter (@good_chapter).
|
||||
```
|
||||
|
||||
Here’s what an anchor looks like:
|
||||
|
||||
```typst
|
||||
<anchor_name>
|
||||
```
|
||||
|
||||
You place the anchor anywhere in the file, and you can reference it the same way you reference citations:
|
||||
|
||||
```typst
|
||||
@anchor_name
|
||||
```
|
||||
|
||||
For example, we can take a look at this illustrative reference (@example_anchor).
|
||||
|
||||
== Abbreviations
|
||||
|
||||
The LaTeX TUL template includes a list of abbreviations at the beginning of the document. Therefore, we’ve included one here as well.
|
||||
This list is configured to appear only if there is *at least one* abbreviation defined --- which seemed quite logical.
|
||||
|
||||
You can create (define) an abbreviation with #abbr("ABC", "Alphabet") like this:
|
||||
|
||||
```typst
|
||||
#abbr("ABC", "Alphabet")
|
||||
```
|
||||
|
||||
After that, you can use the abbreviation #abbr("ABC") directly without redefining it:
|
||||
|
||||
```typst
|
||||
#abbr("ABC")
|
||||
```
|
||||
|
||||
The template automatically ensures the following:
|
||||
- The abbreviation appears in the list of abbreviations
|
||||
- When you use an abbreviation for the first time, the template *requires* you to define it
|
||||
- The definition is used only once (the first time it appears)
|
||||
|
||||
When used for the first time (definition), the abbreviation will look like this:
|
||||
#abbr("ABR", "Abbreviation").
|
||||
In subsequent uses, it will appear as: #abbr("ABR").
|
||||
|
||||
#highlight[
|
||||
In other words, you do _not_ add abbreviations directly to the abbreviation list.
|
||||
You simply use them elegantly within the text itself.
|
||||
]
|
||||
|
||||
== Attachments
|
||||
|
||||
At the end of the file (or anywhere else, as long as it’s included only once), you can add a structure that generates attachments.
|
||||
Currently, two types of attachments are supported --- links and content.
|
||||
As a demonstration, here’s a practical example (included right after this paragraph in the source code), which generates the attachments for this document:
|
||||
|
||||
#attachments(
|
||||
attach_link("Source code of this template", "https://git.zumepro.cz/tul/tultemplate2"),
|
||||
attach_content("Test content generated by Typst", [Here you can write _styled_ content.]),
|
||||
)
|
||||
Diploma thesis
|
||||
|
||||
@@ -52,293 +52,5 @@
|
||||
citations: "citations.bib",
|
||||
)
|
||||
|
||||
= Co najdete v této šabloně
|
||||
|
||||
Tato šablona má sloužit jako ukázková zpráva k ročníkovému projektu napsaná pomocí jazyka *Typst* a šablony
|
||||
*tultemplate2*. Může posloužit jako jednoduchý základ i pro vaši práci, stačí se naučit používat
|
||||
pár užitečných funkcí, jako např. vkládání obrázků, tabulek, citací nebo odkazů.
|
||||
|
||||
Na rozdíl od souboru _documentation.typ_, který je dostupný ke stažení na stránkách projektu, obsahuje
|
||||
tento dokument jenom to nejpotřebnější ze znalostí, co postačí k úspěšnému napsání práce. Pokud vám budou nějaké funkce chybět, můžete se podívat do zmíněného souboru, anebo kontaktovat některého z autorů, kteří se vám pokusí pomoct. Jen pro úplnost je zde ve zkratce něco málo o jazyce typst a motivaci k tvorbě této šablony:
|
||||
|
||||
Typst je profesionální sázecí nástroj podobný markdownu, LaTeXu/TeXu, groffu, atd.
|
||||
|
||||
Typst je moderní obdobou starších nástrojů, které postrádají spoustu důležitých funkcí, bez kterých
|
||||
se v dnešní době prakticky nedá fungovat. Uživatel často musí importovat nepřeberné množství
|
||||
balíčků, které poskytují (podle mě) naprosto základní funkcionalitu - jako například správná podpora
|
||||
UTF-8 znaků, formátování prvků na základě jazykového lokálu, apod.
|
||||
|
||||
= Začínáme se šablonou
|
||||
|
||||
Tuto šablonu jste si pravděpodobně stáhli z generátoru na webu www.tulsablona.cz a vložili ji do Typst
|
||||
online editoru. Tím pádem vidíte kromě zdrojového kódu také výsledný PDF soubor. Jak už asi víte, hlavní
|
||||
rozdíl mezi tradičními textovými procesory jako Microsoft Word nebo LibreOffice Writer a mezi sázecími
|
||||
programy jako LaTeX nebo Typst je právě způsob, kterým se upravuje vzhled a obsah dokumentu.
|
||||
|
||||
Zatímco ve Wordu jsou uživatelé zvyklí, že pomocí tlačítek a klávesových zkratek mění dokument napřímo,
|
||||
Typst (a i LaTeX) používají tzv. zdrojový soubor, který není ničím jiným než obyčejným textovým souborem,
|
||||
a následně na vyžádání umí tento zdrojový soubor zkompilovat tj. proměnit na výsledný dokument, např. ve formátu PDF.
|
||||
|
||||
Proto zde najdete popis všech důležitých funkcí nikoliv jako galerii obrázků toho, na která tlačítka se má
|
||||
klikat, nýbrž jako ukázka a návod všech speciálních sekvencí textu, které Typst podporuje a které šablona vyhodnocuje jinak než obsah zprávy.
|
||||
|
||||
== Odstavce
|
||||
|
||||
Jak jsou někteří z vás možná zvyklí z Markdownu, odstavce, nadpisy a vlastně pro přehlednost všechny
|
||||
logicky oddělené bloky se oddělují prázným řádkem. Toho jste si jistě mohli při prohlížení tohoto souboru
|
||||
všimnout. Můžete si vyzkoušet, co se stane, když
|
||||
použijete jenom ukončení řádku enterem,
|
||||
|
||||
nebo když použijete zmíněný prázdný řádek,
|
||||
|
||||
|
||||
|
||||
anebo co se stane při použití dvou a více prázdných řádků. (spoiler: 1 a více prázdných řádků mají identické
|
||||
chování, pouze ukončení řádku je interpretováno stejně jako např. mezerník nebo tabulátor)
|
||||
|
||||
Uživatel má tím pádem svobodu v tom, jestli ve zdrojovém souboru používá dlouhé řádky plné textu,
|
||||
nebo
|
||||
má
|
||||
raději
|
||||
přehlednější
|
||||
formátování
|
||||
a sám si obsah dělí na řádky, protože ve výsledném PDF souboru se stejně spojí do jednoho celistvého odstavce.
|
||||
Musí akorát ručně dbát na to, aby odstavce nebyly příliš krátké, ani příliš dlouhé.
|
||||
|
||||
S souvislosti s odstavci bych ještě zmínil, že Typst se za vás stará také o zarovnávání písma a slov do bloků
|
||||
a dělení slov mezi řádky, když už se na něj nevejdou. Chováním odpovídá pravidlům českého pravopisu a typografie, takže se o to nemusíte vůbec starat.
|
||||
|
||||
== Klikatelný obsah
|
||||
|
||||
Pokud používáte oficiální Typst online editor, můžete jednoduše klepnout na jakýkoliv text v pravé části (náhledové PDF), který se dá měnit,
|
||||
a editor podle toho automaticky přesune váš kurzor na správné místo.
|
||||
Je to sice drobná, ale zato velmi užitečná funkce.
|
||||
|
||||
== Nadpisy
|
||||
|
||||
První důležitá funkce kromě psaní samotného textu, k čemuž není zapotřebí žádná speciální syntax, jsou nadpisy.
|
||||
Stejně jako v jiných programech, i Typst podporuje nadpisy více úrovní. Pro nadpis první úrovně se používá znaménko
|
||||
rovná se a mezera na začátku řádku, čili ve zdrojovém souboru Typstu je používán takto:
|
||||
|
||||
```typst
|
||||
= Můj nadpis první úrovně
|
||||
```
|
||||
|
||||
Pro nadpis druhé úrovně pak použijeme dvě rovná se, pro nadpis třetí úrovně tři rovná se.
|
||||
Šablona *tultemplate2* Vám ovšem bohužel nedovolí nadpis čtvrté a další úrovně, protože by takový
|
||||
nadpis porušoval směrnice TUL o formátování dokumentů. Ale nemusíte se bát. Pokud takový nadpis
|
||||
uděláte -- šablona vyhodí chybu, aby vás na to upozornila.
|
||||
|
||||
```typst
|
||||
= Nadpis
|
||||
== Podnadpis
|
||||
=== Podpodnadpis
|
||||
|
||||
A pak obsah
|
||||
```
|
||||
|
||||
== Číslování kapitol
|
||||
|
||||
Asi jste si všimli, že každý nadpis začíná číslem dané kapitoly. Toto číslování provádí Typst automaticky, promítne se následně i v sekci Obsah na začátku souboru, nemusíte se tak opět o nic starat.
|
||||
|
||||
= Kontrola šablony při kompilaci
|
||||
|
||||
Tato šablona je vytvořena tak, že když se ji pokusíte zkompilovat s nesprávnou syntaxí nebo s nějakou
|
||||
chybějící důležitou částí hlavičky,
|
||||
nenechá vás to provést. Vždy se podívejte na chybové hlášky, které šablona vypisuje, protože vás snadno navedou k opravě všech chyb.
|
||||
Můžete to vyzkoušet tak, že smažete něco z hlavičky nebo že např. použijete funkci, která není nikde definovaná.
|
||||
|
||||
= Používání funkcí
|
||||
|
||||
Používání většiny funkcionalit Typstu je prováděno pomocí tzv. volání funkce. Je to velmi podobné předchozím ukázkám,
|
||||
akorát místo toho, aby se text obalil pouze jedním symbolem či podobnou jednoduchou značkou, obalíme text jménem dané funkce. Syntaxe vypadá nějak takto:
|
||||
```typst
|
||||
#Název_funkce[samotný text nebo jiné parametry]
|
||||
```
|
||||
Pokud v editoru napíšete symbol hashtagu, začne vám automaticky našeptávat všechny možné funkce a jejich popisy. Přejdeme rovnou k dalším praktickým příkladům.
|
||||
|
||||
== Zvýrazňování textu
|
||||
|
||||
Syntaxe základního zvýraznění je velmi podobná například Markdownu. Stačí použít následující symboly:
|
||||
|
||||
```typst
|
||||
*tučně*
|
||||
_kurzívou_
|
||||
```
|
||||
|
||||
Další stylování lze dělat právě přes funkce, viz třeba:
|
||||
|
||||
```typst
|
||||
#strike[přeškrtnuto]
|
||||
#highlight[zvýrazněno]
|
||||
#underline[podtrženo] // podtržení by se NEMĚLO používat
|
||||
```
|
||||
|
||||
Pro úplnost a ukázku je zde přímo v textu *tučný text*, _text kurzívou_, #strike[přeškrtnutý text] a #highlight[text zvýrazněný podle barvy příslušící vaší fakultě], #underline[podtržený text] (ačkoli typografové doporučují podtržení nepoužívat).
|
||||
|
||||
== Odkazy<links>
|
||||
|
||||
Odkazy je možné dělat na URL/URI zdroje, e-maily, telefony, atd...
|
||||
Odkázat URL (URI) je možné bez zavolání funkce, odkaz stačí prostě a jednodušše napsat:
|
||||
https://git.zumepro.cz/tul/tultemplate2
|
||||
|
||||
```typst
|
||||
https://git.zumepro.cz/tul/tultemplate2
|
||||
```
|
||||
|
||||
Tohle interně volá funkci `link`.
|
||||
|
||||
Pokud odkazujeme na méně časté věci (jako e-maily), můžeme použít funkci `link` přímo.
|
||||
```typst
|
||||
#link("mailto:ondrej@mekina.cz")
|
||||
```
|
||||
|
||||
Dalši předpony (URI schémata) můžete najít třeba na Wikipedii
|
||||
https://en.wikipedia.org/wiki/List_of_URI_schemes.
|
||||
|
||||
== Obrázky
|
||||
|
||||
Obrázky je možné vkládat samotné, nebo i s popiskem.
|
||||
Obrázek se vloží pomocí funkce `image`.
|
||||
|
||||
Přidání popisku a zároveň zalistování obrázku v indexu (aby se na ně třeba dalo odkazovat) lze
|
||||
udělat pomocí funkce `figure`.
|
||||
|
||||
#block([
|
||||
```typst
|
||||
#figure(
|
||||
image("mujobrazek.jpg"),
|
||||
caption: [
|
||||
*Krásný* obrázek, který vypadá jako obrázek.
|
||||
]
|
||||
)
|
||||
```
|
||||
], breakable: false)
|
||||
|
||||
Tady je praktická ukázka jednoduchého vložení obrázku s popiskem:
|
||||
|
||||
#figure(image("../template/assets/tul_logo.svg", width: 25%), caption: [
|
||||
Logo *TUL*
|
||||
])
|
||||
|
||||
První parametr funkce je zobrazovaný obsah, v našem případě zmíněný `image`. K němu můžeme psát různé parametry, v příkladu máme třeba nastavení šířky obrázku v procentech. Jako poslední je parametr `caption`, s jehož pomocí můžeme nastavit popisek obrázku/figury.
|
||||
|
||||
Obrázky se zobrazí na začátku dokumentu v seznamu (pokud to daný typ dokumentu vyžaduje). I toto za vás Typst dělá automaticky, vám tak stačí do textu přidávat obrázky, jak se to hodí, a všechny se poté korektně zobrazí v Seznamu obrázků s odkazem i správně uvedenou stránkou, na které se obrázek nachází. Obrázky jsou také automaticky číslovány podle předepsaného způsobu, podobně jako kapitoly.
|
||||
|
||||
== 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")
|
||||
```
|
||||
|
||||
Parametr `columns` udává počet sloupců tabulky. Poté následuje libovolný počet buněk tabulky, pro lepší přehlednost jsou v příkladu jednotlivé řádky oddělené. Nakonec je zde opět parametr `caption` sloužící k zadání popisku tabulky.
|
||||
|
||||
#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). Jak už jste asi pochopili, i toto provede šablona automaticky.
|
||||
|
||||
== Citace
|
||||
|
||||
Šablona podporuje správu citací pomocí standardního BibTeX @bibtex souboru, stejně jako
|
||||
například LaTeX. Generování citací v BibTeX zápisu umí téměř každá stránka nebo program, které mají pro citace podporu.
|
||||
Kód takovéto citace ve vhodném formátu stačí přidat do souboru _citations.bib_, poté je možné se
|
||||
na ně odkazovat pomocí `@jmeno_citace`, nebo `#cite(<jmeno_citace>)`. Můžu se tak třeba odkázat na
|
||||
citaci Typstu #cite(<typst>).
|
||||
|
||||
Formát souboru _citations.bib_ je naprosto stejný jako pro LaTeX. Tyto citace lze přímo vložit
|
||||
třeba z webu https://www.citace.com ve formátu BibTeX -- Typst tento formát také umí přečíst.
|
||||
Můžete se do souboru s příponou .bib podívat, zjistíte, že je to opravdu jen obyčejný textový soubor se specifickou strukturou.
|
||||
V přiloženém ukázkovém souboru už nějaké citace jsou - např. již použitá citace se jménem `typst`.
|
||||
|
||||
Soubor, ze kterého se načtou citace lze změnit pomocí argumentu šablony (tj. struktura na začátku souboru):
|
||||
|
||||
```typst
|
||||
#show: tultemplate2.with(
|
||||
...
|
||||
citations: "jinysoubor.bib",
|
||||
...
|
||||
)
|
||||
```
|
||||
|
||||
== Vnitřní odkazy a kotvy<ukazka_odkazu>
|
||||
|
||||
Trochu navážeme na Odkazy (@links).
|
||||
|
||||
Můžete dělat i vnitřní odkazy třeba na kapitoly, stránky nebo obrázky s popiskem (zabalené ve
|
||||
`figure`).
|
||||
|
||||
```typst
|
||||
= Dobrá kapitola<dobra_kapitola>
|
||||
|
||||
Podívejme se na Dobrou kapitolu (@dobra_kapitola).
|
||||
```
|
||||
|
||||
Takhle vypadá kotva:
|
||||
|
||||
```typst
|
||||
<nazev_kotvy>
|
||||
```
|
||||
|
||||
Kotvu dáte někam do souboru a můžete na ní odkazovat stejně jako na citace:
|
||||
|
||||
```typst
|
||||
@nazev_kotvy
|
||||
```
|
||||
Můžeme se podívat na názornou ukázku odkazu (@ukazka_odkazu).
|
||||
|
||||
== Zkratky
|
||||
|
||||
LaTeX TUL šablona má k začátku dokumentu seznam zkratek. Proto jsme ho přidali i do této šablony.
|
||||
Seznam zkratek je v této šabloně nastaven tak, aby se zobrazoval pouze pokud je v něm alespoň jedna
|
||||
zkratka (přišlo nám to poměrně logické).
|
||||
|
||||
Zkratku #abbr("ABC", "Abeceda") vytvoříte (definujete) pomocí:
|
||||
|
||||
```typst
|
||||
#abbr("ABC", "Abeceda")
|
||||
```
|
||||
|
||||
Potom zkratku #abbr("ABC") už můžete použít přímo (bez opakované definice):
|
||||
|
||||
```typst
|
||||
#abbr("ABC")
|
||||
```
|
||||
|
||||
Šablona zajistí následující věci:
|
||||
- Zkratka se zobrazí v seznamu zkratek
|
||||
- Při prvním použití zkratky vás šablona donutí zkratku definovat
|
||||
- Definice zkratky bude použita právě jednou (poprvé)
|
||||
|
||||
Při prvním použití zkratky (při definici) bude zkratka v textu vypadat takto:
|
||||
#abbr("ZK", "Zkratka").
|
||||
Při dalších použití bude vypadat takto: #abbr("ZK").
|
||||
|
||||
#highlight[
|
||||
Tedy zkratku _nepřidáváte_ přímo do seznamu zkratek, ale elegantně jí používáte přímo v textu.
|
||||
]
|
||||
|
||||
== Přílohy
|
||||
|
||||
Na konec souboru (nebo klidně doprostřed či na začátek, hlavní je, že pouze jednou) je také možné dát strukturu generující přílohy. Momentálně jsou podporované čtyři typy příloh: odkaz, obsah, PDF soubor vložený na konec dokumentu a odkaz na externí soubor (například přiložený do systému s bakalářskou prací).
|
||||
Jako demonstrace by měla postačit praktická ukázka, která ve zdrojovém kódu následuje hned za tímto odstavcem, a která generuje přílohy tohoto 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.]),
|
||||
)
|
||||
Ročníkový projekt
|
||||
ročníkovým projektem
|
||||
|
||||
@@ -52,312 +52,4 @@
|
||||
citations: "citations.bib",
|
||||
)
|
||||
|
||||
= A quick few words about this template
|
||||
|
||||
This template should serve as an example yearly Project report thesis written with the help of the *Typst* programming
|
||||
language and the *tultemplate2* template. It can be used as a starting point for your own report, you just
|
||||
have to learn a few of its useful functions, e.g. how to insert images, tables, citacions or links.
|
||||
|
||||
In contrast with the _documentation.typ_ file, which is available for download on the project's page,
|
||||
this document only contains the most necessary knowledge to complete most reports. If you find this
|
||||
documentt lacking in features, you can look at the aforementioned docs or contact one of the authors,
|
||||
who will try to help you. Just for the sake of completeness, here is a few words about the Typst programming
|
||||
language and about Typst, as well as about the motivation behind the creation of this template:
|
||||
|
||||
Typst is a professional typesetting language similar to markdown, LaTeX/TeX, groff, etc.
|
||||
|
||||
Typst is the modern equivalent of older typesetting tools, which often lack a lot of important features,
|
||||
such that make it next to impossible to work without today. The user must often import an incountable number of packages,
|
||||
which only provide only the most basic of functionalities - for example proper UTF-8 character support,
|
||||
formatting of elements based on the set locale, etc.
|
||||
|
||||
= Getting Started with the Template
|
||||
|
||||
You have probably downloaded this template from the generator on the website www.tulsablona.cz and inserted
|
||||
it into the Typst online editor. Therefore, besides the source code, you can also see the resulting PDF file.
|
||||
As you probably know, the main difference between traditional word processors like Microsoft Word or LibreOffice
|
||||
Writer and typesetting programs like LaTeX or Typst is the way in which the appearance and content of the document
|
||||
are edited.
|
||||
|
||||
While Word users are used to changing the document directly using buttons and keyboard shortcuts, Typst (and also LaTeX)
|
||||
use a so-called source file, which is nothing more than an ordinary text file, and can then, on request, compile this
|
||||
source file -- i.e., turn it into the final document, for example in PDF format.
|
||||
|
||||
That’s why here you will find a description of all the important functions not as a gallery of images showing which
|
||||
buttons to click, but rather as an example and guide to all the special text sequences that Typst supports and that
|
||||
the template interprets differently from the main content of the report.
|
||||
|
||||
== Paragraphs
|
||||
|
||||
Some of you might know this concept from using Markdown, where paragraphs, headings and for the sake of clarity all
|
||||
logically coherent blocks are separated by an empty line. You might have already spotted this while reading through
|
||||
this document. You can try for yourself what happens when
|
||||
you just end the line
|
||||
|
||||
or when you properly use an empty line,
|
||||
|
||||
|
||||
|
||||
|
||||
or maybe what happens if you use two or more empty rows. (spoiler: 1 or more empty lines share identical behavior,
|
||||
while newlining only is interpreted the same as using spaces or tabs)
|
||||
|
||||
Therefore, the user has freedom of choosing whether he uses long lines full of text,
|
||||
or
|
||||
if
|
||||
he
|
||||
prefers
|
||||
a
|
||||
cleaner
|
||||
formatting
|
||||
and manages the separation of content to lines, because it all gets concatenated into a nice consice paragraph.
|
||||
The user has to manually watch out for the length of the paragraphs, so that they are neither too short or too long.
|
||||
|
||||
In the context of paragraphs, it should be mentioned that Typst also manages the alignment of text and words into blocks
|
||||
and the division of words between lines when they don't fit.
|
||||
This behavior complies with the English grammar and typography rules fully, so you don't have to think about that at all.
|
||||
|
||||
== Clickable content
|
||||
|
||||
When using the official Typst online editor, you can simply click on any text in the right side (the preview PDF),
|
||||
and your cursor will jump directly to that text in the source file.
|
||||
A small but very practical feature.
|
||||
|
||||
== Headings
|
||||
|
||||
The first important feature, apart from writing the text itself (which requires no special syntax), is the usage of headings.
|
||||
Just like in other programs, Typst also supports multi-level headings. For a first-level heading, an equals sign followed
|
||||
by a space is used at the beginning of a line, meaning that in a Typst source file it is written like this:
|
||||
|
||||
```typst
|
||||
= My first level heading
|
||||
```
|
||||
|
||||
For a second-level heading, we then use two equals signs; for a third-level heading, three equals signs...
|
||||
There are enough subheading levels that you’ll probably never run out. However, the TUL guidelines for writing reports
|
||||
forbid usage of level four heading or larger, so you can (and should) only use headings from level 1 to 3.
|
||||
If you try to use fourth-level or larger heading, the template will warn you not to do that and will refuse to compile
|
||||
until you fix this. More on this behavior later.
|
||||
|
||||
```typst
|
||||
= Heading
|
||||
== Subheading
|
||||
=== Subsubheading
|
||||
|
||||
And then your content
|
||||
```
|
||||
|
||||
== Chapter Numbering
|
||||
|
||||
You’ve probably noticed that each heading begins with the number of its respective chapter. Typst handles this numbering
|
||||
automatically, and it’s also reflected in the *Table of Contents* at the start of the document, so you don’t have to
|
||||
worry about it yourself.
|
||||
|
||||
== Template compile-time checks
|
||||
|
||||
This template is created in such a way that when you try to compile it with incorrect syntax or an imoportant
|
||||
part of the header missing, it won't let you. Always see the error messages the template provides,
|
||||
as they will simply guide you to fix your mistakes. You can try this by deleting something from the header,
|
||||
or by using e.g. a function that ins't defined anywhere.
|
||||
|
||||
= Using Functions
|
||||
|
||||
Most Typst features are used through what’s called *function calls*. This is quite similar to the previous examples,
|
||||
except that instead of wrapping text with a single symbol or a simple marker, we wrap it with the name of the function.
|
||||
The syntax looks like this:
|
||||
|
||||
```typst
|
||||
#Function_name[text itself or other parameters]
|
||||
```
|
||||
|
||||
When you type the hash symbol in the editor, it will automatically start suggesting all available functions and their descriptions.
|
||||
Let’s move on to some practical examples.
|
||||
|
||||
== Text Highlighting
|
||||
|
||||
The syntax for basic highlighting is very similar to Markdown. You just need to use the following symbols:
|
||||
|
||||
```typst
|
||||
*bold*
|
||||
_italic_
|
||||
```
|
||||
|
||||
More styling options can be applied through functions, for example:
|
||||
|
||||
```typst
|
||||
#strike[struck through]
|
||||
#highlight[highlighted]
|
||||
#underline[underlined] // underline SHOULD NOT be used
|
||||
```
|
||||
|
||||
For completeness and demonstration, here in the text we have *bold text*, _italic text_, #strike[struck-through text],
|
||||
and #highlight[text highlighted with your faculty’s color], as well as #underline[underlined text]
|
||||
(although typographers generally advise against using underlining).
|
||||
|
||||
== Links<links>
|
||||
|
||||
You can create links to URLs/URIs, emails, phone numbers, and more.
|
||||
A URL (URI) link can be written directly, without calling any function --- just type it in:
|
||||
|
||||
https://git.zumepro.cz/tul/tultemplate2
|
||||
|
||||
```typst
|
||||
https://git.zumepro.cz/tul/tultemplate2
|
||||
```
|
||||
|
||||
Internally, this automatically calls the `link` function.
|
||||
|
||||
If we want to link to less common things (like email addresses), we can call the `link` function explicitly:
|
||||
|
||||
```typst
|
||||
#link("mailto:ondrej@mekina.cz")
|
||||
```
|
||||
|
||||
You can find other prefixes (URI schemes) on Wikipedia:
|
||||
https://en.wikipedia.org/wiki/List_of_URI_schemes.
|
||||
|
||||
== Images
|
||||
|
||||
Images can be inserted either by themselves or with a caption.
|
||||
|
||||
An image is inserted using the `image` function:
|
||||
|
||||
To add a caption and also include the image in the index (so you can reference it later), use the `figure` function:
|
||||
|
||||
#block([
|
||||
```typst
|
||||
#figure(
|
||||
image("myimage.jpg"),
|
||||
caption: [
|
||||
*A beautiful* picture that looks like a picture.
|
||||
]
|
||||
)
|
||||
```
|
||||
], breakable: false)
|
||||
|
||||
Here’s a practical example of inserting an image with a caption:
|
||||
|
||||
#figure(image("../template/assets/tul_logo.svg", width: 25%), caption: [
|
||||
Logo of *TUL*
|
||||
])
|
||||
|
||||
The first parameter of the function is the displayed content --- in our case, the mentioned `image`. You can then specify various parameters for it; in the example, we define the image width as a percentage.
|
||||
The last parameter is `caption`, which lets us set the figure’s (or image’s) caption text.
|
||||
|
||||
If the document type requires it, images will automatically appear in a list at the beginning of the document. Typst handles this automatically for you --- all you need to do is add images wherever appropriate, and they’ll show up correctly in the *List of Figures*, complete with references and page numbers.
|
||||
Images are also numbered automatically according to the predefined style, similar to chapters.
|
||||
|
||||
== Tables
|
||||
|
||||
Tables can be created like this:
|
||||
|
||||
```typst
|
||||
#figure(table(
|
||||
columns: 3,
|
||||
table.header([], [*Column 1*], [*Column 2*]),
|
||||
[*Row 1*], [a], [b],
|
||||
[*Row 2*], [c], [d],
|
||||
), caption: "My beautiful table")
|
||||
```
|
||||
|
||||
The `columns` parameter specifies the number of columns in the table. Then comes any number of table cells --- for clarity, the rows are separated in the example. Finally, there’s again a `caption` parameter, used to provide a caption for the table.
|
||||
|
||||
#highlight[It’s a good idea to wrap the table header (the first row) in the `header` function (as shown above)] --- this ensures Typst includes extra metadata in the generated PDF (for example, for people with visual impairments).
|
||||
|
||||
#figure(table(
|
||||
columns: 3,
|
||||
table.header([], [*Column 1*], [*Column 2*]),
|
||||
[*Row 1*], [a], [b],
|
||||
[*Row 2*], [c], [d],
|
||||
), caption: "My beautiful table")
|
||||
|
||||
Tables also appear at the beginning of the document in a list (if required by the document type).
|
||||
As you’ve probably noticed by now, Typst’s template takes care of this automatically.
|
||||
|
||||
== Citations
|
||||
|
||||
The template supports citation management using a standard BibTeX file @bibtex, just like LaTeX. Almost every website or program that supports citations can generate BibTeX-formatted entries.
|
||||
You simply add the code for such a citation, in the proper format, to the file _citations.bib_. Once added, you can reference it using `@citation_name` or `#cite(<citation_name>)`.
|
||||
For example, I can reference the Typst citation as #cite(<typst>).
|
||||
|
||||
The format of the _citations.bib_ file is exactly the same as in LaTeX. You can even copy entries directly from sites like [citace.com](https://www.citace.com) in BibTeX format --- Typst understands that format, too.
|
||||
If you open a `.bib` file, you’ll see that it’s simply a plain text file with a specific structure.
|
||||
The provided sample file already contains several citations --- for instance, the one named `typst`, which was already used above.
|
||||
|
||||
You can change the file from which citations are loaded using a template argument (i.e., in the structure at the beginning of your Typst document):
|
||||
|
||||
```typst
|
||||
#show: tultemplate2.with(
|
||||
...
|
||||
citations: "anotherfile.bib",
|
||||
...
|
||||
)
|
||||
```
|
||||
|
||||
== Internal Links and Anchors<example_anchor>
|
||||
|
||||
Let’s continue from the *Links* section (@links).
|
||||
|
||||
You can also create internal links --- for instance, to chapters, pages, or labeled images (those wrapped with the `figure` function).
|
||||
|
||||
```typst
|
||||
= A Good Chapter<good_chapter>
|
||||
|
||||
Let’s take a look at A Good Chapter (@good_chapter).
|
||||
```
|
||||
|
||||
Here’s what an anchor looks like:
|
||||
|
||||
```typst
|
||||
<anchor_name>
|
||||
```
|
||||
|
||||
You place the anchor anywhere in the file, and you can reference it the same way you reference citations:
|
||||
|
||||
```typst
|
||||
@anchor_name
|
||||
```
|
||||
|
||||
For example, we can take a look at this illustrative reference (@example_anchor).
|
||||
|
||||
== Abbreviations
|
||||
|
||||
The LaTeX TUL template includes a list of abbreviations at the beginning of the document. Therefore, we’ve included one here as well.
|
||||
This list is configured to appear only if there is *at least one* abbreviation defined --- which seemed quite logical.
|
||||
|
||||
You can create (define) an abbreviation with #abbr("ABC", "Alphabet") like this:
|
||||
|
||||
```typst
|
||||
#abbr("ABC", "Alphabet")
|
||||
```
|
||||
|
||||
After that, you can use the abbreviation #abbr("ABC") directly without redefining it:
|
||||
|
||||
```typst
|
||||
#abbr("ABC")
|
||||
```
|
||||
|
||||
The template automatically ensures the following:
|
||||
- The abbreviation appears in the list of abbreviations
|
||||
- When you use an abbreviation for the first time, the template *requires* you to define it
|
||||
- The definition is used only once (the first time it appears)
|
||||
|
||||
When used for the first time (definition), the abbreviation will look like this:
|
||||
#abbr("ABR", "Abbreviation").
|
||||
In subsequent uses, it will appear as: #abbr("ABR").
|
||||
|
||||
#highlight[
|
||||
In other words, you do _not_ add abbreviations directly to the abbreviation list.
|
||||
You simply use them elegantly within the text itself.
|
||||
]
|
||||
|
||||
== Attachments
|
||||
|
||||
At the end of the file (or anywhere else, as long as it’s included only once), you can add a structure that generates attachments.
|
||||
Currently, two types of attachments are supported --- links and content.
|
||||
As a demonstration, here’s a practical example (included right after this paragraph in the source code), which generates the attachments for this document:
|
||||
|
||||
#attachments(
|
||||
attach_link("Source code of this template", "https://git.zumepro.cz/tul/tultemplate2"),
|
||||
attach_content("Test content generated by Typst", [Here you can write _styled_ content.]),
|
||||
)
|
||||
Project
|
||||
|
||||
Reference in New Issue
Block a user