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
|
||
|
|
ed5a62c659
|
||
|
|
f078b8ae00
|
||
|
|
321703ddbc
|
||
|
|
c15747ce98
|
||
|
|
ada5bc3f63
|
||
|
|
e5c774f96c
|
||
|
|
b803a906ea
|
||
|
|
71b83ab97f
|
||
|
|
f8a747e6b3
|
||
|
|
dfac289590
|
||
|
|
1740adfc5a
|
||
|
|
55a236fe8b
|
||
|
|
d0d7d2a197
|
||
|
|
9736619563
|
||
|
|
340c5ab92c
|
||
|
|
59d197f291
|
||
|
|
f8001593dd
|
||
|
|
1ff507941d
|
||
|
|
3e91fbfefd
|
||
|
|
2e3f4a890e
|
||
|
|
3040693015
|
||
|
|
67947b07a7
|
||
|
|
cd64907a36
|
||
|
|
920866695c
|
||
|
|
b046a59a89
|
||
|
|
ca96637e50
|
||
|
|
ef3e1f6432
|
||
|
|
e37150fc87
|
||
|
|
f5835937db
|
||
|
|
05da5ad1bf
|
||
|
|
22c9e7df8e
|
||
|
|
2b0406163e
|
||
|
|
39a5959bca
|
No files matched your search
@@ -1 +1,3 @@
|
||||
template/*.pdf
|
||||
|
||||
tests/
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2026 Dominykas Svetikas
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -1,3 +1,14 @@
|
||||
# ktu-paper
|
||||
|
||||
This repository contains a Typst template for academic papers at the Kaunas University of Technology, Faculty of Informatics. A final Bachelor's thesis written with this template has successfully passed the formal review.
|
||||
This repository contains a Typst template for academic papers at the Kaunas University of Technology, Faculty of Informatics.
|
||||
|
||||
I successfully wrote and defended a final Bachelor's thesis written with this template and continue to use for writing other reports.
|
||||
|
||||
## Initiating the template
|
||||
Install the downloaded template under the following directory:
|
||||
- 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.1
|
||||
```
|
||||
@@ -1,3 +1,16 @@
|
||||
/// Whether to number figures per section or not.
|
||||
/// If true, figures will be numbered like "1.1", "1.2", "2.1", etc.
|
||||
/// If false, figures will be numbered like "1", "2", "3", etc.
|
||||
///
|
||||
/// TODO: figure out how to deal with numbering on sections such as
|
||||
/// Appendix and other non-standard sections.
|
||||
#let __FIG_PER_SECTION = state("svetikas.lt/ktu-paper/figure-numbering-per-section", false)
|
||||
|
||||
/// Whether to uppercase section titles or not.
|
||||
/// If true, section titles will be uppercased.
|
||||
/// If false, section titles will be displayed as-is.
|
||||
#let __UPPERCASE_SECTION_TITLES = state("svetikas.lt/ktu-paper/uppercase-section-titles", false)
|
||||
|
||||
#let __DEBUG_AUTHOR_TABLE = state("$ktu-template-DEBUG_AUTHOR_TABLE", false)
|
||||
#let debug-author-table() = {
|
||||
__DEBUG_AUTHOR_TABLE.update(true)
|
||||
|
||||
+481
@@ -0,0 +1,481 @@
|
||||
// This file includes logic for displaying figures in the document, including numbering, captions, and references. It also includes logic for handling figure numbering per section or globally, based on the configuration set in `config.typ`.
|
||||
#import "config.typ": __FIG_PER_SECTION
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Figure kinds
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/// Localizations for the recognized referenceable figure kinds, keyed by `repr(func)`.
|
||||
/// - supplement: used in captions (the caption adds the separator, e.g. "1 pav.").
|
||||
/// - ref-name: used in references, e.g. "(žr. 1 pav.)". Either a string or a
|
||||
/// function `count => string`, called with the number of elements mentioned
|
||||
/// together, e.g. "(žr. 1 priedą)" vs "(žr. 1, 2 priedus)".
|
||||
/// - single-name: full word used when the figure is the only one of its kind and
|
||||
/// therefore unnumbered, e.g. "Paveikslas. ..." and "(žr. paveikslas)".
|
||||
#let __figure-kinds = (
|
||||
table: (supplement: "lentelė", ref-name: "lentelė", single-name: "lentelė"),
|
||||
image: (supplement: "pav", ref-name: "pav.", single-name: "paveikslas"),
|
||||
raw: (supplement: "kodo frag", ref-name: "kodo frag.", single-name: "kodo fragmentas"),
|
||||
equation: (supplement: "lygtis", ref-name: "formulė", single-name: "lygtis"),
|
||||
// Appendices are headings, not figures, but they use the same referencing
|
||||
appendix: (
|
||||
supplement: "priedas",
|
||||
ref-name: count => if count == 1 { "priedą" } else { "priedus" },
|
||||
single-name: "priedas",
|
||||
),
|
||||
)
|
||||
|
||||
/// Figure kinds registered by the document author via `ktu-paper(figureKinds: ...)`.
|
||||
#let __USER_FIGURE_KINDS = state("ktu-user-figure-kinds", (:))
|
||||
|
||||
/// Validates author-supplied kinds and fills in defaults (`ref-name` falls back
|
||||
/// to `supplement`).
|
||||
#let __normalize-figure-kinds(kinds) = {
|
||||
let normalized = (:)
|
||||
for (key, spec) in kinds {
|
||||
assert(
|
||||
"supplement" in spec,
|
||||
message: "figure kind `" + key + "` needs a `supplement`",
|
||||
)
|
||||
normalized.insert(key, (
|
||||
supplement: spec.supplement,
|
||||
ref-name: spec.at("ref-name", default: spec.supplement),
|
||||
single-name: spec.at("single-name", default: spec.supplement),
|
||||
))
|
||||
}
|
||||
normalized
|
||||
}
|
||||
|
||||
/// Recognized kinds merged with the author's. Must be called in a context.
|
||||
#let __all-figure-kinds() = __figure-kinds + __USER_FIGURE_KINDS.get()
|
||||
|
||||
/// Resets all figure and equation counters (used when numbering per section).
|
||||
/// Must be called in a context.
|
||||
#let __reset-figure-counters() = {
|
||||
let custom = (..__USER_FIGURE_KINDS.get().keys(),)
|
||||
for kind in (image, table, raw, ..custom) {
|
||||
counter(figure.where(kind: kind)).update(0)
|
||||
}
|
||||
counter(math.equation).update(0)
|
||||
}
|
||||
|
||||
/// Returns the caption supplement text for a figure kind (e.g. `table`, `math.equation`).
|
||||
#let __fig-supplement(func) = __figure-kinds.at(repr(func)).supplement
|
||||
|
||||
/// Finds the first recognized kind ("table", "image", "raw" or "equation") inside
|
||||
/// `node`, descending through wrappers (align, block, grid, stack, ...).
|
||||
/// Returns the key into `__figure-kinds`, or `none` if nothing is recognized.
|
||||
#let __find-figure-kind(node) = {
|
||||
if type(node) != content { return none }
|
||||
|
||||
let key = repr(node.func())
|
||||
if key in __figure-kinds { return key }
|
||||
|
||||
// Single-child wrappers
|
||||
for field in ("body", "child") {
|
||||
if node.has(field) {
|
||||
let found = __find-figure-kind(node.at(field))
|
||||
if found != none { return found }
|
||||
}
|
||||
}
|
||||
|
||||
// Multi-child containers
|
||||
if node.has("children") {
|
||||
for child in node.children {
|
||||
let found = __find-figure-kind(child)
|
||||
if found != none { return found }
|
||||
}
|
||||
}
|
||||
|
||||
none
|
||||
}
|
||||
|
||||
/// Resolves the `__figure-kinds` key of a figure element. An explicit custom
|
||||
/// (string) kind always wins; otherwise the kind is detected from the body.
|
||||
#let __figure-key(fig) = {
|
||||
if type(fig.kind) == str { return fig.kind }
|
||||
let found = __find-figure-kind(fig.body)
|
||||
if found != none { found } else { repr(fig.kind) }
|
||||
}
|
||||
|
||||
/// Returns the caption supplement of a figure element.
|
||||
#let __figure-supplement-of(fig) = {
|
||||
let key = __figure-key(fig)
|
||||
let kinds = __all-figure-kinds()
|
||||
assert(
|
||||
key in kinds,
|
||||
message: "unregistered figure kind `" + key + "`: register it with ktu-paper(figureKinds: ...)",
|
||||
)
|
||||
kinds.at(key).supplement
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Numbering
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/// Resolves a figure's number (global "1" or section-based "1.1") at `loc`,
|
||||
/// returned as a string.
|
||||
#let __get-figure-number(fig-item, loc) = {
|
||||
assert(
|
||||
type(fig-item) == content and fig-item.func() == figure,
|
||||
message: "can only get figure number for figure elements",
|
||||
)
|
||||
|
||||
let fig-counter = counter(figure.where(kind: fig-item.kind))
|
||||
|
||||
if __FIG_PER_SECTION.at(loc) {
|
||||
let chapter = counter(heading).at(loc).at(0, default: 0)
|
||||
let fig-num = fig-counter.at(loc).at(0, default: 1)
|
||||
str(chapter) + "." + str(fig-num)
|
||||
} else {
|
||||
str(fig-counter.at(loc).at(0))
|
||||
}
|
||||
}
|
||||
|
||||
/// Resolves an equation's number (global "2" or section-based "1.2") at `loc` without parentheses.
|
||||
/// `loc` is the location of the equation.
|
||||
#let __get-equation-number(loc) = {
|
||||
let number = counter(math.equation).at(loc).at(0)
|
||||
if __FIG_PER_SECTION.at(loc) {
|
||||
let chapter = counter(heading).at(loc).at(0, default: 0)
|
||||
str(chapter) + "." + str(number)
|
||||
} else {
|
||||
str(number)
|
||||
}
|
||||
}
|
||||
|
||||
/// Numbering function for `math.equation`: "(2)" or, when numbering per
|
||||
/// section, "(1.2)".
|
||||
#let __equation-numbering(..nums) = context {
|
||||
let number = nums.pos().first()
|
||||
if __FIG_PER_SECTION.get() {
|
||||
let chapter = counter(heading).get().at(0, default: 0)
|
||||
// TODO: this is a hack to prevent the numbers from being completely
|
||||
// part of a regex match against math.equation.
|
||||
// It would be better to render math equation numbers as a separate element, so that regexes don't see them at all.
|
||||
[(#box[#chapter].#box[#number])]
|
||||
} else {
|
||||
[(#number)]
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the number of a located figure element as a string, formatted
|
||||
/// according to the current numbering scheme.
|
||||
#let __get-locatable-element-number(element) = context {
|
||||
assert(type(element) == content, message: "can only reference elements of type content")
|
||||
assert(element.func() == figure, message: "referenced element does not have a figure function")
|
||||
__get-figure-number(element, element.location())
|
||||
}
|
||||
|
||||
/// Appendix headings carry an "appendix-heading" metadata marker as their
|
||||
/// first child (or as their whole body, when the appendix has no title) and
|
||||
/// are numbered separately from normal headings.
|
||||
#let __is-appendix-heading(item) = {
|
||||
let body = item.body
|
||||
if body.has("children") {
|
||||
body.children.at(0, default: none) == metadata("appendix-heading")
|
||||
} else {
|
||||
body == metadata("appendix-heading")
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the title of an appendix heading element (everything after the
|
||||
/// marker), or `none` if the appendix has no title.
|
||||
#let __appendix-title(item) = {
|
||||
let body = item.body
|
||||
if not body.has("children") { return none }
|
||||
let rest = body.children.slice(1)
|
||||
if rest.len() == 0 { none } else { rest.join() }
|
||||
}
|
||||
|
||||
/// Returns the number (int) of an appendix heading element: its position among
|
||||
/// all appendices, in document order. Must be called in a context.
|
||||
#let __appendix-number(item) = {
|
||||
query(selector(heading).before(item.location(), inclusive: true))
|
||||
.filter(h => __is-appendix-heading(h))
|
||||
.len()
|
||||
}
|
||||
|
||||
/// Parses a dotted number such as "12" or "1.12.5" into an array of ints.
|
||||
/// Returns `none` if any part is not purely numeric.
|
||||
#let __parse-number(value) = {
|
||||
let parts = value.split(".")
|
||||
if parts.all(p => p.match(regex("^\\d+$")) != none) {
|
||||
parts.map(int)
|
||||
} else {
|
||||
none
|
||||
}
|
||||
}
|
||||
|
||||
/// Sorts `(location, number)` entries. If every number is numeric (optionally
|
||||
/// dotted, e.g. "1.12.5"), sorts component-wise numerically; otherwise falls
|
||||
/// back to plain string ordering.
|
||||
#let __sort-entries(entries) = {
|
||||
let keys = entries.map(e => __parse-number(e.at(1)))
|
||||
if keys.all(k => k != none) {
|
||||
entries.zip(keys).sorted(key: pair => pair.at(1)).map(pair => pair.at(0))
|
||||
} else {
|
||||
entries.sorted(key: e => e.at(1))
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Single-figure handling
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/// Figure kinds that are left unnumbered when the document contains only one
|
||||
/// captioned figure of that kind: "Lentelė. Aprašas" and "(žr. lentelė)"
|
||||
/// instead of "1 lentelė. Aprašas" and "(žr. 1 lentelė)". The word used comes
|
||||
/// from the kind's `single-name`.
|
||||
/// Keys are `__figure-key` values.
|
||||
#let __UNNUMBERED_WHEN_SINGLE = ("table", "image")
|
||||
|
||||
/// Whether `fig` is the only captioned figure of its kind in the document and
|
||||
/// its kind is listed in `__UNNUMBERED_WHEN_SINGLE`. Must be called in a context.
|
||||
#let __is-single-unnumbered(fig) = {
|
||||
if __figure-key(fig) not in __UNNUMBERED_WHEN_SINGLE { return false }
|
||||
query(figure.where(kind: fig.kind)).filter(f => f.caption != none).len() == 1
|
||||
}
|
||||
|
||||
/// Capitalizes the first letter of `value` ("lentelė" -> "Lentelė").
|
||||
#let __capitalize(value) = {
|
||||
let first = value.first()
|
||||
upper(first) + value.slice(first.len())
|
||||
}
|
||||
|
||||
/// Caption label of a figure element: "1 lentelė." normally, or
|
||||
/// "Lentelė." for a single unnumbered figure.
|
||||
#let __caption-label(fig) = context {
|
||||
let supplement = __figure-supplement-of(fig)
|
||||
if __is-single-unnumbered(fig) {
|
||||
let name = __all-figure-kinds().at(__figure-key(fig)).single-name
|
||||
[#__capitalize(name).]
|
||||
} else {
|
||||
[#__get-figure-number(fig, fig.location()) #supplement.]
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// References
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/// Returns a number for the given reference target.
|
||||
/// Panics for a figure that is the only one of its kind,
|
||||
/// since such figures have no number.
|
||||
/// - target (label): Label to get the reference number for.
|
||||
#let ref-no(target) = context {
|
||||
if type(target) != label {
|
||||
panic("ref-no expects a label as input")
|
||||
}
|
||||
|
||||
let item = query(target).first()
|
||||
let loc = item.location()
|
||||
let kind = item.func()
|
||||
|
||||
let number = if kind == figure {
|
||||
if __is-single-unnumbered(item) {
|
||||
panic(
|
||||
"ref-no: "
|
||||
+ str(target)
|
||||
+ " is the only "
|
||||
+ __figure-key(item)
|
||||
+ " in the document and is therefore unnumbered; "
|
||||
+ "refer to it with @"
|
||||
+ str(target)
|
||||
+ " (or custom-ref) instead",
|
||||
)
|
||||
}
|
||||
__get-figure-number(item, loc)
|
||||
} else if kind == math.equation {
|
||||
"(" + __get-equation-number(loc) + ")"
|
||||
} else if kind == heading {
|
||||
if __is-appendix-heading(item) {
|
||||
str(__appendix-number(item))
|
||||
} else {
|
||||
counter(heading).at(loc).map(str).join(".")
|
||||
}
|
||||
} else {
|
||||
panic("referencing unknown type: " + repr(kind))
|
||||
}
|
||||
|
||||
link(loc, number)
|
||||
}
|
||||
|
||||
/// Create a custom reference for multiple targets of the same type.
|
||||
/// - targets (label...): Labels to create a custom reference for.
|
||||
#let custom-ref(..targets) = context {
|
||||
let group-key = none
|
||||
let group-name = none // a string, or a function of the number of mentions
|
||||
let single-name = none // set when the target is a lone, unnumbered figure
|
||||
let entries = () // (location, number) pairs
|
||||
|
||||
for target in targets.pos() {
|
||||
let item = query(target).first()
|
||||
let loc = item.location()
|
||||
|
||||
// (kind key used for grouping, ref-name spec, number)
|
||||
let (key, name, number) = if item.func() == math.equation {
|
||||
("equation", __figure-kinds.equation.ref-name, __get-equation-number(loc))
|
||||
} else if item.func() == figure {
|
||||
let kind = __figure-key(item)
|
||||
let kinds = __all-figure-kinds()
|
||||
if kind not in kinds {
|
||||
panic("unregistered figure kind `" + kind + "`: register it with ktu-paper(figureKinds: ...)")
|
||||
}
|
||||
if __is-single-unnumbered(item) { single-name = kinds.at(kind).single-name }
|
||||
(kind, kinds.at(kind).ref-name, __get-figure-number(item, loc))
|
||||
} else if item.func() == heading and __is-appendix-heading(item) {
|
||||
("appendix", __figure-kinds.appendix.ref-name, str(__appendix-number(item)))
|
||||
} else {
|
||||
panic("referencing unknown type: " + repr(item.func()))
|
||||
}
|
||||
|
||||
if group-key != none and group-key != key {
|
||||
panic("custom-ref does not support grouping different elements together")
|
||||
}
|
||||
group-key = key
|
||||
group-name = name
|
||||
entries.push((loc, number))
|
||||
}
|
||||
|
||||
if entries.len() > 0 {
|
||||
if single-name != none {
|
||||
// The only figure of its kind: no number, e.g. "(žr. lentelė)"
|
||||
[(žr. #link(entries.first().at(0), single-name))]
|
||||
} else {
|
||||
let links = __sort-entries(entries).map(e => link(e.at(0), e.at(1)))
|
||||
let name = if type(group-name) == function { group-name(entries.len()) } else { group-name }
|
||||
[(žr. #links.join(", ") #name)]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Show rule for `@label` references. Equations render as a bare "(1.2)";
|
||||
/// figures delegate to `custom-ref`, so "(žr. 1 pav.)" is built in one place.
|
||||
/// Anything else (headings, citations, unregistered figure kinds) keeps
|
||||
/// Typst's default rendering.
|
||||
#let __format-ref(it) = {
|
||||
let el = it.element
|
||||
if el == none { return it }
|
||||
|
||||
if el.func() == math.equation {
|
||||
let loc = el.location()
|
||||
link(loc, "(" + __get-equation-number(loc) + ")")
|
||||
} else if el.func() == figure and __figure-key(el) in __all-figure-kinds() {
|
||||
custom-ref(it.target)
|
||||
} else if el.func() == heading and __is-appendix-heading(el) {
|
||||
custom-ref(it.target)
|
||||
} else {
|
||||
it
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// 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
|
||||
|
||||
// If caption is not provided, just show the figure body
|
||||
if caption == none { return it.body }
|
||||
|
||||
set text(size: 11pt)
|
||||
|
||||
let caption-line = [*#__caption-label(it)* #caption.body]
|
||||
let key = __figure-key(it)
|
||||
|
||||
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
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
+202
-28
@@ -17,6 +17,7 @@
|
||||
#let ktu-author-table(
|
||||
authors: (),
|
||||
alignment: right,
|
||||
namesFirst: true, // if false, roles will be displayed first
|
||||
) = context {
|
||||
// The layout should be a list of lists whose elements are (name, role) pairs.
|
||||
assert(authors.len() > 0, message: "author table must have at least one author")
|
||||
@@ -51,29 +52,43 @@
|
||||
table.header([]),
|
||||
..for author in authors {
|
||||
let (name, role) = author
|
||||
(align(center)[
|
||||
name = [*#name*]
|
||||
if not namesFirst {
|
||||
(role, name) = (name, role)
|
||||
}
|
||||
(
|
||||
align(center)[
|
||||
#set block(below: 8pt)
|
||||
#block[*#name*]
|
||||
#block[#name]
|
||||
#block[#role]
|
||||
|
||||
], [])
|
||||
],
|
||||
[],
|
||||
)
|
||||
}
|
||||
))
|
||||
} else {
|
||||
align(alignment, table(
|
||||
columns: (198.5pt, 56.7pt),
|
||||
table.header(
|
||||
[], [],
|
||||
),
|
||||
table.header([], []),
|
||||
..for author in authors {
|
||||
let (name, role) = author
|
||||
(align(left)[
|
||||
name = [*#name*]
|
||||
if not namesFirst {
|
||||
(role, name) = (name, role)
|
||||
}
|
||||
(
|
||||
align(left)[
|
||||
#set block(below: 8pt)
|
||||
#block[*#name*]
|
||||
#block[#name]
|
||||
#block[#role]
|
||||
|
||||
], [], [], [])
|
||||
}
|
||||
],
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
)
|
||||
},
|
||||
))
|
||||
}
|
||||
}
|
||||
@@ -128,8 +143,9 @@
|
||||
]
|
||||
}
|
||||
|
||||
#let ktu-heading-page-centered(
|
||||
#let ktu-heading-page(
|
||||
faculty: highlight[Fakulteto pavadinimas],
|
||||
department: none, // optional
|
||||
title: highlight[Rašto darbo pavadinimas],
|
||||
subtitles: highlight[Praktikos ataskaita / referatas ir pan. (įrašyti rašto darbo tipą)],
|
||||
authors: (
|
||||
@@ -138,44 +154,80 @@
|
||||
),
|
||||
place: highlight[Kaunas],
|
||||
year: highlight[#datetime.today().year()],
|
||||
centerAuthors: false,
|
||||
authorNamesFirst: true, // if false, roles will be displayed first
|
||||
) = {
|
||||
let isArr = type(subtitles) == array
|
||||
if not isArr {
|
||||
let subHeaders = (faculty,)
|
||||
if department != none {
|
||||
subHeaders = (faculty, department)
|
||||
}
|
||||
if type(subtitles) != array {
|
||||
subtitles = (subtitles,)
|
||||
}
|
||||
ktu-title-header-block(
|
||||
subHeaders: (faculty,),
|
||||
subHeaders: subHeaders,
|
||||
bigTitle: title,
|
||||
subTitles: subtitles,
|
||||
)
|
||||
v(94pt)
|
||||
ktu-author-table(authors: authors, alignment: center)
|
||||
align(center+bottom, block([*#place, #year*]))
|
||||
if centerAuthors {
|
||||
ktu-author-table(authors: authors, namesFirst: authorNamesFirst, alignment: center)
|
||||
} else {
|
||||
ktu-author-table(authors: authors, namesFirst: authorNamesFirst)
|
||||
}
|
||||
align(center + bottom, block([*#place, #year*]))
|
||||
}
|
||||
|
||||
#let ktu-heading-page-centered(
|
||||
faculty: highlight[Fakulteto pavadinimas],
|
||||
department: none, // optional
|
||||
title: highlight[Rašto darbo pavadinimas],
|
||||
subtitles: highlight[Praktikos ataskaita / referatas ir pan. (įrašyti rašto darbo tipą)],
|
||||
authors: (
|
||||
(highlight[Vardenis Pavardenis], highlight[Projekto autorius]),
|
||||
(highlight[Vardenis Pavardenis], highlight[Vadovas]),
|
||||
),
|
||||
authorNamesFirst: true, // if false, roles will be displayed first
|
||||
place: highlight[Kaunas],
|
||||
year: highlight[#datetime.today().year()],
|
||||
) = {
|
||||
ktu-heading-page(
|
||||
faculty: faculty,
|
||||
department: department,
|
||||
title: title,
|
||||
subtitles: subtitles,
|
||||
authors: authors,
|
||||
place: place,
|
||||
year: year,
|
||||
centerAuthors: true,
|
||||
authorNamesFirst: authorNamesFirst,
|
||||
)
|
||||
}
|
||||
|
||||
#let ktu-heading-page-normal(
|
||||
faculty: highlight[Fakulteto pavadinimas],
|
||||
department: none, // optional
|
||||
title: highlight[Rašto darbo pavadinimas],
|
||||
subtitles: highlight[Praktikos ataskaita / referatas ir pan. (įrašyti rašto darbo tipą)],
|
||||
authors: (
|
||||
(highlight[Vardenis Pavardenis], highlight[Projekto autorius]),
|
||||
(highlight[Vardenis Pavardenis], highlight[Vadovas]),
|
||||
),
|
||||
authorNamesFirst: true, // if false, roles will be displayed first
|
||||
place: highlight[Kaunas],
|
||||
year: highlight[#datetime.today().year()],
|
||||
) = {
|
||||
let isArr = type(subtitles) == array
|
||||
if not isArr {
|
||||
subtitles = (subtitles,)
|
||||
}
|
||||
ktu-title-header-block(
|
||||
subHeaders: (faculty,),
|
||||
bigTitle: title,
|
||||
subTitles: subtitles,
|
||||
ktu-heading-page(
|
||||
faculty: faculty,
|
||||
department: department,
|
||||
title: title,
|
||||
subtitles: subtitles,
|
||||
authors: authors,
|
||||
place: place,
|
||||
year: year,
|
||||
centerAuthors: false,
|
||||
authorNamesFirst: authorNamesFirst,
|
||||
)
|
||||
v(94pt)
|
||||
ktu-author-table(authors: authors)
|
||||
align(center+bottom, block([*#place, #year*]))
|
||||
}
|
||||
|
||||
#let ktu-academic-honestly-declaration-page(
|
||||
@@ -186,7 +238,7 @@
|
||||
ktu-title-header-block(
|
||||
subHeaders: (faculty, author),
|
||||
bigTitle: projectTitle,
|
||||
subTitles: ("Akademinio sąžiningumo deklaracija",)
|
||||
subTitles: ("Akademinio sąžiningumo deklaracija",),
|
||||
)
|
||||
v(20pt)
|
||||
[
|
||||
@@ -202,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ė_)]],
|
||||
))
|
||||
}
|
||||
+284
-291
@@ -1,75 +1,100 @@
|
||||
#import "@preview/codly:1.3.0": codly, codly-init
|
||||
#import "config.typ": debug-author-table, enable-heading-experiment, __HEADING_EXPERIMENT
|
||||
#import "@preview/codly:2.0.0" as codly
|
||||
#import "config.typ": debug-author-table, enable-heading-experiment, __HEADING_EXPERIMENT, __FIG_PER_SECTION, __UPPERCASE_SECTION_TITLES
|
||||
#import "fragments.typ": (
|
||||
ktu-table,
|
||||
ktu-heading-page-centered, ktu-heading-page-normal, ktu-academic-honestly-declaration-page
|
||||
|
||||
// building blocks
|
||||
ktu-author-table, ktu-title-header-block,
|
||||
|
||||
ktu-heading-page, ktu-heading-page-centered, ktu-heading-page-normal,
|
||||
ktu-academic-honestly-declaration-page, ktu-gen-ai-usage-declaration-page
|
||||
)
|
||||
#import "figures.typ": (
|
||||
ref-no, custom-ref,
|
||||
|
||||
__caption-label,
|
||||
__reset-figure-counters,
|
||||
__equation-numbering,
|
||||
__normalize-figure-kinds,
|
||||
__USER_FIGURE_KINDS,
|
||||
__USER_FIGURE_LAYOUT,
|
||||
__normalize-figure-layout,
|
||||
__with-break-override,
|
||||
|
||||
__format-ref,
|
||||
__format-figure,
|
||||
__figure-kinds,
|
||||
|
||||
__is-appendix-heading,
|
||||
__appendix-title,
|
||||
__appendix-number,
|
||||
)
|
||||
|
||||
/**
|
||||
* Paruošta pagal "Rašto ..."
|
||||
*/
|
||||
*/
|
||||
|
||||
/*
|
||||
* Further reading required:
|
||||
* - Double line spacing | https://github.com/typst/typst/issues/106
|
||||
* - Proposal: change `leading` option to `line-height` | https://github.com/typst/typst/issues/4224
|
||||
*/
|
||||
*/
|
||||
|
||||
#let __METADATA_HEADING_ALIGN_LEFT = metadata("heading-align-left");
|
||||
|
||||
///
|
||||
/// Insert a heading without a number.
|
||||
///
|
||||
/// Usually used for introductory or summary sections at the start and end.
|
||||
/// - text (str): The heading's title.
|
||||
/// - headingElement (heading): The heading's title.
|
||||
/// - alignLeft (bool): Whether the heading should be left-aligned or centered.
|
||||
/// ->
|
||||
#let unnumbered-heading(text) = {
|
||||
set heading(numbering: none)
|
||||
[#text]
|
||||
#let unnumbered-heading(headingElement, alignLeft: false) = {
|
||||
let fields = headingElement.fields()
|
||||
let body = fields.body
|
||||
let level = fields.at("level", default: 1)
|
||||
|
||||
if alignLeft {
|
||||
body = body + __METADATA_HEADING_ALIGN_LEFT
|
||||
}
|
||||
|
||||
heading(level: level, numbering: none, body)
|
||||
}
|
||||
|
||||
#let figureDefinitions = (
|
||||
table: (
|
||||
outlineFormat: (number) => [*#number lentelė.*],
|
||||
captionFormat: (number) => [*#number lentelė.*],
|
||||
),
|
||||
)
|
||||
|
||||
#let custom-figure(
|
||||
kind,
|
||||
caption: none,
|
||||
body
|
||||
) = {
|
||||
figure(
|
||||
body,
|
||||
kind: kind,
|
||||
caption: caption,
|
||||
supplement: "CUSTOM-FIGURE"
|
||||
/// Insert an appendix (priedas).
|
||||
///
|
||||
/// Appendices are numbered 1, 2, 3, ... in the order they appear in the
|
||||
/// document, so place them in the order they are first mentioned in the text.
|
||||
/// Each appendix should start on a new page: put a `#pagebreak()` before it.
|
||||
/// "N priedas" is written in the top right
|
||||
/// corner. The optional title is written below it like a chapter title (bold),
|
||||
/// exactly as given: start it with a capital letter, the rest in lowercase.
|
||||
/// Appendices are included in the table of contents.
|
||||
///
|
||||
/// Give it a label to refer to it from the text: `#appendix-item[Pavadinimas] <pr-konfig>`
|
||||
/// and then `@pr-konfig` or `#custom-ref(<pr-konfig>)` gives "(žr. 1 priedą)".
|
||||
/// - title (content | none): Optional appendix title.
|
||||
/// -> heading
|
||||
#let appendix-item(..title) = {
|
||||
assert(
|
||||
title.named().len() == 0 and title.pos().len() <= 1,
|
||||
message: "appendix-item takes at most one argument: the appendix title",
|
||||
)
|
||||
}
|
||||
|
||||
#let appendix-item(body) = {
|
||||
let title = title.pos().at(0, default: none)
|
||||
heading(
|
||||
metadata("appendix-heading") + "priedas. " + body,
|
||||
if title == none { metadata("appendix-heading") } else { metadata("appendix-heading") + title },
|
||||
level: 2,
|
||||
numbering: (..any) => {str(any.at(1))}
|
||||
numbering: none,
|
||||
)
|
||||
}
|
||||
|
||||
// Stores localized names for various figure types
|
||||
#let figureNames = (
|
||||
table: ("lentelė"),
|
||||
image: ("pav"),
|
||||
code: ("kodo frag"),
|
||||
equation: ("lygtis"),
|
||||
)
|
||||
|
||||
// Utility function to round numbers with padded zeros
|
||||
#let round-and-pad(number, decimals) = {
|
||||
let rounded = calc.round(number, digits: decimals)
|
||||
let s = str(rounded)
|
||||
let parts = s.split(".")
|
||||
let integer-part = parts.at(0)
|
||||
let decimal-part = if parts.len() == 2 { parts.at(1) } else { ""}
|
||||
|
||||
let decimal-part = if parts.len() == 2 { parts.at(1) } else { "" }
|
||||
|
||||
let padded-decimal = if decimals > 0 {
|
||||
let current-decimal-length = decimal-part.len()
|
||||
@@ -90,120 +115,6 @@
|
||||
}
|
||||
|
||||
|
||||
/// Returns a number for the given reference target.
|
||||
/// - target (label): Label to get the reference number for.
|
||||
#let ref-no(target) = context {
|
||||
let loc = locate(target)
|
||||
let elem = query(target)
|
||||
let item = elem.at(0)
|
||||
|
||||
// If it's a figure, return the figure number
|
||||
if item.func() == figure {
|
||||
link(loc, [#counter(figure.where(kind: item.kind)).at(loc).at(0)])
|
||||
} else if item.func() == heading {
|
||||
let fullValue = counter(heading).at(loc)
|
||||
|
||||
// If the heading has the "appendix-heading" metadata attached,
|
||||
// it means that it's an appendix heading and should be numbered differently
|
||||
if item.body.has("children") and item.body.children.at(0) == metadata("appendix-heading") {
|
||||
link(loc, [#fullValue.at(1)])
|
||||
// Otherwise, show the fully qualified heading numbering
|
||||
} else {
|
||||
link(loc, [#fullValue.map((x) => str(x)).join(".")])
|
||||
}
|
||||
} else {
|
||||
panic("referencing unknown type: ", item.func())
|
||||
}
|
||||
}
|
||||
|
||||
#let __ref-no-element(element) = context {
|
||||
// Ensure that we pass an element
|
||||
if type(element) != content {
|
||||
panic("can only reference elements of type content")
|
||||
}
|
||||
let loc = element.location()
|
||||
let elem = query(loc)
|
||||
let fig = elem.at(0)
|
||||
if fig.func() != figure {
|
||||
panic("referencing unknown type: " + fig.func())
|
||||
}
|
||||
fig.caption.counter.at(loc).at(0)
|
||||
}
|
||||
|
||||
// Constructs a reference from multiple targets
|
||||
#let custom-ref(..targets) = context {
|
||||
let collected = (:)
|
||||
|
||||
for target in targets.pos() {
|
||||
let loc = locate(target)
|
||||
let elem = query(target)
|
||||
|
||||
let fig = elem.at(0)
|
||||
if fig.func() != figure {
|
||||
panic("referencing unknown type")
|
||||
}
|
||||
|
||||
// determine what we...
|
||||
let element = fig.body;
|
||||
let elementName = "unknown";
|
||||
let found = false;
|
||||
while not found {
|
||||
|
||||
// If it's a grid
|
||||
if (element.func() == grid) {
|
||||
for cell in element.children {
|
||||
if cell.body.func() == image {
|
||||
elementName = "pav."
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
if (element.func() == table) {
|
||||
elementName = "lentelė"
|
||||
found = true
|
||||
break
|
||||
}
|
||||
|
||||
if (element.func() == raw) {
|
||||
elementName = "kodo frag."
|
||||
found = true
|
||||
break
|
||||
}
|
||||
|
||||
if (element.func() == image) {
|
||||
elementName = "pav."
|
||||
found = true
|
||||
break
|
||||
}
|
||||
|
||||
panic("unknown element", element.func())
|
||||
}
|
||||
|
||||
if elementName not in collected {
|
||||
collected.insert(elementName, ())
|
||||
}
|
||||
|
||||
collected.at(elementName).push(
|
||||
(loc, fig.caption.counter.at(loc).at(0))
|
||||
)
|
||||
}
|
||||
|
||||
if collected.len() > 1 {
|
||||
panic("multiple types detected")
|
||||
}
|
||||
|
||||
for type in collected {
|
||||
let name = type.at(0)
|
||||
let arr = type.at(1).sorted(key: k => k.at(1))
|
||||
|
||||
[(žr. #arr.map(x =>link(x.at(0), [#x.at(1)])).join(", ") #name)]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Returns a KTU template-conformant outline.
|
||||
/// - depth (int | none): Same as outline depth.
|
||||
/// - indent (auto | function | relative): Same as outline indent.
|
||||
@@ -214,7 +125,7 @@
|
||||
depth: none,
|
||||
indent: 0em, // Disable the default outline indenting
|
||||
target: heading,
|
||||
title: auto
|
||||
title: auto,
|
||||
) = {
|
||||
// TODO: įtrauka
|
||||
set block(spacing: 0em)
|
||||
@@ -222,6 +133,9 @@
|
||||
show outline: o => context {
|
||||
// If it's a heading, show the default outline with bold text
|
||||
if (o.target == selector(heading)) {
|
||||
// Determine whether to uppercase section titles based on the global setting
|
||||
let isUpper = __UPPERCASE_SECTION_TITLES.get()
|
||||
|
||||
// Define known target widths based on KTU template
|
||||
let targets = (0.64cm, 0.96cm, 1.28cm, 1.6cm, 1.92cm)
|
||||
|
||||
@@ -229,17 +143,40 @@
|
||||
show outline.entry: it => {
|
||||
// Recompute the gap based on the prefix content, so that the outline entry is indented
|
||||
// from the left regardless of the length of the prefix (based on the requirement)
|
||||
let prefixContent = it.prefix()
|
||||
let measurement = measure(prefixContent)
|
||||
let target = targets.at(it.level - 1, default: 0.64cm)
|
||||
let newGap = target - measurement.width
|
||||
if it.element.body.has("children") and it.element.body.children.at(0) == metadata("appendix-heading") {
|
||||
target = 0.64cm
|
||||
let isAppendix = __is-appendix-heading(it.element)
|
||||
|
||||
// Appendices are listed as "N priedas. Pavadinimas", the number being the prefix
|
||||
let prefixContent = if isAppendix {
|
||||
context [#__appendix-number(it.element)]
|
||||
} else {
|
||||
it.prefix()
|
||||
}
|
||||
let measurement = measure(prefixContent)
|
||||
let target = if isAppendix { 0.64cm } else { targets.at(it.level - 1, default: 0.64cm) }
|
||||
let newGap = target - measurement.width
|
||||
|
||||
// Uppercase body if need be
|
||||
let bodyContent = it.element.body
|
||||
if isAppendix {
|
||||
let title = __appendix-title(it.element)
|
||||
let name = __figure-kinds.appendix.supplement
|
||||
bodyContent = if title == none { [#name] } else { [#name. #title] }
|
||||
} else if isUpper and (it.level == 1 or it.element.numbering == none) {
|
||||
bodyContent = upper(bodyContent)
|
||||
}
|
||||
|
||||
// Reconstruct the it.inner content with the new body
|
||||
let formattedInner = {
|
||||
bodyContent
|
||||
[ ] // whitespace is required for backwards compat
|
||||
box(width: 1fr, it.fill)
|
||||
[ ] // whitespace is required for backwards compat
|
||||
it.page()
|
||||
}
|
||||
|
||||
link(
|
||||
it.element.location(),
|
||||
it.indented(prefixContent, it.inner(), gap: newGap),
|
||||
it.indented(prefixContent, formattedInner, gap: newGap),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -252,7 +189,10 @@
|
||||
} else if (o.target == figure.where(kind: image)) {
|
||||
show outline.entry: it => link(
|
||||
it.element.location(),
|
||||
it.indented([*#__ref-no-element(it.element) #figureNames.image.*], [ #it.inner()], gap: 0pt),
|
||||
it.indented(
|
||||
[*#__caption-label(it.element)*],
|
||||
[ #it.inner()], gap: 0pt
|
||||
),
|
||||
)
|
||||
o
|
||||
|
||||
@@ -260,7 +200,10 @@
|
||||
} else if (o.target == figure.where(kind: table)) {
|
||||
show outline.entry: it => link(
|
||||
it.element.location(),
|
||||
it.indented([*#__ref-no-element(it.element) #figureNames.table.*], [ #it.inner()], gap: 0pt),
|
||||
it.indented(
|
||||
[*#__caption-label(it.element)*],
|
||||
[ #it.inner()], gap: 0pt
|
||||
),
|
||||
)
|
||||
o
|
||||
|
||||
@@ -268,7 +211,10 @@
|
||||
} else if (o.target == figure.where(kind: raw)) {
|
||||
show outline.entry: it => link(
|
||||
it.element.location(),
|
||||
it.indented([*#__ref-no-element(it.element) #figureNames.code.*], [ #it.inner()], gap: 0pt),
|
||||
it.indented(
|
||||
[*#__caption-label(it.element)*],
|
||||
[ #it.inner()], gap: 0pt
|
||||
),
|
||||
)
|
||||
o
|
||||
|
||||
@@ -284,9 +230,13 @@
|
||||
#(o.target == selector(heading))
|
||||
]*/
|
||||
|
||||
// Any other figure kind (generally, user defined kinds)
|
||||
show outline.entry: it => link(
|
||||
it.element.location(),
|
||||
it.indented([*#__ref-no-element(it.element) unknown.*], it.inner(), gap: 0pt),
|
||||
it.indented(
|
||||
[*#__caption-label(it.element)*],
|
||||
[ #it.inner()], gap: 0pt
|
||||
),
|
||||
)
|
||||
o
|
||||
}
|
||||
@@ -294,19 +244,6 @@
|
||||
outline(depth: depth, indent: indent, target: target, title: title)
|
||||
}
|
||||
|
||||
#let func-to-name(func) = {
|
||||
if func == table {
|
||||
return "lentelė"
|
||||
}
|
||||
if func == image {
|
||||
return "pav."
|
||||
}
|
||||
if func == grid {
|
||||
return "pav."
|
||||
}
|
||||
return func
|
||||
}
|
||||
|
||||
// Doesn't work in Typst 0.12.0 due to relative paths
|
||||
#let bibliography-list(path) = {
|
||||
bibliography(path, title: "Literatūros sąrašas", full: true)
|
||||
@@ -322,7 +259,7 @@
|
||||
depth: none,
|
||||
indent: 0em, // Disable the default outline indenting
|
||||
target: heading,
|
||||
title: auto
|
||||
title: auto,
|
||||
) = {
|
||||
__ktu_outline(depth: depth, indent: indent, target: target, title: title)
|
||||
}
|
||||
@@ -339,6 +276,10 @@
|
||||
ktu-outline(title: heading("Paveikslų sąrašas", outlined: true), target: figure.where(kind: image))
|
||||
}
|
||||
|
||||
#let ktu-code-list() = {
|
||||
ktu-outline(title: heading("Kodo fragmentų sąrašas", outlined: true), target: figure.where(kind: raw))
|
||||
}
|
||||
|
||||
/// Define a custom outline for a specific figure type.
|
||||
/// This function creates an outline entry with a specified title and figure type.
|
||||
/// The outline entry will link to the figure of the specified type.
|
||||
@@ -348,20 +289,59 @@
|
||||
__ktu_outline(title: heading(title, outlined: true), target: figure.where(kind: kind))
|
||||
}
|
||||
|
||||
#let setup-code(body) = {
|
||||
show: codly-init.with()
|
||||
codly(
|
||||
/// 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",
|
||||
spacing: 80%,
|
||||
fill: white,
|
||||
zebra-fill: none,
|
||||
stroke: none,
|
||||
stroke: 0.5pt + black,
|
||||
numbers: true,
|
||||
radius: 0pt,
|
||||
display-name: false,
|
||||
display-icon: false,
|
||||
)
|
||||
|
||||
/// Applies the code block styling to the body.
|
||||
/// - code (dictionary | none): Options, merged over `__CODE_DEFAULTS`.
|
||||
/// `none` leaves raw blocks untouched.
|
||||
#let __setup-code(code, body) = {
|
||||
if code == none {
|
||||
return body
|
||||
}
|
||||
let opts = __CODE_DEFAULTS + code
|
||||
let known = __CODE_DEFAULTS.keys()
|
||||
for key in opts.keys() {
|
||||
assert(
|
||||
key in known,
|
||||
message: "ktu-paper: unknown `code` option \"" + key + "\", expected one of: " + known.join(", "),
|
||||
)
|
||||
show raw: set text(font: "Hack", spacing: 80%)
|
||||
}
|
||||
|
||||
show raw.where(block: true): codly.new
|
||||
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,
|
||||
display-icon: opts.display-icon,
|
||||
)
|
||||
show raw: set text(font: opts.font, spacing: opts.spacing)
|
||||
body
|
||||
}
|
||||
|
||||
#let __page_rules(body) = {
|
||||
#let __page_rules(font: "Times New Roman", body) = {
|
||||
// Page size and margins
|
||||
set page(
|
||||
paper: "a4",
|
||||
@@ -371,8 +351,8 @@
|
||||
left: 30mm,
|
||||
right: 10mm,
|
||||
bottom: 20mm,
|
||||
top: 20mm
|
||||
)
|
||||
top: 20mm,
|
||||
),
|
||||
)
|
||||
set page(width: 595pt, height: 842pt)
|
||||
|
||||
@@ -386,11 +366,11 @@
|
||||
set heading(numbering: "1.")
|
||||
|
||||
// Number equations
|
||||
set math.equation(numbering: "(1)")
|
||||
set math.equation(numbering: __equation-numbering)
|
||||
|
||||
// Set text font
|
||||
set text(
|
||||
font: "Times New Roman",
|
||||
font: font,
|
||||
size: 12pt,
|
||||
lang: "lt",
|
||||
// Change where the bounding box is drawn for the text
|
||||
@@ -411,8 +391,13 @@
|
||||
body
|
||||
}
|
||||
|
||||
#let setup-page(body) = {
|
||||
show: __page_rules.with()
|
||||
#let setup-page(
|
||||
font: "Times New Roman",
|
||||
uppercaseSectionTitles: false,
|
||||
unnumberedHeadingAlignment: center,
|
||||
body,
|
||||
) = {
|
||||
show: __page_rules.with(font: font)
|
||||
|
||||
// Pagal formaliuosius rašto darbų reikalavimus
|
||||
|
||||
@@ -424,6 +409,14 @@
|
||||
set par(justify: true)
|
||||
set linebreak(justify: true)
|
||||
|
||||
let maybe-uppercase(body) = {
|
||||
if uppercaseSectionTitles {
|
||||
upper(body)
|
||||
} else {
|
||||
body
|
||||
}
|
||||
}
|
||||
|
||||
// Antraštės
|
||||
// Force them into blocks so they don't count as paragraphs
|
||||
show heading: it => {
|
||||
@@ -439,40 +432,59 @@
|
||||
|
||||
// TODO: intervalas tarp eilučių – 1,15 kiekvienai antraštei
|
||||
|
||||
// Priedas: kiekvienas pradedamas naujame lape, dešiniajame viršutiniame
|
||||
// kampe rašoma "N priedas", pavadinimas (jei yra) – kaip skyriaus pavadinimas
|
||||
if __is-appendix-heading(it) {
|
||||
align(right, block(below: 10pt, text(weight: "regular")[
|
||||
#__appendix-number(it) #__figure-kinds.appendix.supplement
|
||||
]))
|
||||
let title = __appendix-title(it)
|
||||
if title != none {
|
||||
block(below: 10pt, title)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Antraštė be nr.
|
||||
if it.numbering == none {
|
||||
// Centruota lygiuotė
|
||||
set align(center)
|
||||
// Centruota lygiuotė by default, but can be overridden by the user
|
||||
let explicitlyAlignLeft = (
|
||||
it.body.has("children")
|
||||
and it.body.children.len() > 1
|
||||
and it.body.children.at(1) == __METADATA_HEADING_ALIGN_LEFT
|
||||
)
|
||||
|
||||
// If the user explicitly set alignLeft to true, we should align left regardless of the global setting
|
||||
let targetAlign = if explicitlyAlignLeft { left } else { unnumberedHeadingAlignment }
|
||||
|
||||
set align(targetAlign)
|
||||
|
||||
// atstumas prieš ir po antraštės - 10 pt
|
||||
block[#it.body]
|
||||
block[#maybe-uppercase(it.body)]
|
||||
if useExperiment {
|
||||
v(10pt)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Skyrius
|
||||
if it.numbering != none and it.level == 1 {
|
||||
// abipusė lygiuotė
|
||||
set par(justify: true)
|
||||
//set align
|
||||
|
||||
// Reset figure counters if numbering per section is enabled
|
||||
if __FIG_PER_SECTION.get() {
|
||||
__reset-figure-counters()
|
||||
}
|
||||
|
||||
// po antraštės - 10 pt
|
||||
block[#counter(heading).display() #it.body]
|
||||
block[#counter(heading).display() #maybe-uppercase(it.body)]
|
||||
if useExperiment {
|
||||
v(10pt)
|
||||
}
|
||||
}
|
||||
|
||||
// Determine whether the heading has appending metadata attached and adjust its display accordingly
|
||||
let isAppendixHeading = it.body.has("children") and it.body.children.at(0) == metadata("appendix-heading")
|
||||
if isAppendixHeading {
|
||||
block[#counter(heading).display(it.numbering) #it.body]
|
||||
}
|
||||
|
||||
// Poskyris ir skyrelis
|
||||
if not isAppendixHeading and it.numbering != none and it.level != 1 {
|
||||
if it.numbering != none and it.level != 1 {
|
||||
// abipusė lygiuotė
|
||||
set par(justify: true)
|
||||
|
||||
@@ -487,94 +499,75 @@
|
||||
}
|
||||
}
|
||||
|
||||
// Override references for equations
|
||||
show ref: it => {
|
||||
let el = it.element
|
||||
// Reference style and numbering
|
||||
show ref: it => __format-ref(it)
|
||||
|
||||
if el == none {
|
||||
return it
|
||||
}
|
||||
// Figure captions and numbering
|
||||
show figure: it => __format-figure(it)
|
||||
|
||||
// Override equation references
|
||||
if el.func() == math.equation {
|
||||
link(
|
||||
el.location(),
|
||||
numbering(el.numbering, ..counter(math.equation).at(el.location()))
|
||||
)
|
||||
// Override references to figures
|
||||
} else if el.func() == figure {
|
||||
let fig = el.body
|
||||
let figType = fig.func()
|
||||
link(el.location(), [
|
||||
(žr. #numbering(el.numbering, ..counter(figure.where(kind: figType)).at(el.location())) #func-to-name(figType))
|
||||
])
|
||||
} else {
|
||||
it
|
||||
}
|
||||
}
|
||||
|
||||
// Change captions for figures
|
||||
show figure: it => {
|
||||
let separator = [.]
|
||||
let caption = it.caption
|
||||
|
||||
// If caption is not provided, just show the figure body
|
||||
if caption == none {
|
||||
it.body
|
||||
return
|
||||
}
|
||||
|
||||
let counter = caption.counter
|
||||
let supplement = caption.supplement
|
||||
|
||||
if it.body.func() == math.equation {
|
||||
supplement = figureNames.equation
|
||||
} else if it.kind == image {
|
||||
supplement = figureNames.image
|
||||
} else if it.kind == table {
|
||||
supplement = figureNames.table
|
||||
} else if it.kind == raw {
|
||||
supplement = figureNames.code
|
||||
}
|
||||
|
||||
|
||||
// Tables have captions at the top
|
||||
set text(size: 11pt)
|
||||
if it.kind == table {
|
||||
{set align(left)
|
||||
[*#context counter.display(caption.numbering) #supplement#separator* #caption.body]}
|
||||
it.body
|
||||
} else {
|
||||
it.body
|
||||
[*#context counter.display(caption.numbering) #supplement#separator* #caption.body]
|
||||
}
|
||||
}
|
||||
|
||||
// Lentelės pirma eilutė
|
||||
/*
|
||||
show table.cell.where(y: 0): it => context {
|
||||
set align(left)
|
||||
set par(justify: false)
|
||||
set text(size: TableHeadSize.get()) // Šrifto dydis
|
||||
v(3pt)
|
||||
// Paryškintas
|
||||
[*#it*]
|
||||
v(3pt)
|
||||
}
|
||||
|
||||
show table.cell: it => context {
|
||||
set align(left)
|
||||
set par(justify: false)
|
||||
set text(size: TableCellSize.get())
|
||||
v(3pt)
|
||||
[#it]
|
||||
v(3pt)
|
||||
}*/
|
||||
|
||||
// Set bibliography and citing style
|
||||
// Bibliography citing style
|
||||
set bibliography(style: "assets/iso690-numeric-lt.csl")
|
||||
|
||||
// Return the body
|
||||
// Block equations are left-aligned
|
||||
show math.equation.where(block: true): it => {
|
||||
align(left, it)
|
||||
}
|
||||
|
||||
body
|
||||
}
|
||||
|
||||
/// Configure the template for a KTU paper.
|
||||
/// - font (str): Text font to use for the paper.
|
||||
/// - figureNumberingPerSection (bool): Whether to number figures per section rather than globally.
|
||||
/// - uppercaseSectionTitles (bool): Whether to uppercase section titles.
|
||||
/// - unnumberedHeadingAlignment (alignment): Alignment for unnumbered headings.
|
||||
/// - figureKinds (dictionary): Extra figure kinds, e.g.
|
||||
/// `(command: (supplement: "komanda", ref-name: "komanda", single-name: "komanda"))`.
|
||||
/// Use them with `figure(kind: "command", ...)`. Keys:
|
||||
/// - `supplement` (required): text after the number in captions, e.g. "1 komanda.".
|
||||
/// - `ref-name`: text used in references, e.g. "(žr. 1 komanda)". Defaults to `supplement`.
|
||||
/// Can also be a function `count => string`, called with the number of elements
|
||||
/// referenced together, for kinds whose wording depends on it, e.g.
|
||||
/// `count => if count == 1 { "komandą" } else { "komandas" }`.
|
||||
/// - `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,
|
||||
// but some modules may require them
|
||||
uppercaseSectionTitles: false,
|
||||
unnumberedHeadingAlignment: center,
|
||||
body,
|
||||
) = context {
|
||||
show: setup-page.with(
|
||||
font: font,
|
||||
uppercaseSectionTitles: uppercaseSectionTitles,
|
||||
unnumberedHeadingAlignment: unnumberedHeadingAlignment,
|
||||
)
|
||||
__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)
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
#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
|
||||
)
|
||||
|
||||
#show: ktu-paper.with(
|
||||
font: "Times New Roman", // or Arial
|
||||
figureNumberingPerSection: true,
|
||||
figureKinds: (
|
||||
veryCustomKind: (supplement: "komanda", ref-name: "komanda"),
|
||||
),
|
||||
// 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],
|
||||
subtitles: (
|
||||
"Laboratorinio darbo ataskaita",
|
||||
highlight[Studijų modulio pavadinimas (kodas)]
|
||||
),
|
||||
authors: (
|
||||
(highlight[Vardenis Pavardenis], "Ataskaitą parengė"),
|
||||
(highlight[Pareigų ir mokslo laipsnio sutrumpinimas Vardenis Pavardenis], "Laboratoriniam darbui vadovavo"),
|
||||
),
|
||||
authorNamesFirst: false,
|
||||
place: "Kaunas",
|
||||
year: datetime.today().year(),
|
||||
)
|
||||
#pagebreak()
|
||||
#set page(numbering: "1")
|
||||
|
||||
#ktu-table-of-contents()
|
||||
#pagebreak()
|
||||
|
||||
#ktu-picture-list()
|
||||
#pagebreak()
|
||||
|
||||
#ktu-table-list()
|
||||
#pagebreak()
|
||||
|
||||
#ktu-code-list()
|
||||
#pagebreak()
|
||||
|
||||
#unnumbered-heading[= Įvadas]
|
||||
#lorem(50)
|
||||
|
||||
#pagebreak()
|
||||
= Skyrius
|
||||
#lorem(50)
|
||||
|
||||
== Poskyrius
|
||||
#lorem(50)
|
||||
|
||||
=== Dalis
|
||||
#lorem(50)
|
||||
|
||||
#pagebreak()
|
||||
= Komponentai
|
||||
|
||||
== Paveikslai
|
||||
Galima gauti paveikslo numerį #ref-no(<image-label>) arba visą paveikslo nuorodą #custom-ref(<image-label>).
|
||||
|
||||
#figure(
|
||||
image("images/santaka.png", width: 70%),
|
||||
caption: [
|
||||
Paveikslo pavadinimas
|
||||
],
|
||||
) <image-label>
|
||||
|
||||
|
||||
== Paveikslų "grid" išdėstymas
|
||||
Paveikslus taip pat galima sudėti į "grid" išdėstymą, į jį kreiptis kaip numerį #ref-no(<image-grid-label>) arba visą nuorodą #custom-ref(<image-grid-label>).
|
||||
|
||||
#figure(grid(
|
||||
columns: 2,
|
||||
gutter: 2mm,
|
||||
image("images/santaka.png", width: 100%),
|
||||
image("images/santaka.png", width: 100%),
|
||||
), caption: [
|
||||
Paveikslėliai "grid'e"
|
||||
]) <image-grid-label>
|
||||
|
||||
|
||||
== Lentelės
|
||||
|
||||
Galima gauti lentelės numerį /*#ref-no(<table-label>)*/ arba visą lentelės nuorodą #custom-ref(<table-label>).
|
||||
|
||||
#figure(
|
||||
ktu-table(
|
||||
columns: (auto, 1fr, 1fr, 1fr),
|
||||
align: (x, y) => { horizon + left },
|
||||
table.header([*Stulpelio pavadinimas*], [*Stulpelio pavadinimas*], [*Stulpelio pavadinimas*], [*Stulpelio pavadinimas*]),
|
||||
[Eilutė 1], [...], [...], [...],
|
||||
[Eilutė 2], [...], [...], [...],
|
||||
[Eilutė 3], [...], [...], [...],
|
||||
[Eilutė 4], [...], [...], [...],
|
||||
),
|
||||
caption: [Lentelės pavadinimas],
|
||||
) <table-label>
|
||||
|
||||
|
||||
== Formulės
|
||||
Formules galima išreikšti eilutėje, pavyzdžiui $E = m c^2$ arba atskiroje eilutėje, pavyzdžiui:
|
||||
$
|
||||
E = m c^2
|
||||
$ <formula-label>
|
||||
|
||||
// TODO: fix
|
||||
Formulės atskiroje eilutėje numeruojamos besąlygiškai, galima gauti formulės numerį #ref-no(<formula-label>) arba visą formulės nuorodą #custom-ref(<formula-label>).
|
||||
|
||||
== Kodo fragmentai
|
||||
Kodo fragmentus galima išreikšti eilutėje, pavyzdžiui `print("Hello, world!")` arba atskiroje eilutėje, pavyzdžiui:
|
||||
#figure(```python
|
||||
def main():
|
||||
print("Hello, world!")
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
```, caption: [
|
||||
Python kodas
|
||||
]) <code-label>
|
||||
|
||||
Galima gauti kodo fragmento numerį #ref-no(<code-label>) arba visą kodo fragmento nuorodą #custom-ref(<code-label>).
|
||||
|
||||
== Naudotojo apibrėžtos figūros
|
||||
|
||||
Naudotojai tai pat gali apibrėžti savo figūras, pavyzdžiui, komandų fragmentus. Pavyzdžiui, galima apibrėžti komandų fragmentą su papildoma informacija ir naudoti jį dokumente. Galima gauti kodo fragmento numerį #ref-no(<custom-figure-label>) arba visą kodo fragmento nuorodą #custom-ref(<custom-figure-label>).
|
||||
|
||||
#figure(
|
||||
```sh
|
||||
npm install foo
|
||||
```,
|
||||
kind: "veryCustomKind",
|
||||
supplement: "...",
|
||||
caption: [Diegimo komanda],
|
||||
) <custom-figure-label>
|
||||
|
||||
#pagebreak()
|
||||
= Išvados
|
||||
#lorem(50)
|
||||
|
||||
#pagebreak()
|
||||
#ktu-gen-ai-usage-declaration-page()
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 593 KiB |
File renamed without changes.
+14
-13
@@ -1,13 +1,14 @@
|
||||
#import "@local/ktu-paper:0.1.0": (
|
||||
setup-page, setup-code,
|
||||
#import "@local/ktu-paper:0.5.1": (
|
||||
ktu-paper,
|
||||
ktu-table-of-contents, ktu-picture-list, ktu-table-list,
|
||||
ktu-heading-page-normal,
|
||||
ktu-table,
|
||||
custom-ref, ref-no
|
||||
)
|
||||
|
||||
#show: setup-page.with()
|
||||
#show: setup-code.with()
|
||||
#show: ktu-paper.with(
|
||||
font: "Times New Roman",
|
||||
)
|
||||
|
||||
#show math.equation: it => {
|
||||
show regex("\d+\.\d+"): it => {show ".": {","+h(0pt)}
|
||||
@@ -92,7 +93,7 @@ show table.cell: set text(size: 8pt)
|
||||
Duomenų sklaidą yra patogu pavaizduoti ir stačiakampe diagrama:
|
||||
|
||||
#figure(
|
||||
image("image.jpeg", width: 70%),
|
||||
image("images/santaka.png", width: 70%),
|
||||
caption: [
|
||||
Skaitinių atributų stačiakampė diagrama
|
||||
],
|
||||
@@ -134,8 +135,8 @@ Paveikslėlius galima grupuoti į "grid" #custom-ref(<image-grid-2>, <image-grid
|
||||
#figure(grid(
|
||||
columns: 2,
|
||||
gutter: 2mm,
|
||||
image("image.jpeg", width: 100%),
|
||||
image("image.jpeg", width: 100%),
|
||||
image("images/santaka.png", width: 100%),
|
||||
image("images/santaka.png", width: 100%),
|
||||
), caption: [
|
||||
Paveikslėliai "grid'e" 1
|
||||
]) <image-grid-2>
|
||||
@@ -143,11 +144,11 @@ Paveikslėlius galima grupuoti į "grid" #custom-ref(<image-grid-2>, <image-grid
|
||||
#figure(grid(
|
||||
columns: 3,
|
||||
gutter: 2mm,
|
||||
image("image.jpeg", width: 100%),
|
||||
image("image.jpeg", width: 100%),
|
||||
image("image.jpeg", width: 100%),
|
||||
image("image.jpeg", width: 100%),
|
||||
image("image.jpeg", width: 100%),
|
||||
image("images/santaka.png", width: 100%),
|
||||
image("images/santaka.png", width: 100%),
|
||||
image("images/santaka.png", width: 100%),
|
||||
image("images/santaka.png", width: 100%),
|
||||
image("images/santaka.png", width: 100%),
|
||||
), caption: [
|
||||
Paveikslėliai "grid'e" 2
|
||||
]) <image-grid-3>
|
||||
@@ -188,7 +189,7 @@ $
|
||||
čia $X$ -- imtis, $mu$ -- imties vidurkis, $sigma$ -- imties standartinis nuokrypis. Fragmentas pateikiamas #ref-no(<image-1>) paveikslėlyje.
|
||||
|
||||
#figure(
|
||||
image("image.jpeg", width: 90%),
|
||||
image("images/santaka.png", width: 90%),
|
||||
caption: [
|
||||
Paveikslėlio pavadinimas
|
||||
],
|
||||
|
||||
+6
-5
@@ -1,5 +1,5 @@
|
||||
#import "@local/ktu-paper:0.1.0": (
|
||||
setup-page, setup-code,
|
||||
#import "@local/ktu-paper:0.5.1": (
|
||||
ktu-paper,
|
||||
ktu-table-of-contents, ktu-picture-list, ktu-table-list,
|
||||
ktu-heading-page-normal,
|
||||
ktu-table,
|
||||
@@ -7,8 +7,9 @@
|
||||
custom-ref, ref-no
|
||||
)
|
||||
|
||||
#show: setup-page.with()
|
||||
#show: setup-code.with()
|
||||
#show: ktu-paper.with(
|
||||
font: "Times New Roman",
|
||||
)
|
||||
|
||||
#show figure: it => {
|
||||
set block(breakable: true)
|
||||
@@ -189,7 +190,7 @@ Eu eum decore inimicus consetetur, cu usu habeo corpora intellegam. Ut antiopam
|
||||
Lorem ipsum dolor sit amet, eam ex decore persequeris, sit at illud lobortis atomorum. Sed dolorem quaerendum ne, prompta instructior ne pri. Et mel partiendo suscipiantur, docendi abhorreant ea sit. Recteque imperdiet eum te.
|
||||
|
||||
#figure(
|
||||
image("Picture.png", width: 11.2cm, height: 8cm),
|
||||
image("images/santaka.png", width: 11.2cm, height: 8cm),
|
||||
caption: [
|
||||
Kauno technologijos universiteto „Santakos“ slėnio fasadas
|
||||
],
|
||||
|
||||
Executable
+43
@@ -0,0 +1,43 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Clean up previous test results
|
||||
if [ -d "tests/original-res" ]; then
|
||||
rm -r tests/original-res
|
||||
fi
|
||||
if [ -d "tests/modified-res" ]; then
|
||||
rm -r tests/modified-res
|
||||
fi
|
||||
if [ -d "tests/modified" ]; then
|
||||
rm -r tests/modified
|
||||
fi
|
||||
if [ -d "tests/original/src" ]; then
|
||||
rm -r tests/original/src
|
||||
fi
|
||||
|
||||
mkdir -p tests/original-res
|
||||
mkdir -p tests/modified-res
|
||||
|
||||
# Copy current template
|
||||
cp -r src/ tests/original/src
|
||||
|
||||
cp -r tests/original tests/modified
|
||||
# replace the "#import "@local/ktu-paper:0.1.0""
|
||||
# with "#import "./src/lib.typ"" in the modified files
|
||||
find tests/modified -type f -name "*.typ" -exec \
|
||||
sed -i 's/#import "@local\/ktu-paper:0.1.0"/#import ".\/src\/lib.typ"/g' {} \;
|
||||
find tests/modified -type f -name "ataskaita.typ" -exec \
|
||||
sed -i 's/setup-page/ktu-paper/g' {} \;
|
||||
|
||||
# Compile the original document
|
||||
typst compile --root tests/original tests/original/ataskaita.typ "tests/original-res/{0p}.png"
|
||||
# Compile the modified document
|
||||
typst compile --root tests/modified tests/modified/ataskaita.typ "tests/modified-res/{0p}.png"
|
||||
typst compile --root tests/modified tests/modified/ataskaita.typ "tests/modified.pdf"
|
||||
|
||||
# Compare the results
|
||||
diff -r tests/original-res tests/modified-res
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "No differences found between original and modified results."
|
||||
else
|
||||
echo "Differences found between original and modified results."
|
||||
fi
|
||||
+3
-3
@@ -1,9 +1,9 @@
|
||||
[package]
|
||||
name = "ktu-paper"
|
||||
version = "0.1.0"
|
||||
compiler = "0.12.0"
|
||||
version = "0.5.1"
|
||||
compiler = "0.15.0"
|
||||
entrypoint = "src/lib.typ"
|
||||
repository = "https://git.svetikas.lt/JustAnyone/dotfiles"
|
||||
repository = "https://github.com/svetikas/ktu-paper"
|
||||
authors = ["Dominykas Svetikas <https://svetikas.lt>"]
|
||||
license = "MIT"
|
||||
description = "KTU report template to use for writing lab reports or final thesis."
|
||||
|
||||
Reference in new issue
Block a user