1
0

5 Commits

Author SHA1 Message Date
2e65baae70 refactor: backport changes from noatu's fork
feat(style)!: remove reference styling & fix figure numbering for appendices
feat!: swap appending on 'none' being the first position in ..sink
feat: add chapters to pz-lb()
feat: add asserts
fix: better control flow

img() function now requires `none` to be the first position in ..sink,
e.g. `#img("/fig/1.png", "Caption", none)` to get "Caption (рисунок виконано самостійно)" caption.

Use `@some_label[див. рис.]` to get a "див. рис. 42" link.

Signed-off-by: unexplrd <unexplrd@linerds.us>
2025-07-09 17:17:53 +03:00
d338c21965 Merge pull request 'add name of educational program && names of subjects for this semester' (#14) from add-program-and-subject-names into 0.1.0
Reviewed-on: pencelheimer/typst_nure_template#14
LGTM
2025-05-25 04:11:28 +03:00
7e15ea09d4 add name of educational program && names of subjects for this semester 2025-05-25 04:08:53 +03:00
3b3d62fd9b lib.typ: too lazy to name it
Signed-off-by: unexplrd <unexplrd@linerds.us>
2025-05-20 20:46:32 +03:00
04c5b283e7 lib.typ: better code branching
Signed-off-by: unexplrd <unexplrd@linerds.us>
2025-05-20 20:31:41 +03:00
10 changed files with 390 additions and 346 deletions

2
.gitignore vendored
View File

@ -1,3 +1 @@
*.pdf *.pdf
test
config

View File

@ -1,6 +1,3 @@
> [!CAUTION]
> Experimental fork. Successfully **breaking** stuff each commit. Documentation is **not** up to date.
# Typst Template for NURE Works # Typst Template for NURE Works
![pz-lb title page](assets/pz-lb_title_page.png) ![pz-lb title page](assets/pz-lb_title_page.png)
@ -10,7 +7,7 @@ This project contains two template functions and some utilities for writing NURE
### Templates ### Templates
#### `general` - For general works #### `pz-lb` - For Practice and Laboratory Works
This template: This template:
- Sets up document styles; - Sets up document styles;
- Formats the title page according to NURE/DSTU guidelines. - Formats the title page according to NURE/DSTU guidelines.
@ -33,11 +30,11 @@ This template:
### As a local typst package ### As a local typst package
1. Clone this repository into ~/.local/share/typst/packages/: 1. Clone this repository into ~/.local/share/typst/packages/:
```bash ```bash
git clone https://github.com/noatu/typst-nure-template.git ~/.local/share/typst/packages/local/nure/0.2.0 git clone -b 0.1.0 https://gitea.linerds.us/pencelheimer/typst_nure_template.git ~/.local/share/typst/packages/local/nure/0.1.0
``` ```
2. Init your project with Typst: 2. Init your project with Typst:
```bash ```bash
typst init @local/nure:0.2.0 project-name typst init @local/nure:0.1.0 project-name
``` ```
### As a standalone file ### As a standalone file
@ -46,19 +43,19 @@ Copy `lib.typ` to your project's root directory.
### In your project ### In your project
```typst ```typst
// Import the template either from a local package... // Import the template either from a local package...
#import "@local/nure:0.2.0": * #import "@local/nure:0.1.0": *
// ...or by importing a lib.typ directly // ...or by importing a lib.typ directly
// #import "/lib.typ": * // #import "/lib.typ": *
// 1. Setup the document // 1. Setup the document
// by setting values directly... // by setting values directly...
#show: general.with( #show: pz-lb.with(
title: "Some title", title: "Some title",
// etc: "and so on", // etc: "and so on",
// ... // ...
) )
// ...or using a doc.yaml file // ...or using a config/doc.yaml file
#show: general.with(..yaml("doc.yaml")) #show: pz-lb.with(..yaml("config/doc.yaml"))
// this template automatically inserts a `=title` // this template automatically inserts a `=title`
@ -75,7 +72,7 @@ Some text
// you have to import the package or a lib.typ inside a module. // you have to import the package or a lib.typ inside a module.
// If you ever need appendices in general template use the show rule // If you ever need appendices in pz-lb template use the show rule
// WARNING: when using coursework template use its own argument, // WARNING: when using coursework template use its own argument,
// so it can put bibliography before appendices // so it can put bibliography before appendices
#show: appendices-style #show: appendices-style
@ -89,12 +86,16 @@ Some text
### Notes: ### Notes:
1. Use `#v(-spacing)` to remove vertical spacing between titles (this cannot be automatically handled by the template). Variable `spacing` used here is imported from the template. 1. Use `#v(-spacing)` to remove vertical spacing between titles (this cannot be automatically handled by the template). Variable `spacing` used here is imported from the template.
2. When importing `@local/nure:0.2.0` and specifying file paths in functions handled by the package, the path will relative to package's root directory, e.g. setting `#show: coursework.with(bib_path: "bibl.yml")` will evaluate to `~/.local/share/typst/packages/local/nure/0.2.0/bibl.yml`, the same is for `#img` function, which makes it quite annoying and forces one to import `lib.typ` file. Please open an issue or contact us in any other way if you have any advice. 2. When importing `@local/nure:0.1.0` and specifying file paths in functions handled by the package, the path will relative to package's root directory, e.g. setting `#show: coursework.with(bib_path: "bibl.yml")` will evaluate to `~/.local/share/typst/packages/local/nure/0.1.0/bibl.yml`, the same is for `#img` function, which makes it quite annoying and forces one to import `lib.typ` file. Please open an issue or contact us in any other way if you have any advice.
### Example Project Structure ### Example Project Structure
``` ```
project/ project/
├── main.typ -- for boilerplate code and importing everything ├── main.typ -- for boilerplate code and importing everything
├── config/
│ ├── doc.yaml -- for things that don't change across works, i.e. author and mentor metadata
│ ├── universities.yaml -- for user-specific configuration, i.e. education programs and disciplines
│ └── ...
├── src/ ├── src/
│ ├── intro.typ │ ├── intro.typ
│ ├── chapter1.typ │ ├── chapter1.typ

