mirror of
https://github.com/JustAnyones/ktu-paper.git
synced 2026-11-04 00:30:18 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
efa3f8bcb0
|
||
|
|
62bf11a63f
|
||
|
|
099408aaaa
|
||
|
|
e1709a9ac5
|
||
|
|
60156860e5
|
||
|
|
eb8ea2616d
|
||
|
|
f94d6207e8
|
No files matched your search
@@ -6,9 +6,9 @@ I successfully wrote and defended a final Bachelor's thesis written with this te
|
||||
|
||||
## Initiating the template
|
||||
Install the downloaded template under the following directory:
|
||||
- Linux: `~/.local/share/typst/packages/local/ktu-paper/0.5.0/`
|
||||
- Linux: `~/.local/share/typst/packages/local/ktu-paper/0.5.1/`
|
||||
|
||||
And then initiate a new project:
|
||||
```sh
|
||||
typst init @local/ktu-paper:0.5.0
|
||||
typst init @local/ktu-paper:0.5.1
|
||||
```
|
||||
+92
-7
@@ -374,6 +374,65 @@
|
||||
// Figure layout
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/// Default layout per figure kind (keyed like `__figure-kinds`; custom kinds
|
||||
/// and unlisted ones use `__FALLBACK_FIGURE_LAYOUT`).
|
||||
/// - breakable: whether the body may be split across pages. The caption is then
|
||||
/// attached to the start of the body (sticky), so it is never left alone at
|
||||
/// the bottom of a page. If `false`, body and caption form one unbreakable
|
||||
/// block that moves to the next page as a whole.
|
||||
/// - caption: `top` or `bottom`.
|
||||
#let __DEFAULT_FIGURE_LAYOUT = (
|
||||
table: (breakable: true, caption: top),
|
||||
raw: (breakable: true, caption: bottom),
|
||||
)
|
||||
#let __FALLBACK_FIGURE_LAYOUT = (breakable: false, caption: bottom)
|
||||
|
||||
/// Author overrides, set via `ktu-paper(figureLayout: ...)`.
|
||||
#let __USER_FIGURE_LAYOUT = state("ktu-user-figure-layout", (:))
|
||||
|
||||
/// Stack of local overrides set by `breakable-figures` / `unbreakable-figures`.
|
||||
#let __FIGURE_BREAK_OVERRIDE = state("ktu-figure-break-override", ())
|
||||
|
||||
/// Validates author-supplied layouts: `(kind: (breakable: bool, caption: top | bottom))`,
|
||||
/// every field optional.
|
||||
#let __normalize-figure-layout(layouts) = {
|
||||
for (key, spec) in layouts {
|
||||
for (field, value) in spec {
|
||||
assert(
|
||||
field in ("breakable", "caption"),
|
||||
message: "figureLayout." + key + ": unknown option `" + field + "`, expected `breakable` or `caption`",
|
||||
)
|
||||
if field == "breakable" {
|
||||
assert(type(value) == bool, message: "figureLayout." + key + ".breakable must be a bool")
|
||||
} else {
|
||||
assert(
|
||||
value == top or value == bottom,
|
||||
message: "figureLayout." + key + ".caption must be `top` or `bottom`",
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
layouts
|
||||
}
|
||||
|
||||
/// Resolves the layout of a figure kind key. Must be called in a context.
|
||||
#let __figure-layout(key) = {
|
||||
let layout = __FALLBACK_FIGURE_LAYOUT + __DEFAULT_FIGURE_LAYOUT.at(key, default: (:))
|
||||
layout = layout + __USER_FIGURE_LAYOUT.get().at(key, default: (:))
|
||||
let overrides = __FIGURE_BREAK_OVERRIDE.get()
|
||||
if overrides.len() > 0 {
|
||||
layout.breakable = overrides.last()
|
||||
}
|
||||
layout
|
||||
}
|
||||
|
||||
/// Runs `body` with every figure's `breakable` setting forced to `mode`.
|
||||
#let __with-break-override(mode, body) = {
|
||||
__FIGURE_BREAK_OVERRIDE.update(stack => stack + (mode,))
|
||||
body
|
||||
__FIGURE_BREAK_OVERRIDE.update(stack => stack.slice(0, -1))
|
||||
}
|
||||
|
||||
/// Formats a figure with a caption and number.
|
||||
#let __format-figure(it) = {
|
||||
let caption = it.caption
|
||||
@@ -384,13 +443,39 @@
|
||||
set text(size: 11pt)
|
||||
|
||||
let caption-line = [*#__caption-label(it)* #caption.body]
|
||||
let key = __figure-key(it)
|
||||
|
||||
// Tables have captions at the top
|
||||
if it.kind == table {
|
||||
align(left, caption-line)
|
||||
it.body
|
||||
} else {
|
||||
it.body
|
||||
align(center, caption-line)
|
||||
context {
|
||||
let layout = __figure-layout(key)
|
||||
let on-top = layout.caption == top
|
||||
// Entire table is by default left aligned, unlike other figures which are centered
|
||||
let body = if key == "table" { align(left, it.body) } else { it.body }
|
||||
let caption-block = block(
|
||||
sticky: on-top and layout.breakable,
|
||||
width: 100%,
|
||||
align(if on-top { left } else { center }, caption-line),
|
||||
)
|
||||
if layout.breakable {
|
||||
// The body may split across pages. A caption on top is sticky and stays
|
||||
// with the first rows; a caption at the bottom cannot be glued to the end
|
||||
// of a splittable body, so it may end up alone on the next page.
|
||||
if on-top {
|
||||
caption-block
|
||||
body
|
||||
} else {
|
||||
body
|
||||
caption-block
|
||||
}
|
||||
} else {
|
||||
block(breakable: false, width: 100%, {
|
||||
if on-top {
|
||||
caption-block
|
||||
body
|
||||
} else {
|
||||
body
|
||||
caption-block
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -254,3 +254,125 @@
|
||||
#h(58%) _Patvirtinta elektroniniu būdu_
|
||||
]
|
||||
}
|
||||
|
||||
#let ktu-gen-ai-usage-declaration-page(
|
||||
author: highlight[Vardenis Pavardenis],
|
||||
faculty: highlight[Informatikos fakultetas],
|
||||
module: highlight[Studijų modulio pavadinimas (kodas)],
|
||||
title: highlight[Studijų darbo pavadinimas],
|
||||
type: highlight[Studijų darbo rūšis],
|
||||
usageInformation: (
|
||||
(highlight[...], highlight[...], highlight[...], highlight[...]),
|
||||
),
|
||||
showPhysicalSignature: true,
|
||||
) = {
|
||||
set text(size: 12pt)
|
||||
|
||||
align(center)[
|
||||
#block([*GENERATYVINIO DIRBTINIO INTELEKTO (GenDI) NAUDOJIMO DEKLARACIJA*])
|
||||
#block[\_\_\_ \_\_\_ \_\_\_]
|
||||
]
|
||||
|
||||
[*1. Studento duomenys*]
|
||||
table(
|
||||
columns: (155pt, 1fr),
|
||||
align: (x, y) => { horizon + left },
|
||||
[*Studento vardas, pavardė*], [#author],
|
||||
[*Studento fakultetas*], [#faculty],
|
||||
[*Studijų modulis*], [#module],
|
||||
[*Studijų darbo pavadinimas*], [#title],
|
||||
[*Studijų darbo rūšis*], [#type],
|
||||
)
|
||||
|
||||
[
|
||||
#set linebreak(justify: false)
|
||||
*2. GenDI naudojimo patvirtinimas*\
|
||||
_Pažymėkite vieną variantą:_
|
||||
]
|
||||
let usedAi = usageInformation != none and usageInformation.len() > 0
|
||||
let checkbox(checked: false) = {
|
||||
box(
|
||||
width: 0.8em,
|
||||
height: 0.8em,
|
||||
stroke: 0.08em + black,
|
||||
radius: 0.15em,
|
||||
if checked {
|
||||
let size = 0.4em
|
||||
let margin = 0.2em
|
||||
// Top-left to bottom-right line
|
||||
place(top + left, dx: margin, dy: margin, line(end: (size, size), stroke: 0.08em + black))
|
||||
// Bottom-left to top-right line
|
||||
place(top + left, dx: margin, dy: margin + size, line(end: (size, -size), stroke: 0.08em + black))
|
||||
} else {
|
||||
none
|
||||
},
|
||||
)
|
||||
}
|
||||
table(
|
||||
columns: (28pt, 1fr),
|
||||
align: (x, y) => { horizon + left },
|
||||
table.cell(rowspan: 2)[#align(top, checkbox(checked: not usedAi))],
|
||||
[*Rengdamas (-a) šį studijų darbą nenaudojau generatyvinio dirbtinio intelekto įrankių*],
|
||||
[Patvirtinu, kad studijų darbe pateiktas turinys yra mano autentiškas intelektinis darbas, o naudoti šaltiniai nurodyti pagal citavimo reikalavimus.],
|
||||
|
||||
table.cell(rowspan: 2)[#align(top, checkbox(checked: usedAi))],
|
||||
[*Rengdamas (-a) šį studijų darbą naudojau generatyvinio dirbtinio intelekto įrankius*],
|
||||
[Patvirtinu, kad GenDI įrankiai buvo naudojami laikantis studijų modulyje nustatytų GenDI naudojimo reikalavimų bei naudojimas yra skaidriai ir sąžiningai deklaruotas.],
|
||||
)
|
||||
|
||||
[
|
||||
#set linebreak(justify: false)
|
||||
*3. GenDI naudojimo informacija*\
|
||||
_Užpildykite, jei rengiant studijų darbą naudojote generatyvinio dirbtinio intelekto įrankius:_
|
||||
]
|
||||
let rows = if usedAi {
|
||||
usageInformation.flatten()
|
||||
} else {
|
||||
// hide[x] gives each empty cell the height of one regular line of text
|
||||
range(3).map(_ => range(4).map(_ => hide[x])).flatten()
|
||||
}
|
||||
set par(justify: false)
|
||||
table(
|
||||
columns: (91pt, 127pt, 139pt, 1fr),
|
||||
align: (x, y) => if y == 0 { top + left } else { horizon + left },
|
||||
table.header(
|
||||
[
|
||||
#set linebreak(justify: false)
|
||||
*Darbo dalis*\
|
||||
_(pvz., skyrius, visas darbas)_
|
||||
],
|
||||
[*GenDI įrankio naudojimo tikslas*],
|
||||
[*GenDI įrankio pavadinimas, versija / internetinė nuoroda*],
|
||||
[
|
||||
#set linebreak(justify: false)
|
||||
*Studento indėlis* \
|
||||
_(kaip GenDI rezultatas buvo patikrintas, redaguotas ar papildytas studento)_
|
||||
],
|
||||
),
|
||||
..rows,
|
||||
)
|
||||
|
||||
let field(size: 12pt, body) = {
|
||||
set text(size: size)
|
||||
align(center, body)
|
||||
}
|
||||
let underlined-field(min-width: 92pt, body) = context {
|
||||
let w = calc.max(min-width, measure(body).width)
|
||||
align(center, box(
|
||||
width: w,
|
||||
height: 1.4em,
|
||||
stroke: (bottom: 0.5pt + black),
|
||||
inset: (bottom: 2pt),
|
||||
align(center + bottom, body),
|
||||
))
|
||||
}
|
||||
let maybe(show-it, body) = if show-it { body } else { hide(body) }
|
||||
align(bottom, table(
|
||||
stroke: 0pt,
|
||||
inset: 2pt,
|
||||
columns: (120pt, 177pt, 1fr),
|
||||
align: (x, y) => { horizon + left },
|
||||
[Studentas], [#maybe(showPhysicalSignature, [#underlined-field[]])], [#underlined-field[#author]],
|
||||
[], [#maybe(showPhysicalSignature, [#field(size: 10pt)[_(parašas)_]])], [#field(size: 10pt)[(_vardas, pavardė_)]],
|
||||
))
|
||||
}
|
||||
+28
-4
@@ -7,7 +7,7 @@
|
||||
ktu-author-table, ktu-title-header-block,
|
||||
|
||||
ktu-heading-page, ktu-heading-page-centered, ktu-heading-page-normal,
|
||||
ktu-academic-honestly-declaration-page
|
||||
ktu-academic-honestly-declaration-page, ktu-gen-ai-usage-declaration-page
|
||||
)
|
||||
#import "figures.typ": (
|
||||
ref-no, custom-ref,
|
||||
@@ -17,6 +17,9 @@
|
||||
__equation-numbering,
|
||||
__normalize-figure-kinds,
|
||||
__USER_FIGURE_KINDS,
|
||||
__USER_FIGURE_LAYOUT,
|
||||
__normalize-figure-layout,
|
||||
__with-break-override,
|
||||
|
||||
__format-ref,
|
||||
__format-figure,
|
||||
@@ -286,6 +289,19 @@
|
||||
__ktu_outline(title: heading(title, outlined: true), target: figure.where(kind: kind))
|
||||
}
|
||||
|
||||
/// Lets figures in `body` split across pages: the body may break, the caption stays
|
||||
/// attached to its start (a caption at the bottom may end up alone, see `figureLayout`).
|
||||
/// Use it to opt out of keeping a figure on one page, e.g. for a long code listing.
|
||||
/// - body (content): Content containing figures.
|
||||
/// -> content
|
||||
#let breakable-figures(body) = __with-break-override(true, body)
|
||||
|
||||
/// Keeps every figure in `body` on one page: body and caption move to the next
|
||||
/// page together. Use it to opt out of splitting, e.g. for a short table.
|
||||
/// - body (content): Content containing figures.
|
||||
/// -> content
|
||||
#let unbreakable-figures(body) = __with-break-override(false, body)
|
||||
|
||||
/// `code` option defaults for the library entrypoint.
|
||||
#let __CODE_DEFAULTS = (
|
||||
font: "Hack",
|
||||
@@ -293,6 +309,7 @@
|
||||
fill: white,
|
||||
stroke: 0.5pt + black,
|
||||
numbers: true,
|
||||
radius: 0pt,
|
||||
display-name: false,
|
||||
display-icon: false,
|
||||
)
|
||||
@@ -314,7 +331,7 @@
|
||||
}
|
||||
|
||||
show raw.where(block: true): codly.new
|
||||
show: codly.set_(number-enabled: opts.numbers)
|
||||
show: codly.set_(number-enabled: opts.numbers, radius: opts.radius)
|
||||
show: codly.line-set_(fill: opts.fill, stroke: opts.stroke)
|
||||
show: codly.lang-set_(
|
||||
display-name: opts.display-name,
|
||||
@@ -374,8 +391,6 @@
|
||||
body
|
||||
}
|
||||
|
||||
#let setup-code(body, ..ignored) = body
|
||||
|
||||
#let setup-page(
|
||||
font: "Times New Roman",
|
||||
uppercaseSectionTitles: false,
|
||||
@@ -517,18 +532,26 @@
|
||||
/// - `single-name`: full word used when the figure is the only one of its kind
|
||||
/// and is left unnumbered, e.g. "Komanda." and "(žr. komanda)". Defaults to `supplement`.
|
||||
/// Currently only tables and images are left unnumbered when single, so this only matters for kinds added there.
|
||||
/// - figureLayout (dictionary): Page-break behaviour and caption position per figure kind,
|
||||
/// `(kind: (breakable: bool, caption: top | bottom))`, every field optional. Kinds are
|
||||
/// `table`, `image`, `raw` (code), or a key of `figureKinds`. Defaults: `table` and `raw`
|
||||
/// are breakable; everything else is unbreakable. Example: `(raw: (breakable: false, caption: bottom))`.
|
||||
/// A breakable figure's top caption stays attached to the start of the body.
|
||||
/// Use `breakable-figures[...]` / `unbreakable-figures[...]` to override it locally.
|
||||
/// - code (dictionary | none): Code block configuration, or `none` to leave raw blocks unstyled. Keys:
|
||||
/// - `font` (str): Monospace font. Defaults to "Hack".
|
||||
/// - `spacing` (relative): Word spacing of code text. Defaults to `80%`.
|
||||
/// - `fill` (paint): Background of code lines. Defaults to `white`.
|
||||
/// - `stroke` (stroke | none): Outline around the code block. Defaults to `0.5pt + black`; `none` removes it.
|
||||
/// - `numbers` (bool): Show line numbers. Defaults to `true`.
|
||||
/// - `radius` (length): Corner radius of the outline. Defaults to `0pt` (square corners).
|
||||
/// - `display-name` (bool): Show the language name badge. Defaults to `false`.
|
||||
/// - `display-icon` (bool): Show the language icon badge. Defaults to `false`.
|
||||
#let ktu-paper(
|
||||
font: "Times New Roman",
|
||||
figureNumberingPerSection: false,
|
||||
figureKinds: (:),
|
||||
figureLayout: (:),
|
||||
code: (:),
|
||||
// Not sure about formal conformity of deviating
|
||||
// from the defaults of the next options,
|
||||
@@ -544,6 +567,7 @@
|
||||
)
|
||||
__FIG_PER_SECTION.update(figureNumberingPerSection)
|
||||
__USER_FIGURE_KINDS.update(__normalize-figure-kinds(figureKinds))
|
||||
__USER_FIGURE_LAYOUT.update(__normalize-figure-layout(figureLayout))
|
||||
__UPPERCASE_SECTION_TITLES.update(uppercaseSectionTitles)
|
||||
__setup-code(code, body)
|
||||
}
|
||||
+15
-3
@@ -1,7 +1,8 @@
|
||||
#import "@local/ktu-paper:0.5.0": (
|
||||
#import "@local/ktu-paper:0.5.1": (
|
||||
ktu-paper,
|
||||
ktu-table-of-contents, ktu-picture-list, ktu-table-list, ktu-code-list,
|
||||
ktu-heading-page-normal,
|
||||
ktu-gen-ai-usage-declaration-page,
|
||||
ktu-table,
|
||||
unnumbered-heading,
|
||||
custom-ref, ref-no
|
||||
@@ -13,24 +14,32 @@
|
||||
figureKinds: (
|
||||
veryCustomKind: (supplement: "komanda", ref-name: "komanda"),
|
||||
),
|
||||
// Code blocks, optional, `code: none` disables styling
|
||||
// Code blocks, `code: none` to disable styling
|
||||
code: (
|
||||
font: "Hack",
|
||||
spacing: 80%,
|
||||
fill: white,
|
||||
stroke: 0.5pt + black,
|
||||
numbers: true,
|
||||
radius: 0pt,
|
||||
display-name: false,
|
||||
display-icon: false,
|
||||
),
|
||||
)
|
||||
|
||||
// Replace dots in equations with commas instead so 1.25 becomes 1,25.
|
||||
#show math.equation: it => {
|
||||
show regex("\d+\.\d+"): it => {show ".": {","+h(0pt)}
|
||||
it}
|
||||
it
|
||||
}
|
||||
|
||||
// To be used for writing purposes to mark TODOs in the document. They will be highlighted in yellow and have a dashed border.
|
||||
#let todo(desc) = block(
|
||||
width: 100%, inset: 10pt, stroke: (dash: "dashed"), fill: yellow.lighten(80%),
|
||||
[*TODO:* #desc],
|
||||
)
|
||||
|
||||
#ktu-heading-page-normal(
|
||||
faculty: highlight[Informatikos fakultetas],
|
||||
title: highlight[Laboratorinio darbo ataskaitos pavadinimas],
|
||||
@@ -156,4 +165,7 @@ Naudotojai tai pat gali apibrėžti savo figūras, pavyzdžiui, komandų fragmen
|
||||
|
||||
#pagebreak()
|
||||
= Išvados
|
||||
#lorem(50)
|
||||
#lorem(50)
|
||||
|
||||
#pagebreak()
|
||||
#ktu-gen-ai-usage-declaration-page()
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
#import "@local/ktu-paper:0.5.0": (
|
||||
#import "@local/ktu-paper:0.5.1": (
|
||||
ktu-paper,
|
||||
ktu-table-of-contents, ktu-picture-list, ktu-table-list,
|
||||
ktu-heading-page-normal,
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
#import "@local/ktu-paper:0.5.0": (
|
||||
#import "@local/ktu-paper:0.5.1": (
|
||||
ktu-paper,
|
||||
ktu-table-of-contents, ktu-picture-list, ktu-table-list,
|
||||
ktu-heading-page-normal,
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ktu-paper"
|
||||
version = "0.5.0"
|
||||
version = "0.5.1"
|
||||
compiler = "0.15.0"
|
||||
entrypoint = "src/lib.typ"
|
||||
repository = "https://github.com/svetikas/ktu-paper"
|
||||
|
||||
Reference in new issue
Block a user