Compare commits

29 Commits

Author SHA1 Message Date
f36b513a2d docs(README): fix installation instructions 2025-03-01 10:53:53 +02:00
d7c26debfd fix: package entry point 2025-03-01 01:26:50 +02:00
f940d16e06 fix: imports 2025-03-01 01:26:38 +02:00
09b4d3aa44 feat(README): added instructions for local typst package setup 2025-03-01 01:15:13 +02:00
0d526d4f58 feat: restructured files accrording to typst package format
- added typst.toml
- moved templates to "template" folder
- renamed files according to convention
2025-03-01 01:10:05 +02:00
efa56f1fec feat(style func): added show rules for heading(level: 3) 2025-02-27 11:54:31 +02:00
0e6f2ce25e docs: improve code examples 2025-02-27 08:49:47 +02:00
394d4b1fcf minor syntactic changes 2025-02-25 10:20:20 +02:00
09fc15a8c9 reimplement appendices 2025-02-21 15:06:28 +02:00
a761f36a02 removed typst-13 warning from readme 2025-02-20 00:19:23 +02:00
b12627d888 fixed calendar plan signature indent 2025-02-19 16:08:24 +02:00
2d67b11f48 pass named arguments for img to image 2025-02-17 18:23:36 +02:00
c2fd8f6ad0 fix image and table count 2025-02-16 21:43:16 +02:00
63720d0068 remove italics from bibliography 2025-02-15 12:06:01 +02:00
8cabd1c779 fix bibliography indent 2025-02-15 10:02:04 +02:00
a6ec38abee reorganize a bit 2025-02-15 09:26:27 +02:00
bc78371fce add fold-markers 2025-02-15 00:30:50 +02:00
612e70a897 fixed authors list 2025-02-14 23:48:59 +02:00
67dc761845 updated readme and lab template to 0.13 2025-02-14 23:48:47 +02:00
b3c0a466f7 make img func source arg optional 2025-02-14 15:53:22 +02:00
e1354921f3 update README.md 2025-02-14 11:44:18 +02:00
84e83c6f39 change text.font.lang from ua to uk
May also need to rework bibliography handling.
2025-02-14 09:37:11 +02:00
9758b54735 fixed par indent 2025-02-14 01:48:47 +02:00
f2833b62c6 added general info and removed unnecessary code 2025-02-14 01:48:34 +02:00
003f327c71 fix image & reference numbering 2025-02-13 22:20:05 +02:00
c9e56a75b1 add source to img function 2025-02-13 19:32:38 +02:00
eab40dfbfb make Times New Roman the default font 2025-02-13 12:40:11 +02:00
36208ab7a8 Merge pull request 'fix initial_date' (#6) from 0x1D8/typst_nure_template:main into main
Reviewed-on: #6
2025-02-13 11:41:01 +02:00
ab418ea1ec fix intial_date 2025-02-13 08:24:40 +02:00
8 changed files with 283 additions and 206 deletions

View File

@ -1,14 +1,8 @@
# Typst Template for NURE Works
> [!INFO]
> Needs more work, but it is functional and ready for use.
## TODO
- Add more information about the template.
## General Info
This project contains two template functions and some utilities for writing NURE works. All functions include documentation comments inside them, so you can explore all possibilities using LSP/IntelliSense.
This project contains two template functions and some utilities for writing NURE works. All functions include documentation comments inside them, so you can explore all possibilities using LSP.
### Templates
@ -32,26 +26,37 @@ This template:
## Usage
To use the template, include it in your project and utilize the provided functions:
### As a local typst package
1. Clone this repository into ~/.local/share/typst/packages/:
```bash
git clone https://gitea.linerds.us/pencelheimer/typst_nure_template.git ~/.local/share/typst/packages/local/nure/0.0.0
```
2. Init your project with Typst:
```bash
typst init @local/nure:0.0.0 project-name
```
### As a file in your project
Include lib.typ in your project and utilize the provided functions:
```typst
#import "path/to/template.typ": * // Import the template
#import "@preview/indenta:0.0.3": fix-indent // Import indentation fix utility
// Import the template
#import "lib.typ": *
#show: pz-lb-template.with(
// Setup the document
#show: lab-pz-template.with(
title: "Some title",
)
// this template automatically inserts a `=title`
#show: fix-indent()
#v(-spacing)
// Write your content
#v(-spacing) // remove spacing between headings
== Purpose
Some text
```
### Notes:
1. You must use the `fix-indent` function from `@preview/indenta` to correct indentation after the title.
2. Use `#v(-spacing)` to remove vertical spacing between titles (this cannot be automatically handled by the template). Notice that the `spacing` variable 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.
### Example Project Structure
```
@ -64,4 +69,3 @@ project-folder/
│ ├── ...
├── ...
```
This setup ensures that `main.typ` includes and applies the template correctly.

Binary file not shown.

Binary file not shown.

View File

@ -1,4 +1,26 @@
// Academic aliases {{{1
/// subject abbreviations to full names
#let subjects = (
"БД": "Бази даних",
"ОПНJ": "Основи програмування на Java",
"ОС": "Операційні системи",
"ПП": "Проектний практикум",
"СПМ": "Скриптові мови програмування",
"Ф": "Філософія",
)
/// education program abbreviations to name & number
#let edu_programs = (
"ПЗПІ": (
name: "Інженерія програмного забезпечення",
number: 121, // TODO: ПЗПІ is "F2" now
),
)
// Template formatting functions {{{1
/// numberless heading
#let nheading(title) = heading(depth: 1, numbering: none, title)
@ -15,47 +37,7 @@
/// bold text
#let bold(content) = text(weight: "bold")[#content]
/// captioned image with label derived from path:
/// - `image.png` = @image
/// - `img/image.png` = @image
/// - `img/foo/image.png` = @foo_image
/// - `img/foo/foo_image.png` = @foo_image
#let img(path, caption) = [
#let parts = path.split(".").first().split("/")
#figure(
image(path),
caption: caption,
)
#label(
if parts.len() <= 2 or parts.at(-1).starts-with(parts.at(-2)) {
// ("image",), (_, "image") and (.., "img", "img_image")
parts.last()
} else {
// (.., "img", "image") = "img_image"
parts.at(-2) + "_" + parts.at(-1)
}.replace(" ", "_"),
)
]
/// subjects list
#let subjects = (
"БД": "Бази даних",
"ОПНJ": "Основи програмування на Java",
"ОС": "Операційні системи",
"ПП": "Проектний практикум",
"СПМ": "Скриптові мови програмування",
"Ф": "Філософія",
)
/// education programs list
#let edu_programs = (
"ПЗПІ": (
name: "Інженерія програмного забезпечення",
number: 121,
),
)
/// month name from its number
#let month_gen(month) = (
"січня",
"лютого",
@ -71,7 +53,46 @@
"грудня",
).at(month - 1)
/// spacing between lines
// Helper functions {{{1
/// captioned image with label derived from path:
/// - "image.png" = @image
/// - "img/image.png" = @image
/// - "img/foo/image.png" = @foo_image
/// - "img/foo/foo_image.png" = @foo_image
/// the caption will be modified based on a conditional positional value:
/// - `none`: no change
/// - some value: "`caption` (за даними `value`)"
/// - no value: "`caption` (рисунок виконано самостійно)"
/// additional named arguments will be passed to original `image` function
#let img(path, caption, ..sink) = {
let parts = path.split(".").first().split("/")
let label_string = if parts.len() <= 2 or parts.at(-1).starts-with(parts.at(-2)) {
// ("image",), (_, "image") and (.., "img", "img_image")
parts.last()
} else {
// (.., "img", "image") = "img_image"
parts.at(-2) + "_" + parts.at(-1)
}.replace(" ", "_")
let caption = if sink.pos().len() == 0 {
caption + " (рисунок виконано самостійно)"
} else if sink.pos().first() == none {
caption
} else {
[#caption (за даними #sink.pos().first())]
}
[#figure(image(path, ..sink.named()), caption: caption) #label(label_string)]
}
// Styling {{{1
/// NOTE: may be wrong
#let ua_alpha_numbering = "абвгдежиклмнпрстуфхцшщюя".split("") // 0 = "", 1 = "а"
// general outlook {{{2
// spacing between lines
#let spacing = 0.95em
#let style(it) = {
@ -86,8 +107,8 @@
},
)
set text(font: "Liberation Serif", size: 14pt, hyphenate: false, lang: "ua")
set par(justify: true, first-line-indent: 1.25cm)
set text(font: ("Times New Roman", "Liberation Serif"), size: 14pt, hyphenate: false, lang: "uk")
set par(justify: true, first-line-indent: (amount: 1.25cm, all: true))
set underline(evade: false)
// set 1.5 line spacing
@ -95,17 +116,8 @@
set par(spacing: spacing)
set par(leading: spacing)
// enums and lists
let ua_alph_numbering() = {
// INFO: This alphabet is not full, maybe it should be extended or maybe not.
// I cant remember nor find proper formatting rules.
// "абвгґдеєжзиіїйклмнопрстуфхцчшщьюя" (full alphabet)
let alphabet = "абвгдежиклмнпрстуфхцшщюя".split("")
i => { alphabet.at(i) + ")" }
}
set enum(numbering: ua_alph_numbering(), indent: 1.25cm, body-indent: 0.5cm)
// enums and lists {{{2
set enum(numbering: i => { ua_alpha_numbering.at(i) + ")" }, indent: 1.25cm, body-indent: 0.5cm)
show enum: it => {
set enum(indent: 0em, numbering: "1)")
it
@ -113,65 +125,56 @@
set list(indent: 1.35cm, body-indent: 0.5cm, marker: [--])
// figures
set figure.caption(separator: [ -- ])
show figure.where(kind: table): set figure.caption(position: top)
show figure.caption.where(kind: table): set align(left)
let img = counter("image")
let tab = counter("table")
show figure.where(kind: image): set figure(
numbering: (..) => {
img.step()
context str(counter(heading).get().at(0)) + "." + context img.display()
},
)
show figure.where(kind: table): set figure(
numbering: (..) => {
tab.step()
context str(counter(heading).get().at(0)) + "." + context tab.display()
},
)
// appearance of references to images and tables
show ref: it => {
let el = it.element
if el == none or not el.has("kind") {
return it
}
let el_name = if el.kind == image {
"рис."
} else if el.kind == table {
"таблицю"
} else {
return it
}
link(
el.location(),
[(див. #el_name #numbering(el.numbering))],
)
}
// TODO: Maybe this will be better. Must be investigated.
//
// set math.equation(numbering: (..num) =>
// numbering("(1.1)", counter(heading).get().first(), num.pos().first())
// )
// set figure(numbering: (..num) =>
// numbering("1.1", counter(heading).get().first(), num.pos().first())
// )
// figures {{{2
show figure: it => {
v(spacing * 2, weak: true)
it
v(spacing * 2, weak: true)
}
// headings
set figure.caption(separator: [ -- ])
show figure.where(kind: table): set figure.caption(position: top)
show figure.caption.where(kind: table): set align(left)
// figure numbering
show heading.where(level: 1): it => {
counter(math.equation).update(0)
counter(figure.where(kind: image)).update(0)
counter(figure.where(kind: table)).update(0)
counter(figure.where(kind: raw)).update(0)
it
}
set math.equation(numbering: (..num) => numbering("(1.1)", counter(heading).get().at(0), num.pos().first()))
set figure(numbering: (..num) => numbering("1.1", counter(heading).get().at(0), num.pos().first()))
// appearance of references to images and tables {{{2
set ref(
supplement: it => {
if it == none or not it.has("kind") {
it
} else if it.kind == image {
"див. рис."
} else if it.kind == table {
"див. таблицю"
} else {
it
}
},
)
show ref: it => {
let el = it.element
if el == none or not el.has("kind") {
return it
}
if el.kind != image and el.kind != table {
return it
}
[(#it)]
}
// headings {{{2
set heading(numbering: "1.1")
show heading.where(level: 1): it => {
@ -194,7 +197,19 @@
v(spacing * 2, weak: true)
}
// listings
show heading.where(level: 3): it => {
set text(size: 14pt, weight: "regular")
v(spacing * 2, weak: true)
block(width: 100%, spacing: 0em)[
#h(1.25cm)
#counter(heading).display(it.numbering)
#it.body
]
v(spacing * 2, weak: true)
}
// listings {{{2
show raw: it => {
let new_spacing = 0.5em
set block(spacing: new_spacing)
@ -212,6 +227,8 @@
it
}
// Coursework template {{{1
/// DSTU 3008:2015 Template for NURE
/// -> content
/// - doc (content): Content to apply the template to.
@ -221,11 +238,11 @@
/// - authors ((name: str, full_name_gen: str, variant: int, group: str, gender: str),): List of Authors dicts.
/// - mentors ((name: str, gender: str, degree: str),): List of mentors dicts.
/// - edu_program_shorthand (str): Education program shorthand.
/// - task_list (done_date: datetime, initial_data: datetime, source: (content | str), content: (content | str), graphics: (content | str)): Task list object.
/// - task_list (done_date: datetime, initial_date: datetime, source: (content | str), content: (content | str), graphics: (content | str)): Task list object.
/// - calendar_plan ( plan_table: (content | str), approval_date: datetime): Calendar plan object.
/// - abstract (keywords: (str, ), text: (content | str)): Abstract object.
/// - bib_path path: Path to the bibliography yaml file.
/// - appendices ((title: str, content: content, ): List of appendices objects.
/// - appendices (content): Content with appendices.
#let cw-template(
doc,
title: "NONE",
@ -258,7 +275,7 @@
let head_mentor = mentors.at(0)
let edu_program = edu_programs.at(edu_program_shorthand)
// page 1
// page 1 {{{2
[
#set align(center)
МІНІСТЕРСТВО ОСВІТИ І НАУКИ УКРАЇНИ
@ -325,22 +342,21 @@
#pagebreak()
]
//
// page 2
// page 2 {{{2
{
uline([Харківський національний університет радіоелектроніки])
uline[Харківський національний університет радіоелектроніки]
linebreak()
linebreak()
grid(
columns: (100pt, 1fr),
bold([
bold[
Кафедра
Дисципліна
Спеціальність
]),
],
{
uline(align: left, department_gen)
linebreak()
@ -352,7 +368,7 @@
grid(
columns: (1fr, 1fr, 1fr),
gutter: 0.3fr,
[#bold("Курс") #uline(2)], [#bold("Група") #uline(author.group)], [#bold("Семестр") #uline(3)],
[#bold[Курс] #uline(2)], [#bold[Група] #uline(author.group)], [#bold[Семестр] #uline(3)],
)
linebreak()
@ -397,17 +413,18 @@
linebreak()
{
bold[\6. Строк здачі закінченої роботи:]
uline(task_list.done_date.display("[day].[month].[year]"))
bold[\6. Дата видачі завдання:]
uline(task_list.initial_date.display("[day].[month].[year]"))
hfill(10fr)
}
pagebreak()
}
// page 3
// page 3 {{{2
{
align(center, bold[КАЛЕНДАРНИЙ ПЛАН])
set par(first-line-indent: 0pt)
linebreak()
@ -445,22 +462,25 @@
pagebreak()
}
// page 4 {{{
// page 4 {{{2
[
#align(center, bold([РЕФЕРАТ])) \
#align(center, bold[РЕФЕРАТ]) \
#context [
#let pages = counter(page).final().at(0)
#let tables = counter("table").final().at(0)
#let images = counter("image").final().at(0)
#let images = query(figure.where(kind: image)).len()
#let tables = query(figure.where(kind: table)).len()
#let bibs = bib-count.final().dedup().len()
/* TODO: why this stopped working?
#let tables = counter(figure.where(kind: table)).final().at(0)
#let images = counter(figure.where(kind: image)).final().at(0)*/
#let counters = ()
#if pages != 0 { counters.push([#pages с.]) }
#if tables != 0 { counters.push([#tables табл.]) }
#if images != 0 { counters.push([#images рис.]) }
#if bibs != 0 { counters.push([#bibs джерел]) }
#if pages != 0 { counters.push[#pages с.] }
#if tables != 0 { counters.push[#tables табл.] }
#if images != 0 { counters.push[#images рис.] }
#if bibs != 0 { counters.push[#bibs джерел] }
Пояснювальна записка до курсової роботи: #counters.join(", ").
]
@ -492,9 +512,8 @@
#abstract.text
]
// }}}
// page 5
// page 5 {{{2
outline(
title: [
ЗМІСТ
@ -506,7 +525,7 @@
doc
// bibliography
// bibliography {{{2
{
heading(depth: 1, numbering: none)[Перелік джерел посилання]
@ -529,7 +548,7 @@
)
[
#citation.title.
_#{citation.author}_.
#citation.author.
URL: #citation.url.value (дата звернення: #date.display("[day].[month].[year]")).
]
} else if citation.type == "Book" [
@ -539,11 +558,12 @@
#citation.date.
#citation.page-total c.
] else [
UNSUPPORTED BIBLIOGRAPHY ENTRY TYPE, PLEASE OPEN THE ISSUE
UNSUPPORTED BIBLIOGRAPHY ENTRY TYPE, PLEASE OPEN AN ISSUE
]
}
show enum.item: it => {
set par(first-line-indent: 0pt)
box(width: 1.25cm)
box(width: 1em + 0.5cm)[#it.number.]
it.body
@ -560,33 +580,48 @@
}
}
// appendices
// appendices {{{2
{
counter(heading).update(0)
for (i, appendix) in appendices.enumerate() [
#set heading(
numbering: i => [
Додаток #"АБВГДЕЖИКЛМНПРСТУФХЦШЩЮЯ".split("").at(i)
],
)
set heading(
numbering: (i, ..nums) => {
let char = upper(ua_alpha_numbering.at(i))
if nums.pos().len() == 0 { char } else {
char + "." + nums.pos().map(str).join(".")
}
},
)
#show heading: it => {
set align(center)
set text(size: 14pt, weight: "regular")
show heading.where(level: 1): it => {
set align(center)
set text(size: 14pt, weight: "regular")
pagebreak(weak: true)
bold(upper(counter(heading).display(it.numbering)))
linebreak()
it.body
v(spacing * 2, weak: true)
}
#heading(appendix.title)
#appendix.content
]
pagebreak(weak: true)
bold[ДОДАТОК #counter(heading).display(it.numbering)]
linebreak()
it.body
v(spacing * 2, weak: true)
}
show heading.where(level: 2): it => {
set text(size: 14pt, weight: "regular")
v(spacing * 2, weak: true)
block(width: 100%, spacing: 0em)[
#h(1.25cm)
#counter(heading).display(it.numbering)
#it.body
]
v(spacing * 2, weak: true)
}
appendices
}
}
// Laboratory work template {{{1
/// DSTU 3008:2015 Template for NURE
/// -> content
/// - doc (content): Content to apply the template to.
@ -613,6 +648,7 @@
context counter(heading).update(worknumber - 1)
// page 1 {{{2
align(center)[
МІНІСТЕРСТВО ОСВІТИ І НАУКИ УКРАЇНИ \
ХАРКІВСЬКИЙ НАЦІОНАЛЬНИЙ УНІВЕРСИТЕТ РАДІОЕЛЕКТРОНІКИ
@ -626,7 +662,7 @@
#if doctype == "ЛБ" [лабораторної роботи] else [практичної роботи]
#if worknumber != none [ #worknumber]
з дисципліни: "#subjects.at(subject_shorthand, default: "UNLNOWN SUBJECT, PLEASE OPEN THE ISSUE")"
з дисципліни: "#subjects.at(subject_shorthand, default: "UNLNOWN SUBJECT, PLEASE OPEN AN ISSUE")"
з теми: "#title"
@ -634,14 +670,16 @@
#columns(2)[
#set align(left)
#if authors.len() == 1 [
#let author = authors.at(0)
#if author.gender == "m" { [Виконав:\ ] } else { [Виконала:\ ] }
ст. гр. #author.group\
#author.name\
#if author.variant != none { [Варіант: #author.variant] }
] else [
#set par(first-line-indent: 0pt)
#if authors.len() == 1 {
let author = authors.at(0)
if author.gender == "m" [Виконав:\ ] else [Виконала:\ ]
[
ст. гр. #author.group\
#author.name\
]
if author.variant != none [Варіант: #author.variant]
} else [
Виконали:\
ст. гр. #authors.at(0).group\
#authors.map(a => [ #a.name\ ])
@ -665,3 +703,5 @@
heading(title)
doc
}
// vim:sts=2:sw=2:fdl=0:fdm=marker:cms=/*%s*/

View File

@ -1,5 +1,4 @@
#import "template.typ": *
#import "@preview/indenta:0.0.3": fix-indent
#import "@local/nure:0.0.0": *
#let author = (
name: "Ситник Є. С.",
@ -29,7 +28,7 @@
#let task_list = (
done_date: datetime(year: 2024, month: 12, day: 27),
initial_data: datetime(year: 2024, month: 9, day: 15),
initial_date: datetime(year: 2024, month: 9, day: 15),
source: "методичні вказівки до виконання курсової роботи, вимоги до інформаційної системи, предметна область, що пов’язана з управлінням класом та класним керівництвом.",
content: "вступ, аналіз предметної області; постановка задачі; проектування бази даних; опис програми; висновки; перелік джерел посилання.",
graphics: "загальна діаграма класів, ER-діаграма, UML-діаграми, DFD-діаграма, схема БД в 1НФ, 2НФ, 3НФ, копії екранів (“скриншоти”) прикладної програми, приклади звітів прикладної програми.",
@ -78,20 +77,20 @@
],
)
#let appendices = (
(
title: "Приклад звіту 1",
content: [test],
),
(
title: "Приклад звіту 2",
content: [test],
),
(
title: "Приклад звіту 3",
content: [test],
),
)
#let appendices = [
= Приклад звіту 1
#v(-spacing)
== Частина 1
#lorem(100)
== Частина2
#lorem(200)
= Приклад звіту 2
#lorem(200)
= Приклад звіту 3
#lorem(200)
]
#show: cw-template.with(
title: "Інформаційна система «Помічник класного керівника». Керування класом",
@ -107,4 +106,15 @@
appendices: appendices,
)
#show: fix-indent()
= Моделювання
#lorem(250)
= Імплементація
#v(-spacing)
== Підоготовка
#lorem(200)
== Процес
#lorem(500)
= Тестування
#lorem(300)

View File

@ -1,5 +1,4 @@
#import "template.typ": *
#import "@preview/indenta:0.0.3": fix-indent
#import "@local/nure:0.0.0": *
#show: lab-pz-template.with(
doctype: "ЛБ",
@ -23,17 +22,30 @@
worknumber: 1,
)
#show: fix-indent()
#v(-spacing)
== Мета роботи
Супер важлива мета
== Висновки
Супер важливий висновок
#lorem(100)
== Хід роботи
#v(-spacing)
=== Підготовка
#lorem(150)
=== Виконання дослідження
#lorem(300)
=== Підрахунок результатів
#lorem(250)
== Висновки
#lorem(100)
== Контрольні запитання
Супер важливі контрольні запитання
#lorem(100):
- #lorem(20);
- #lorem(30);
- #lorem(15);
- #lorem(25);
- #lorem(42);
- #lorem(27).

11
typst.toml Normal file
View File

@ -0,0 +1,11 @@
[package]
name = "nure"
version = "0.0.0"
entrypoint = "lib.typ"
authors = ["linerds"]
license = "GPL-3.0"
description = "Typst NURE package"
[template]
path = "template"
entrypoint = "lab.typ"