diff --git a/.gitignore b/.gitignore index a136337..08774c2 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ *.pdf +test +config diff --git a/README.md b/README.md index c4ac99a..a459123 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ +> [!CAUTION] +> Experimental fork. Successfully **breaking** stuff each commit. Documentation is **not** up to date. + # Typst Template for NURE Works ![pz-lb title page](assets/pz-lb_title_page.png) @@ -7,7 +10,7 @@ This project contains two template functions and some utilities for writing NURE ### Templates -#### `pz-lb` - For Practice and Laboratory Works +#### `general` - For general works This template: - Sets up document styles; - Formats the title page according to NURE/DSTU guidelines. @@ -49,13 +52,13 @@ Copy `lib.typ` to your project's root directory. // 1. Setup the document // by setting values directly... -#show: pz-lb.with( +#show: general.with( title: "Some title", // etc: "and so on", // ... ) -// ...or using a config/doc.yaml file -#show: pz-lb.with(..yaml("config/doc.yaml")) +// ...or using a doc.yaml file +#show: general.with(..yaml("doc.yaml")) // this template automatically inserts a `=title` @@ -72,7 +75,7 @@ Some text // you have to import the package or a lib.typ inside a module. -// If you ever need appendices in pz-lb template use the show rule +// If you ever need appendices in general template use the show rule // WARNING: when using coursework template use its own argument, // so it can put bibliography before appendices #show: appendices-style @@ -92,10 +95,6 @@ Some text ``` project/ ├── 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/ │ ├── intro.typ │ ├── chapter1.typ diff --git a/config/universities.yaml b/config/universities.yaml deleted file mode 100644 index 57c4048..0000000 --- a/config/universities.yaml +++ /dev/null @@ -1,46 +0,0 @@ -ХНУРЕ: - name: Харківський національний університет радіоелектроніки - edu_programs: - ПЗПІ: - name_long: Інженерія програмного забезпечення - department_gen: Програмної інженерії - code: 121 # TODO: change to F2? - КУІБ: - name_long: Управління інформаційною безпекою - department_gen: Інфокомунікаційної інженерії ім. В. В. Поповського - code: 125 - subjects: - ODS: Основи Dаtа Sсіеnсе # NOTE: Eng O here - ІМ: Іноземна мова - АКтаК: Архітектура комп'ютера та комп'ютерних мереж - АТСД: Алгоритми та структури даних - БД: Бази даних - БЖД: Безпека життєдіяльності - ВДІТБ: Введення до ІТ-бізнесу # NOTE: all in UA - ВМ: Вища математика - ГТГ: Гіпертекст та гіпермедіа - ДМ: Дискретна математика - КДМА: Комп'ютерна дискретна математика - КМ: Комп`ютерні мережі - КЗВШ: Креативність з використанням штучного інтелекту - ЛМВ: Людино-машинна взаємодія - МОТДО: Методи оптимізаціі та дослідження операцій - МС: Моделювання систем - ОІМ: Основи IP-мереж - ООП: Об'єктно-орієнтоване програмування - ОП: Основи права - ОПІ: Основи програмноі інженеріі - ОПНJ: Основи програмування на Java - ОПр: Основи програмування - ОС: Операційні системи - ОТК: Основи теорії кіл - ПНП: Програмування на платформі .NЕТ - ПП: Проектний практикум - ПРОГ: Програмування - СМП: Скриптові мови програмування - ТЙтаМ: Теорія ймовірностей та математична # TODO: what? - ТКП: Технології комп`ютерного проєктування - УФМ: Українське фахове мовлення - ФІЗ: Фізика - ФІЛ: Філософія - ФВС: Фізичне виховання та спорт \ No newline at end of file diff --git a/lib.typ b/lib.typ index 9cde572..3239fcf 100644 --- a/lib.typ +++ b/lib.typ @@ -2,16 +2,13 @@ /* * typst-nure-template/lib.typ * - * Typst template for NURE (Kharkiv National University of Radio Electronics) works + * Typst library for NURE (Kharkiv National University of Radio Electronics) works */ #import "style.typ": spacing, dstu-style, appendices-style +#import "template.typ": * -// Academic aliases {{{1 - -#let universities = yaml("config/universities.yaml") - -// Template formatting functions {{{1 +// TODO: Template formatting functions {{{ /// numberless heading #let nheading(title) = heading(depth: 1, numbering: none, title) @@ -48,7 +45,11 @@ "грудня", ).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: /// - "image.png" = @image @@ -87,7 +88,9 @@ ) #label(label_string)] } -// Coursework template {{{1 +// }}} + +// TODO: Coursework template {{{ /// DSTU 3008:2015 Template for NURE /// -> content @@ -448,110 +451,6 @@ } appendices-style(appendices) -} - -// Practice and Laboratory works template {{{1 - -/// DSTU 3008:2015 Template for NURE -/// -> content -/// - doc (content): Content to apply the template to. -/// - doctype ("ЛБ" | "ПЗ"): Document type. -/// - edu_program (str): Education program shorthand. -/// - title (str): Title of the document. -/// - subject (str): Subject shorthand. -/// - 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. -/// - worknumber (int or none): Number of the work. Optional. -#let pz-lb( - doc, - doctype: none, - university: "ХНУРЕ", - edu_program: none, - title: none, - subject: none, - worknumber: none, - authors: (), - mentors: (), -) = { - 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 worknumber != none { - context counter(heading).update(worknumber - if title == none { 0 } else { 1 }) - [№#worknumber] - } - - з дисципліни: "#uni.subjects.at(subject, default: "UNKNOWN SUBJECT, PLEASE OPEN AN ISSUE")" - - #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 [ - Виконали:\ - ст. гр. #edu_program\-#authors.at(0).group\ - #for author in authors [#author.name\ ] - ] - - #colbreak() - #set align(right) - - #if mentors.len() == 1 { - let mentor = mentors.at(0) - if mentor.gender == none [Перевірили:\ ] else if ( - mentor.gender == "m" - ) [Перевірив:\ ] else [Перевірилa:\ ] - [ - #if mentor.degree != none [#mentor.degree\ ] - #mentor.name\ - ] - } else [ - Перевірили:\ - #for mentor in mentors { - [ - #mentor.degree\ - #mentor.name\ - ] - } - ] - ] - - #v(1fr) - - Харків -- #datetime.today().display("[year]") - ] - - pagebreak(weak: true) - - if title != none [#heading(title)] - - doc -} +} // }}} // vim:sts=2:sw=2:fdl=0:fdm=marker:cms=/*%s*/ diff --git a/style.typ b/style.typ index 3b19e8d..703ae78 100644 --- a/style.typ +++ b/style.typ @@ -145,13 +145,14 @@ v(spacing * 2.5, weak: true) } - it // }}} + it + // }}} } /// DSTU 3008:2015 Appendices Style /// -> content /// - it (content): Content to apply the style to. -#let appendices-style(it) = /* {{{1 */ { +#let appendices-style(it) = /* {{{ */ { counter(heading).update(0) set heading(numbering: (i, ..n) => upper(num-to-alpha.at(i)) + numbering(".1.1", ..n)) diff --git a/template.typ b/template.typ new file mode 100644 index 0000000..1f58605 --- /dev/null +++ b/template.typ @@ -0,0 +1,125 @@ +// 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*/ diff --git a/template/config/doc.yaml b/template/config/doc.yaml deleted file mode 100644 index e1844d5..0000000 --- a/template/config/doc.yaml +++ /dev/null @@ -1,22 +0,0 @@ -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 diff --git a/template/lab.typ b/template/lab.typ index b344add..0cb298e 100644 --- a/template/lab.typ +++ b/template/lab.typ @@ -1,6 +1,21 @@ #import "@local/nure:0.2.0": * -#show: pz-lb.with(..yaml("config/doc.yaml")) +#show: general.with( + department: "Програмної інженерії", + work_type: "з лабораторної роботи", + number: 3, + subject: "Операційні системи", + title: "Керування зовнішніми пристроями. Нестандартні пристрої", + author: ( + (name: "Шевчентко Т. Г.", group: "ПЗПІ-23-0"), + (name: "Косач Л. П."), + ), + mentor: ( + gender: "m", + name: "Франко І. Я.", + degree: "доц. каф. ПІ", + ), +) #v(-spacing)