add classic template styling
This commit is contained in:
4
Makefile
4
Makefile
@@ -1,5 +1,7 @@
|
|||||||
.PHONY: example
|
.PHONY: example
|
||||||
example: example.pdf
|
example: example.pdf
|
||||||
|
|
||||||
%.pdf: %.typ
|
TEMPLATE_SRCS := $(shell find template -type f)
|
||||||
|
|
||||||
|
%.pdf: %.typ $(TEMPLATE_SRCS)
|
||||||
typst compile --font-path template/fonts $<
|
typst compile --font-path template/fonts $<
|
||||||
|
@@ -1,7 +1,11 @@
|
|||||||
#import "template/template.typ": tultemplate
|
#import "template/template.typ": *
|
||||||
|
|
||||||
#tultemplate(
|
#show: tultemplate.with(
|
||||||
"classic", "fm", "cs",
|
"classic", "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",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
= Todo
|
||||||
|
|
||||||
|
WIP
|
||||||
|
23
template/abbreviations.typ
Normal file
23
template/abbreviations.typ
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#let abbreviations = state("abbrs", "()");
|
||||||
|
|
||||||
|
#let abbr(abbreviation, text) = {
|
||||||
|
abbreviations.update(abbrs => {
|
||||||
|
let abbrs = if abbrs.len() == 2 { eval(abbrs).to-dict() } else { eval(abbrs) };
|
||||||
|
if abbreviation not in abbrs {
|
||||||
|
if type(text) == type(none) {
|
||||||
|
panic(
|
||||||
|
"abbreviation '" + abbreviation +
|
||||||
|
"' has no definition yet, please specify it on the first call"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
abbrs.insert(abbreviation, text);
|
||||||
|
}
|
||||||
|
"(" + abbrs.pairs().map((v) => { v.at(0) + ":\"" + v.at(1) + "\"" }).join(",") + ")"
|
||||||
|
});
|
||||||
|
abbreviation;
|
||||||
|
}
|
||||||
|
|
||||||
|
#let abbrlist() = {
|
||||||
|
let abbreviations = abbreviations.final();
|
||||||
|
return if abbreviations.len() == 2 { ().to-dict() } else { eval(abbreviations) }
|
||||||
|
}
|
@@ -1,20 +1,26 @@
|
|||||||
#import "template_classic.typ": template_classic
|
|
||||||
#import "utils.typ": assert_in_dict
|
|
||||||
|
|
||||||
#let templates = (
|
|
||||||
classic: template_classic,
|
|
||||||
);
|
|
||||||
|
|
||||||
#let tultemplate(
|
#let tultemplate(
|
||||||
template_id,
|
template_id,
|
||||||
faculty_abbreviation,
|
faculty_abbreviation,
|
||||||
language,
|
language,
|
||||||
document_type: none,
|
document_type: none,
|
||||||
title: none, author: none, supervisor: none, study_programme: none,
|
title: none, author: none, supervisor: none, study_programme: none,
|
||||||
|
content,
|
||||||
) = {
|
) = {
|
||||||
|
import "template_classic.typ": template_classic
|
||||||
|
import "utils.typ": assert_in_dict
|
||||||
|
let templates = (
|
||||||
|
classic: template_classic,
|
||||||
|
);
|
||||||
assert_in_dict(template_id, templates, "template name");
|
assert_in_dict(template_id, templates, "template name");
|
||||||
|
|
||||||
templates.at(template_id)(
|
templates.at(template_id)(
|
||||||
faculty_abbreviation, language, document_type,
|
faculty_abbreviation, language, document_type,
|
||||||
title, author, supervisor, study_programme
|
title, author, supervisor, study_programme,
|
||||||
|
content
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#let abbr(abbreviation, ..text) = {
|
||||||
|
import "abbreviations.typ": abbr
|
||||||
|
return abbr(abbreviation, if text.pos().len() == 0 { none } else { text.pos().at(0) });
|
||||||
|
}
|
||||||
|
@@ -71,12 +71,32 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#let abbrlist(language) = {
|
||||||
|
import "abbreviations.typ": abbrlist
|
||||||
|
context {
|
||||||
|
let abbrs = abbrlist();
|
||||||
|
let max_abbr_width = if abbrs.len() > 0 {
|
||||||
|
calc.max(abbrs.keys().map((v) => measure(v).width)).at(0)
|
||||||
|
} else { return };
|
||||||
|
pagebreak(weak: true);
|
||||||
|
heading(("Seznam zkratek", "List of abbreviations").at(language), numbering: none);
|
||||||
|
align(center, grid(
|
||||||
|
columns: 2,
|
||||||
|
..abbrs.pairs().map((v) => {
|
||||||
|
(block(text(v.at(0), weight: "bold"), width: max_abbr_width + 1em), text(v.at(1)))
|
||||||
|
}).flatten()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#let template_classic(
|
#let template_classic(
|
||||||
faculty_id,
|
faculty_id,
|
||||||
language,
|
language,
|
||||||
document_type,
|
document_type,
|
||||||
title, author, supervisor, study_programme
|
title, author, supervisor, study_programme,
|
||||||
|
content,
|
||||||
) = {
|
) = {
|
||||||
|
// intro page
|
||||||
page({
|
page({
|
||||||
classic_header(faculty_id, language);
|
classic_header(faculty_id, language);
|
||||||
align({
|
align({
|
||||||
@@ -84,4 +104,44 @@
|
|||||||
v(5em);
|
v(5em);
|
||||||
}, bottom);
|
}, bottom);
|
||||||
}, margin: 2cm);
|
}, margin: 2cm);
|
||||||
|
|
||||||
|
// styling
|
||||||
|
let faculty_color = faculty_color(faculty_id);
|
||||||
|
set par(justify: true);
|
||||||
|
set text(lang: "cs");
|
||||||
|
set heading(numbering: "1.1.1 ");
|
||||||
|
set page(margin: (outside: 4cm, top: 3cm, bottom: 3cm), numbering: "1", footer: {
|
||||||
|
context {
|
||||||
|
let page = counter(page).get().at(0);
|
||||||
|
align(str(page), if calc.rem(page, 2) == 0 { right } else { left })
|
||||||
|
}
|
||||||
|
});
|
||||||
|
show heading: it => {
|
||||||
|
block(
|
||||||
|
above: 2em,
|
||||||
|
below: 2em,
|
||||||
|
text(it, faculty_color, font: "TUL Mono", size: 1.2em)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
show heading.where(level: 1): it => {
|
||||||
|
pagebreak();
|
||||||
|
v(2cm);
|
||||||
|
it
|
||||||
|
};
|
||||||
|
|
||||||
|
let language = lang_id(language);
|
||||||
|
|
||||||
|
// toc
|
||||||
|
show outline.entry.where(level: 1): it => {
|
||||||
|
show repeat: none;
|
||||||
|
block(text(it, weight: "bold", size: 1.2em), above: 1.5em);
|
||||||
|
};
|
||||||
|
outline(title: ("Obsah", "Contents").at(language));
|
||||||
|
|
||||||
|
// abbreviation list
|
||||||
|
abbrlist(language);
|
||||||
|
|
||||||
|
// content
|
||||||
|
pagebreak(to: "even", weak: true);
|
||||||
|
content
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user