58
config/universities.yaml Normal file
View File

@ -0,0 +1,58 @@
ХНУРЕ:
name: Харківський національний університет радіоелектроніки
edu_programs:
ПЗПІ:
name_long: Інженерія програмного забезпечення
department_gen: Програмної інженерії
code: 121 # TODO: change to F2?
КУІБ:
name_long: Управління інформаційною безпекою
department_gen: Інфокомунікаційної інженерії ім. В. В. Поповського
code: 125
КНТ:
name_long: Комп'ютерні науки та технології
department_gen: Системотехніки
code: 122
subjects:
ODS: Основи Dаtа Sсіеnсе # NOTE: Eng O here
ІМ: Іноземна мова
АКтаК: Архітектура комп'ютера та комп'ютерних мереж
АТСД: Алгоритми та структури даних
БД: Бази даних
БЖД: Безпека життєдіяльності
ВДІТБ: Введення до ІТ-бізнесу # NOTE: all in UA
ВМ: Вища математика
ГТГ: Гіпертекст та гіпермедіа
ДМ: Дискретна математика
КДМА: Комп'ютерна дискретна математика
КМ: Комп`ютерні мережі
КЗВШ: Креативність з використанням штучного інтелекту
ЛМВ: Людино-машинна взаємодія
МОТДО: Методи оптимізаціі та дослідження операцій
МС: Моделювання систем
ОІМ: Основи IP-мереж
ООП: Об'єктно-орієнтоване програмування
ОП: Основи права
ОПІ: Основи програмноі інженеріі
ОПНJ: Основи програмування на Java
ОПр: Основи програмування
ОС: Операційні системи
ОТК: Основи теорії кіл
ПНП: Програмування на платформі .NЕТ
ПП: Проектний практикум
ПРОГ: Програмування
СМП: Скриптові мови програмування
ТЙтаМ: Теорія ймовірностей та математична # TODO: what?
ТКП: Технології комп`ютерного проєктування
УФМ: Українське фахове мовлення
ФІЗ: Фізика
ФІЛ: Філософія
ФВС: Фізичне виховання та спорт
# Oleksii 6th semester
ХТ: Хмарні технології
ООАПС: Об'єктно-орієнтований аналіз в проектуванні систем
СА: Системний аналіз
МППС: Методології проектування програмних систем
ТЗІ: Технології захисту інформації
АДан: Аналітика даних
DMT: Decision making theory

