add function documentation and citation file changing
This commit is contained in:
35
example.typ
35
example.typ
@@ -1,7 +1,7 @@
|
|||||||
#import "template/template.typ": *
|
#import "template/template.typ": *
|
||||||
|
|
||||||
#show: tultemplate.with(
|
#show: tultemplate2.with(
|
||||||
"classic", "fm", "cs",
|
"latex", "fm", "cs",
|
||||||
title: "Návod na použití Typst TUL šablony",
|
title: "Návod na použití Typst TUL šablony",
|
||||||
author: "Ondřej Mekina",
|
author: "Ondřej Mekina",
|
||||||
)
|
)
|
||||||
@@ -192,6 +192,26 @@ Tady je praktická ukázka jednoduchého vložení obrázku s popiskem:
|
|||||||
Logo *TUL*
|
Logo *TUL*
|
||||||
])
|
])
|
||||||
|
|
||||||
|
== Citace
|
||||||
|
|
||||||
|
Šablona podporuje správu citací pomocí standardního BibTeX @bibtex souboru, stejně jako
|
||||||
|
například LaTeX. 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.
|
||||||
|
|
||||||
|
Soubor, ze kterého se načtou citace lze změnit pomocí argumentu šablony:
|
||||||
|
|
||||||
|
```typst
|
||||||
|
#show: tultemplate2.with(
|
||||||
|
...
|
||||||
|
citations: "jinysoubor.bib",
|
||||||
|
...
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
== Vnitřní odkazy a kotvy
|
== Vnitřní odkazy a kotvy
|
||||||
|
|
||||||
Trochu navážeme na Odkazy (@links).
|
Trochu navážeme na Odkazy (@links).
|
||||||
@@ -217,13 +237,6 @@ Kotvu dáte někam do souboru a můžete na ní odkazovat stejně jako na citace
|
|||||||
@nazev_kotvy
|
@nazev_kotvy
|
||||||
```
|
```
|
||||||
|
|
||||||
== Citace
|
|
||||||
|
|
||||||
Šablona samozřejmě podporuje správu citací pomocí standardního BibTeX @bibtex souboru, stejně jako
|
|
||||||
ta LaTeXová. Citace ve vhodném formátu stačí přidat do souboru _citacions.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>).
|
|
||||||
|
|
||||||
== Pro pokročilé
|
== Pro pokročilé
|
||||||
|
|
||||||
Typst má spoustu dalších způsobů stylování (a i skriptování). Podívejte se třeba na zdrojový kód
|
Typst má spoustu dalších způsobů stylování (a i skriptování). Podívejte se třeba na zdrojový kód
|
||||||
@@ -271,7 +284,7 @@ Zde je ukázkové použití:
|
|||||||
```typst
|
```typst
|
||||||
#todo(
|
#todo(
|
||||||
"koupit vajíčka",
|
"koupit vajíčka",
|
||||||
do_highlight: false // vypnout zvýraznění (pokud chcete)
|
accent: false // vypnout zvýraznění (pokud chcete)
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
], breakable: false)
|
], breakable: false)
|
||||||
@@ -288,7 +301,7 @@ paragrafů, počtu písmen, atd...
|
|||||||
Výše volaná funkce vygeneruje deset slov Lorem Ipsum. Doporučuji `lorem` kombinovat s `todo`.
|
Výše volaná funkce vygeneruje deset slov Lorem Ipsum. Doporučuji `lorem` kombinovat s `todo`.
|
||||||
|
|
||||||
```typst
|
```typst
|
||||||
#todo(lorem(10), do_highlight: false)
|
#todo(lorem(10), accent: false)
|
||||||
```
|
```
|
||||||
|
|
||||||
Takhle si můžete předpřipravit délku odstavců a vyzkoušet si, jestli se rozsahem práce trefíte
|
Takhle si můžete předpřipravit délku odstavců a vyzkoušet si, jestli se rozsahem práce trefíte
|
||||||
|
@@ -1,6 +1,13 @@
|
|||||||
#let todos = state("todos", "0");
|
#let todos = state("todos", "0");
|
||||||
#let is_prod = state("is_prod", "false");
|
#let is_prod = state("is_prod", "false");
|
||||||
|
|
||||||
|
// Set a build profile.
|
||||||
|
//
|
||||||
|
// This can be:
|
||||||
|
// - debug (debug comments and todos are displayed)
|
||||||
|
// - release (document will be ready for release)
|
||||||
|
//
|
||||||
|
// - profile (str): The target profile
|
||||||
#let profile(profile) = {
|
#let profile(profile) = {
|
||||||
let profiles = ("debug", "release");
|
let profiles = ("debug", "release");
|
||||||
if profile not in profiles {
|
if profile not in profiles {
|
||||||
@@ -33,13 +40,19 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#let todo(content, do_highlight: true) = {
|
// Sets an item that should be done later.
|
||||||
|
//
|
||||||
|
// This will cause an error when compiling with a release profile.
|
||||||
|
//
|
||||||
|
// - content (str): What should you do?
|
||||||
|
// - accent (bool): Whether to highlight the todo
|
||||||
|
#let todo(content, accent: true) = {
|
||||||
context {
|
context {
|
||||||
todos.update(todos => {
|
todos.update(todos => {
|
||||||
str(eval(todos) + 1)
|
str(eval(todos) + 1)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if do_highlight {
|
if accent {
|
||||||
highlight(text(content, fill: white), fill: red, radius: .25em, extent: .25em);
|
highlight(text(content, fill: white), fill: red, radius: .25em, extent: .25em);
|
||||||
} else {
|
} else {
|
||||||
text(content);
|
text(content);
|
||||||
|
@@ -8,28 +8,53 @@
|
|||||||
|
|
||||||
#import "prototyping.typ": todo, profile
|
#import "prototyping.typ": todo, profile
|
||||||
|
|
||||||
#let tultemplate(
|
// TUL Template 2
|
||||||
template_id,
|
//
|
||||||
faculty_abbreviation,
|
// Use this at the beginning of a Typst file:
|
||||||
language,
|
// ```typst
|
||||||
document_type: none,
|
// #import "template/template.typ": *
|
||||||
title: none, author: none, supervisor: none, study_programme: none,
|
//
|
||||||
|
// #show: tultemplate2.with(
|
||||||
|
// "classic", "fm", "cs", ...
|
||||||
|
// )
|
||||||
|
// ```
|
||||||
|
//
|
||||||
|
// - style (str): Visual style to use. This can be "latex".
|
||||||
|
// - faculty (str): Factulty abbreviation. One of "fs", "ft", "fp", "ef", "fua", "fm", "fzs", "cxi".
|
||||||
|
// - lang (str): Language code. This can be "cs" or "en".
|
||||||
|
// - document (str): Type of document. This can be "bp", "dp", "ds".
|
||||||
|
// - title (str): The title of the document.
|
||||||
|
// - author (str): The name of the document's author.
|
||||||
|
// - supervisor (str): The name of the document's supervisor.
|
||||||
|
// - programme (str): Study programme.
|
||||||
|
// - citations (str): The location of the citation file.
|
||||||
|
// - content (content): The content of the document
|
||||||
|
//
|
||||||
|
//-> none
|
||||||
|
#let tultemplate2(
|
||||||
|
style,
|
||||||
|
faculty,
|
||||||
|
lang,
|
||||||
|
document: none,
|
||||||
|
title: none, author: none, supervisor: none, programme: none,
|
||||||
|
citations: "citations.bib",
|
||||||
content,
|
content,
|
||||||
) = {
|
) = {
|
||||||
import "template_classic.typ": template_classic
|
import "template_classic.typ": template_classic
|
||||||
import "utils.typ": assert_in_dict
|
import "utils.typ": assert_in_dict
|
||||||
let templates = (
|
let templates = (
|
||||||
classic: template_classic,
|
latex: template_classic,
|
||||||
);
|
);
|
||||||
assert_in_dict(template_id, templates, "template name");
|
assert_in_dict(style, templates, "template name");
|
||||||
|
|
||||||
// global set-up
|
// global set-up
|
||||||
import "lang.typ": lang_ids
|
import "lang.typ": lang_ids
|
||||||
assert_in_dict(language, lang_ids, "language abbreviation");
|
assert_in_dict(lang, lang_ids, "language abbreviation");
|
||||||
set text(lang: language);
|
set text(lang: lang);
|
||||||
templates.at(template_id)(
|
templates.at(style)(
|
||||||
faculty_abbreviation, language, document_type,
|
faculty, lang, document,
|
||||||
title, author, supervisor, study_programme,
|
title, author, supervisor, programme,
|
||||||
|
"../" + citations,
|
||||||
content
|
content
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -37,6 +62,10 @@
|
|||||||
assert_release_ready();
|
assert_release_ready();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make a new abbreviation
|
||||||
|
//
|
||||||
|
// - abbreviation (str): The abbreviation
|
||||||
|
// - text (str): Optionally, the text - the meaning of the abbreviation.
|
||||||
#let abbr(abbreviation, ..text) = {
|
#let abbr(abbreviation, ..text) = {
|
||||||
import "abbreviations.typ": abbr
|
import "abbreviations.typ": abbr
|
||||||
return abbr(abbreviation, if text.pos().len() == 0 { none } else { text.pos().at(0) });
|
return abbr(abbreviation, if text.pos().len() == 0 { none } else { text.pos().at(0) });
|
||||||
|
@@ -94,6 +94,7 @@
|
|||||||
language,
|
language,
|
||||||
document_type,
|
document_type,
|
||||||
title, author, supervisor, study_programme,
|
title, author, supervisor, study_programme,
|
||||||
|
citation_file,
|
||||||
content,
|
content,
|
||||||
) = {
|
) = {
|
||||||
// intro page
|
// intro page
|
||||||
@@ -150,5 +151,5 @@
|
|||||||
content
|
content
|
||||||
|
|
||||||
// bibliography
|
// bibliography
|
||||||
bibliography("../citations.bib", style: "./tul_citace.csl")
|
bibliography(citation_file, style: "./tul_citace.csl")
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user