321
lib.typ
View File

@ -1,14 +1,9 @@
// SPDX-License-Identifier: GPL-3.0
/*
* typst-nure-template/lib.typ
*
* Typst library for NURE (Kharkiv National University of Radio Electronics) works
*/
#import "style.typ": spacing, dstu-style, appendices-style // Academic aliases {{{1
#import "template.typ": *
// TODO: Template formatting functions {{{ #let universities = yaml("config/universities.yaml")
// Template formatting functions {{{1
/// numberless heading /// numberless heading
#let nheading(title) = heading(depth: 1, numbering: none, title) #let nheading(title) = heading(depth: 1, numbering: none, title)
@ -45,11 +40,7 @@
"грудня", "грудня",
).at(month - 1) ).at(month - 1)
// }}} // Helper functions {{{1
// TODO: Helper functions {{{
// TODO: those are dependent on path, move to separate file as a separate sublib for local usage.
/// captioned image with label derived from path: /// captioned image with label derived from path:
/// - "image.png" = @image /// - "image.png" = @image
@ -75,9 +66,9 @@
}.replace(" ", "_") }.replace(" ", "_")
let caption = if sink.pos().len() == 0 { let caption = if sink.pos().len() == 0 {
caption + " (рисунок виконано самостійно)"
} else if sink.pos().first() == none {
caption caption
} else if sink.pos().first() == none {
caption + " (рисунок виконано самостійно)"
} else { } else {
[#caption (за даними #sink.pos().first())] [#caption (за даними #sink.pos().first())]
} }
@ -88,9 +79,168 @@
) #label(label_string)] ) #label(label_string)]
} }
// }}} #let spacing = 0.95em // spacing between lines
#let num-to-alpha = "абвгдежиклмнпрстуфхцшщюя".split("") // 0 = "", 1 = "а"
// TODO: Coursework template {{{ /// DSTU 3008:2015 Style
/// -> content
/// - it (content): Content to apply the style to.
/// - skip (int): Do not show page number for this number of pages.
/// - offset (int): Adjust all page numbers by this amount.
#let dstu-style(
it,
skip: 0,
offset: 0,
) = {
// General Styling {{{1
set page(
paper: "a4",
number-align: top + right,
margin: (top: 20mm, right: 10mm, bottom: 20mm, left: 25mm),
numbering: (i, ..) => if i > skip { numbering("1", i + offset) },
)
set text(
lang: "uk",
size: 14pt,
hyphenate: false,
font: ("Times New Roman", "Liberation Serif"),
)
set par(
justify: true,
spacing: spacing,
leading: spacing,
first-line-indent: (amount: 1.25cm, all: true),
)
set block(spacing: spacing)
set underline(evade: false)
// Enums & Lists {{{1
// First level
set enum(
indent: 1.25cm,
body-indent: 0.5cm,
numbering: i => { num-to-alpha.at(i) + ")" },
)
// Second level and further nesting
show enum: it => {
set enum(indent: 0em, numbering: "1)")
it
}
// Lists are not intended for multiple levels, use `enum`
set list(indent: 1.35cm, body-indent: 0.5cm, marker: [--])
// Figures {{{1
show figure: it => {
v(spacing * 2, weak: true)
it
v(spacing * 2, weak: true)
}
set figure.caption(separator: [ -- ])
show figure.where(kind: table): set figure.caption(position: top)
show figure.caption.where(kind: table): set align(left)
// Numbering {{{1
show heading.where(level: 1): it => {
counter(math.equation).update(0)
counter(figure.where(kind: raw)).update(0)
counter(figure.where(kind: image)).update(0)
counter(figure.where(kind: table)).update(0)
it
}
set figure(numbering: i => numbering("1.1", counter(heading).get().at(0), i))
set math.equation(numbering: i => numbering(
"(1.1)",
counter(heading).get().at(0),
i,
))
// Headings {{{1
set heading(numbering: "1.1")
show heading: it => if it.level == 1 {
set align(center)
set text(size: 14pt, weight: "semibold")
pagebreak(weak: true)
upper(it)
v(spacing * 2, weak: true)
} else {
set text(size: 14pt, weight: "regular")
v(spacing * 2, weak: true)
block(width: 100%, spacing: 0em)[
#h(1.25cm)
#counter(heading).display(auto)
#it.body
]
v(spacing * 2, weak: true)
}
// Listings {{{1
show raw: it => {
let raw-spacing = 0.5em
set block(spacing: raw-spacing)
set par(spacing: raw-spacing, leading: raw-spacing)
set text(
size: 11pt,
weight: "semibold",
font: ("Courier New", "Liberation Mono"),
)
v(spacing * 2.5, weak: true)
pad(it, left: 1.25cm)
v(spacing * 2.5, weak: true)
}
it
// }}}
}
/// DSTU 3008:2015 Appendices Style
/// -> content
/// - it (content): Content to apply the style to.
#let appendices-style(it) = /* {{{ */ {
// Numbering
counter(heading).update(0)
set heading(numbering: (i, ..n) => (
upper(num-to-alpha.at(i)) + numbering(".1.1", ..n)
))
set figure(numbering: i => [#upper(num-to-alpha.at(counter(heading).get().at(0))).#i])
set math.equation(numbering: i => [(#upper(num-to-alpha.at(counter(heading).get().at(0))).#i)])
// Headings
show heading: it => if it.level == 1 {
set align(center)
set text(size: 14pt, weight: "regular")
pagebreak(weak: true)
text(weight: "bold")[ДОДАТОК #counter(heading).display(auto)]
linebreak()
it.body
v(spacing * 2, weak: true)
} else {
set text(size: 14pt, weight: "regular")
v(spacing * 2, weak: true)
block(width: 100%, spacing: 0em)[
#h(1.25cm)
#counter(heading).display(auto)
#it.body
]
v(spacing * 2, weak: true)
}
it
} // }}}
// Coursework template {{{1
/// DSTU 3008:2015 Template for NURE /// DSTU 3008:2015 Template for NURE
/// -> content /// -> content
@ -227,9 +377,7 @@
grid( grid(
columns: (1fr, 1fr, 1fr), columns: (1fr, 1fr, 1fr),
gutter: 0.3fr, gutter: 0.3fr,
[#bold[Курс] #uline(author.course)], [#bold[Курс] #uline(author.course)], [#bold[Група] #uline([#edu_program\-#author.group])], [#bold[Семестр] #uline(author.semester)],
[#bold[Група] #uline([#edu_program\-#author.group])],
[#bold[Семестр] #uline(author.semester)],
) )
linebreak() linebreak()
@ -360,8 +508,7 @@
not is_cyrillic(keywords.at(j)) and is_cyrillic(keywords.at(j + 1)) not is_cyrillic(keywords.at(j)) and is_cyrillic(keywords.at(j + 1))
) )
or ( or (
is_cyrillic(keywords.at(j)) == is_cyrillic(keywords.at(j + 1)) is_cyrillic(keywords.at(j)) == is_cyrillic(keywords.at(j + 1)) and keywords.at(j) > keywords.at(j + 1)
and keywords.at(j) > keywords.at(j + 1)
) )
) { ) {
(keywords.at(j), keywords.at(j + 1)) = ( (keywords.at(j), keywords.at(j + 1)) = (
@ -438,10 +585,7 @@
} }
context { context {
for (i, citation) in query(ref.where(element: none)) for (i, citation) in query(ref.where(element: none)).map(r => str(r.target)).dedup().enumerate() {
.map(r => str(r.target))
.dedup()
.enumerate() {
enum.item( enum.item(
i + 1, i + 1,
format-entry(bib_data.at(citation)), format-entry(bib_data.at(citation)),
@ -451,6 +595,127 @@
} }
appendices-style(appendices) appendices-style(appendices)
} // }}} }
// Practice and Laboratory works template {{{1
/// DSTU 3008:2015 Template for NURE
/// -> content
/// - doc (content): Content to apply the template to.
/// - edu_program (str): Education program shorthand.
/// - doctype ("ЛБ" | "ПЗ" | str): Document type.
/// - title (str or none): Title of the document. Optional.
/// - subject (str): Subject shorthand.
/// - worknumber (int or none): Number of the work. Optional.
/// - authors ((name: str, full_name_gen: str, group: str, gender: str, variant: int or none),): List of authors.
/// - mentors ((name: str, degree: str, gender: str or none),): List of mentors. Optional.
/// - chapters (): List of file names in chapters/ subdirectory. Optional.
#let pz-lb(
doc,
university: "ХНУРЕ",
edu_program: none,
doctype: none,
title: none,
subject: none,
worknumber: none,
authors: (),
mentors: (),
chapters: (),
) = {
assert.ne(edu_program, none, message: "Missing argument: \"edu_program\"")
assert.ne(doctype, none, message: "Missing argument: \"doctype\"")
assert.ne(subject, none, message: "Missing argument: \"subject\"")
set document(title: title, author: authors.at(0).name)
show: dstu-style.with(skip: 1)
let uni = universities.at(university)
let edu_prog = uni.edu_programs.at(edu_program)
// page 1 {{{2
align(center)[
МІНІСТЕРСТВО ОСВІТИ І НАУКИ УКРАЇНИ \
#upper(uni.name)
\ \
Кафедра #edu_prog.department_gen
\ \ \
#if doctype == "ЛБ" [Звіт \ з лабораторної роботи] else if (
doctype == "ПЗ"
) [Звіт \ з практичної роботи] else [#doctype]
#if worknumber != none {
context counter(heading).update(
worknumber - if title == none { 0 } else { 1 },
)
[№#worknumber]
} else if title != none and worknumber != none {
context counter(heading).update(1)
}
з дисципліни: "#uni.subjects.at(subject)"
#if title != none [з теми: "#title"]
\ \ \ \
#columns(2)[
#set align(left)
#set par(first-line-indent: 0pt)
#if authors.len() == 1 {
let author = authors.at(0)
if author.gender == "m" [Виконав:\ ] else [Виконала:\ ]
[
ст. гр. #edu_program\-#author.group\
#author.name\
]
if (
"variant" in author.keys() and author.variant != none
) [Варіант: #author.variant]
} else if authors.len() > 1 [
Виконали:\
ст. гр. #edu_program\-#authors.at(0).group\
#for author in authors [#author.name\ ]
]
#colbreak()
#set align(right)
#if type(mentors) == array {
if mentors.len() == 1 {
let mentor = mentors.at(0)
if "gender" in mentor.keys() {
if mentor.gender == "m" [Перевірив:\ ] else if (
mentor.gender == "f"
) [Перевірила:\ ]
} else [Перевірили:\ ]
if (
"degree" in mentor.keys() and mentor.degree != none
) [#mentor.degree\ ]
[#mentor.name\ ]
} else if mentors.len() > 1 [
Перевірили:\
#for mentor in mentors {
[
#mentor.degree\
#mentor.name\
]
}
]
}
]
#v(1fr)
Харків -- #datetime.today().display("[year]")
]
pagebreak(weak: true)
if title != none [#heading(title)]
doc
chapters.map(chapter => include "/chapters/" + str(chapter) + ".typ").join()
}
// vim:sts=2:sw=2:fdl=0:fdm=marker:cms=/*%s*/ // vim:sts=2:sw=2:fdl=0:fdm=marker:cms=/*%s*/

160
style.typ
View File

@ -1,160 +0,0 @@
// SPDX-License-Identifier: GPL-3.0
/*
* style.typ: Styles beneficial beyond the typst-nure-template
*/
#let spacing = 0.95em // spacing between lines
#let num-to-alpha = "абвгдежиклмнпрстуфхцшщюя".split("") // 0 = "", 1 = "а"
/// DSTU 3008:2015 Style
/// -> content
/// - it (content): Content to apply the style to.
/// - skip (int): Do not show page number for this number of pages.
/// - offset (int): Adjust all page numbers by this amount.
#let dstu-style(
it,
skip: 0,
offset: 0,
) = {
// General Styling {{{1
set page(
paper: "a4",
number-align: top + right,
margin: (top: 20mm, right: 10mm, bottom: 20mm, left: 25mm),
numbering: (i, ..) => if i > skip { numbering("1", i + offset) },
)
set text(
lang: "uk",
size: 14pt,
hyphenate: false,
font: ("Times New Roman", "Liberation Serif"),
)
set par(
justify: true,
spacing: spacing,
leading: spacing,
first-line-indent: (amount: 1.25cm, all: true),
)
set block(spacing: spacing)
set underline(evade: false)
// Enums & Lists {{{1
// First level
set enum(
indent: 1.25cm,
body-indent: 0.5cm,
numbering: i => { num-to-alpha.at(i) + ")" },
)
// Second level and further nesting
show enum: it => {
set enum(indent: 0em, numbering: "1)")
it
}
// Lists are not intended for multiple levels, use `enum`
set list(indent: 1.35cm, body-indent: 0.5cm, marker: [--])
// Figures {{{1
show figure: it => {
v(spacing * 2, weak: true)
it
v(spacing * 2, weak: true)
}
set figure.caption(separator: [ -- ])
show figure.where(kind: table): set figure.caption(position: top)
show figure.caption.where(kind: table): set align(left)
// Numbering {{{1
show heading.where(level: 1): it => {
counter(math.equation).update(0)
counter(figure.where(kind: raw)).update(0)
counter(figure.where(kind: image)).update(0)
counter(figure.where(kind: table)).update(0)
it
}
set figure(numbering: i => numbering("1.1", counter(heading).get().at(0), i))
set math.equation(numbering: i => numbering("(1.1)", counter(heading).get().at(0), i))
// Headings {{{1
set heading(numbering: "1.1")
show heading: it => if it.level == 1 {
set align(center)
set text(size: 14pt, weight: "semibold")
pagebreak(weak: true)
upper(it)
v(spacing * 2, weak: true)
} else {
set text(size: 14pt, weight: "regular")
v(spacing * 2, weak: true)
block(width: 100%, spacing: 0em)[
#h(1.25cm)
#counter(heading).display(auto)
#it.body
]
v(spacing * 2, weak: true)
}
// Listings {{{1
show raw: it => {
let raw-spacing = 0.5em
set block(spacing: raw-spacing)
set par(spacing: raw-spacing, leading: raw-spacing)
set text(
size: 11pt,
weight: "semibold",
font: ("Courier New", "Liberation Mono"),
)
v(spacing * 2.5, weak: true)
pad(it, left: 1.25cm)
v(spacing * 2.5, weak: true)
}
it
// }}}
}
/// DSTU 3008:2015 Appendices Style
/// -> content
/// - it (content): Content to apply the style to.
#let appendices-style(it) = /* {{{ */ {
// Numbering
counter(heading).update(0)
set heading(numbering: (i, ..n) => upper(num-to-alpha.at(i)) + numbering(".1.1", ..n))
set figure(numbering: i => [#upper(num-to-alpha.at(counter(heading).get().at(0))).#i])
set math.equation(numbering: i => [(#upper(num-to-alpha.at(counter(heading).get().at(0))).#i)])
// Headings
show heading: it => if it.level == 1 {
set align(center)
set text(size: 14pt, weight: "regular")
pagebreak(weak: true)
text(weight: "bold")[ДОДАТОК #counter(heading).display(auto)]
linebreak()
it.body
v(spacing * 2, weak: true)
} else {
set text(size: 14pt, weight: "regular")
v(spacing * 2, weak: true)
block(width: 100%, spacing: 0em)[
#h(1.25cm)
#counter(heading).display(auto)
#it.body
]
v(spacing * 2, weak: true)
}
it
} // }}}
// vim:sts=2:sw=2:fdl=0:fdm=marker:cms=/*%s*/

View File

@ -1,125 +0,0 @@
// SPDX-License-Identifier: GPL-3.0
/*
* typst-nure-template/template.typ
*
* Typst templates for NURE (Kharkiv National University of Radio Electronics) works
*/
#import "style.typ": spacing, dstu-style, appendices-style
// Practice and Laboratory works template {{{
/// DSTU 3008:2015 Template for NURE
/// -> content
/// - it (content): Content to apply the template to.
/// - department (str): Education program name.
/// - work_type (str): Work type, i.e. "з лабораторної роботи".
/// - number (int | none): Number of the work. Optional.
/// - subject (str): Subject name.
/// - title (str | none): Title of the work and the document. Optional.
/// - variant (int | none): Variant of the work. Optional.
/// - author ((name: str, group: (str | none), gender: ("m" | "f" | none)),):
/// List of authors. Single author may be passed as a dictionary. Other types will be displayed like content.
/// - mentor ((name: str, degree: (str | none), gender: ("m" | "f" | none)),):
/// List of mentors. Single mentor may be passed as a dictionary. Other types will be displayed like content.
#let general(
it,
department: none,
work_type: none,
number: none,
subject: none,
title: none,
variant: none,
author: (),
mentor: (),
year: datetime.today().display("[year]"),
) = {
if type(author) == array and author.len() == 1 { author = author.at(0) }
if type(mentor) == array and mentor.len() == 1 { mentor = mentor.at(0) }
set document(
title: title,
author: if type(author) == array {
author.map(a => a.name)
} else if type(author) == dictionary { author.name } else { "" },
)
show: dstu-style.with(skip: 1)
align(center)[
МІНІСТЕРСТВО ОСВІТИ І НАУКИ УКРАЇНИ
ХАРКІВСЬКИЙ НАЦІОНАЛЬНИЙ УНІВЕРСИТЕТ РАДІОЕЛЕКТРОНІКИ
\ \ \
Кафедра #department
\ \ \ \
Звіт
#work_type #if number != none [
#number
#counter(heading).update(number - if title != none { 1 } else { 0 })
]
з дисципліни: "#subject"
#if title != none [з теми: "#title"]
\ \ \ \
#columns(2)[
#set par(first-line-indent: 0pt)
//
#set align(left)
//
#if type(author) == dictionary [
#if "gender" in author and author.gender != none {
if author.gender == "m" [Виконав:] else [Виконала:]
} else [Виконали:]
#if "group" in author [ст. гр. #author.group\ ]
#author.name\
#if variant != none [Варіант: #variant]
] else if type(author) == array [
Виконали:
#for a in author [
#if "group" in a [ст. гр. #a.group\ ]
#a.name\
]
#if variant != none [Варіант: #variant]
] else { author } // custom formatting
//
#colbreak()
//
#set align(right)
//
#if type(mentor) == dictionary [
#if "gender" in mentor and mentor.gender != none {
if mentor.gender == "m" [Перевірив:] else [Перевірила:]
} else [Перевірили:]
#if "degree" in mentor and mentor.degree != none [#mentor.degree\ ]
#mentor.name
] else if type(mentor) == array [
Перевірили:
#for m in mentor [
#if "degree" in m [#m.degree\ ]
#m.name\
]
] else { mentor } // custom formatting
]
#v(1fr)
Харків -- #year
]
pagebreak(weak: true)
if title != none { heading(title) }
it
} // }}}
// vim:sts=2:sw=2:fdl=0:fdm=marker:cms=/*%s*/

22
template/config/doc.yaml Normal file
View File

@ -0,0 +1,22 @@
title: Потiк керування та алгоритмічні структури Bash
subject: СМП
doctype: ЛБ
worknumber: 2
mentors:
- name: Шевченко Т. Г.
degree: Доцент кафедри ПІ
gender: m
- name: Франко І. Я.
degree: Асистент кафедри ПІ
gender: m
edu_program: &EDU ПЗПІ
university: ХНУРЕ
authors:
- name: Косач Л. П.
full_name_gen: Косач Лариси Петрівни
course: 2
edu: *EDU
gender: f
group: 23-2
semester: 4
variant: 8

View File

@ -1,4 +1,4 @@
#import "@local/nure:0.2.0": * #import "@local/nure:0.1.0": *
#let author = ( #let author = (
name: "Ситник Є. С.", name: "Ситник Є. С.",

View File

@ -1,21 +1,6 @@
#import "@local/nure:0.2.0": * #import "@local/nure:0.1.0": *
#show: general.with( #show: pz-lb.with(..yaml("config/doc.yaml"))
department: "Програмної інженерії",
work_type: "з лабораторної роботи",
number: 3,
subject: "Операційні системи",
title: "Керування зовнішніми пристроями. Нестандартні пристрої",
author: (
(name: "Шевчентко Т. Г.", group: "ПЗПІ-23-0"),
(name: "Косач Л. П."),
),
mentor: (
gender: "m",
name: "Франко І. Я.",
degree: "доц. каф. ПІ",
),
)
#v(-spacing) #v(-spacing)

View File

@ -1,6 +1,6 @@
[package] [package]
name = "nure" name = "nure"
version = "0.2.0" version = "0.1.0"
entrypoint = "lib.typ" entrypoint = "lib.typ"
authors = ["linerds"] authors = ["linerds"]
license = "GPL-3.0" license = "GPL-3.0"