style: use consistent 2 space indentation

This commit is contained in:
JustAnyone committed 2026-10-15 00:21:18 +03:00
1 parent f8a747e6b3
commit 71b83ab97f
3 files changed
+537 -529

No files matched your search

+3 -3
View File
@@ -1,7 +1,7 @@
/// Whether to number figures per section or not. /// Whether to number figures per section or not.
/// If true, figures will be numbered like "1.1", "1.2", "2.1", etc. /// 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. /// If false, figures will be numbered like "1", "2", "3", etc.
/// ///
/// TODO: figure out how to deal with numbering on sections such as /// TODO: figure out how to deal with numbering on sections such as
/// Appendix and other non-standard sections. /// Appendix and other non-standard sections.
#let __FIG_PER_SECTION = state("svetikas.lt/ktu-paper/figure-numbering-per-section", false) #let __FIG_PER_SECTION = state("svetikas.lt/ktu-paper/figure-numbering-per-section", false)
@@ -13,10 +13,10 @@
#let __DEBUG_AUTHOR_TABLE = state("$ktu-template-DEBUG_AUTHOR_TABLE", false) #let __DEBUG_AUTHOR_TABLE = state("$ktu-template-DEBUG_AUTHOR_TABLE", false)
#let debug-author-table() = { #let debug-author-table() = {
__DEBUG_AUTHOR_TABLE.update(true) __DEBUG_AUTHOR_TABLE.update(true)
} }
#let __HEADING_EXPERIMENT = state("$ktu-template-HEADING_EXPERIMENT", false) #let __HEADING_EXPERIMENT = state("$ktu-template-HEADING_EXPERIMENT", false)
#let enable-heading-experiment() = { #let enable-heading-experiment() = {
__HEADING_EXPERIMENT.update(true) __HEADING_EXPERIMENT.update(true)
} }
+211 -205
View File
@@ -3,225 +3,231 @@
/// Wrapper around the table function that returns a KTU style conformant table. /// Wrapper around the table function that returns a KTU style conformant table.
/// This includes setting text size to 10 pt. /// This includes setting text size to 10 pt.
#let ktu-table(..args) = { #let ktu-table(..args) = {
show table: it => { show table: it => {
set text(size: 10pt) set text(size: 10pt)
// TODO: FIXME line spacing is defined differently // TODO: FIXME line spacing is defined differently
set par(leading: 1em - 0.75em) // intervalas tarp eilučių -- 1 set par(leading: 1em - 0.75em) // intervalas tarp eilučių -- 1
it it
} }
table( table(
..args ..args
) )
} }
#let ktu-author-table( #let ktu-author-table(
authors: (), authors: (),
alignment: right, alignment: right,
namesFirst: true, // if false, roles will be displayed first namesFirst: true, // if false, roles will be displayed first
) = context { ) = context {
// The layout should be a list of lists whose elements are (name, role) pairs. // 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") assert(authors.len() > 0, message: "author table must have at least one author")
assert(authors.all(it => it.len() == 2), message: "each author entry must be a pair of name and role") assert(authors.all(it => it.len() == 2), message: "each author entry must be a pair of name and role")
let frame(color) = (x, y) => ( let frame(color) = (x, y) => (
left: 0pt, left: 0pt,
right: 0pt, right: 0pt,
top: if y == 0 { 0.5pt + color } else { 0pt }, top: if y == 0 { 0.5pt + color } else { 0pt },
bottom: 0.5pt + color, bottom: 0.5pt + color,
) )
set table( set table(
inset: 5.4pt, inset: 5.4pt,
stroke: if __DEBUG_AUTHOR_TABLE.get() { stroke: if __DEBUG_AUTHOR_TABLE.get() {
0.5pt + rgb("D4AF37") 0.5pt + rgb("D4AF37")
} else {
frame(rgb("D4AF37"))
},
)
show table.cell: it => context {
[#it]
if it.body == [] {
v(10pt)
} else {
v(0pt)
}
}
if alignment == center {
align(center, table(
columns: (198.5pt + 56.7pt),
table.header([]),
..for author in authors {
let (name, role) = author
name = [*#name*]
if not namesFirst {
(role, name) = (name, role)
}
(align(center)[
#set block(below: 8pt)
#block[#name]
#block[#role]
], [])
}
))
} else { } else {
align(alignment, table( frame(rgb("D4AF37"))
columns: (198.5pt, 56.7pt), },
table.header( )
[], [], show table.cell: it => context {
), [#it]
..for author in authors { if it.body == [] {
let (name, role) = author v(10pt)
name = [*#name*] } else {
if not namesFirst { v(0pt)
(role, name) = (name, role)
}
(align(left)[
#set block(below: 8pt)
#block[#name]
#block[#role]
], [], [], [])
}
))
} }
}
if alignment == center {
align(center, table(
columns: (198.5pt + 56.7pt),
table.header([]),
..for author in authors {
let (name, role) = author
name = [*#name*]
if not namesFirst {
(role, name) = (name, role)
}
(
align(center)[
#set block(below: 8pt)
#block[#name]
#block[#role]
],
[],
)
}
))
} else {
align(alignment, table(
columns: (198.5pt, 56.7pt),
table.header([], []),
..for author in authors {
let (name, role) = author
name = [*#name*]
if not namesFirst {
(role, name) = (name, role)
}
(
align(left)[
#set block(below: 8pt)
#block[#name]
#block[#role]
],
[],
[],
[],
)
},
))
}
} }
/// This function constructs the title page header block for KTU reports. It includes the university logo, name, subheaders, the main and sub titles of the report. /// This function constructs the title page header block for KTU reports. It includes the university logo, name, subheaders, the main and sub titles of the report.
/// ///
/// - bigTitle (content): The main title of the report, usually the name of the work. Displayed in 18 pt font. /// - bigTitle (content): The main title of the report, usually the name of the work. Displayed in 18 pt font.
/// - subTitles (): Additional titles or information to be displayed under the main title, such as the type of work. Displayed in 14 pt font. If not provided, defaults to "Rašto darbo tipas". /// - subTitles (): Additional titles or information to be displayed under the main title, such as the type of work. Displayed in 14 pt font. If not provided, defaults to "Rašto darbo tipas".
/// - subHeaders (): Additional header information to be displayed under the university name, such as the faculty. If not provided, defaults to "Fakulteto pavadinimas". /// - subHeaders (): Additional header information to be displayed under the university name, such as the faculty. If not provided, defaults to "Fakulteto pavadinimas".
/// -> /// ->
#let ktu-title-header-block( #let ktu-title-header-block(
bigTitle: highlight[Didelis pavadinimas], bigTitle: highlight[Didelis pavadinimas],
subTitles: (), subTitles: (),
subHeaders: (), subHeaders: (),
) = { ) = {
let parsedSubtext = if subHeaders.len() > 0 { let parsedSubtext = if subHeaders.len() > 0 {
subHeaders subHeaders
} else { } else {
( (
highlight[Fakulteto pavadinimas], highlight[Fakulteto pavadinimas],
) )
}
let subTitles = if subTitles.len() > 0 {
subTitles
} else {
(
highlight[Rašto darbo tipas],
)
}
// Top of the title page
v(20pt)
align(center)[
#image("assets/ktu-logo.png", width: 2.46cm, height: 2.69cm)
#v(25pt)
#block[*Kauno technologijos universitetas*]
#for value in parsedSubtext {
block[#value]
} }
]
let subTitles = if subTitles.len() > 0 { // The title page information
subTitles v(91pt)
} else { align(center)[
( #set par(justify: false)
highlight[Rašto darbo tipas], #set linebreak(justify: false)
) #block(text(size: 18pt, hyphenate: false)[*#bigTitle*])
#for value in subTitles {
block(text(size: 14pt)[#value])
} }
]
// Top of the title page
v(20pt)
align(center)[
#image("assets/ktu-logo.png", width: 2.46cm, height: 2.69cm)
#v(25pt)
#block[*Kauno technologijos universitetas*]
#for value in parsedSubtext {
block[#value]
}
]
// The title page information
v(91pt)
align(center)[
#set par(justify: false)
#set linebreak(justify: false)
#block(text(size: 18pt, hyphenate: false)[*#bigTitle*])
#for value in subTitles {
block(text(size: 14pt)[#value])
}
]
} }
#let ktu-heading-page( #let ktu-heading-page(
faculty: highlight[Fakulteto pavadinimas], faculty: highlight[Fakulteto pavadinimas],
department: none, // optional department: none, // optional
title: highlight[Rašto darbo pavadinimas], title: highlight[Rašto darbo pavadinimas],
subtitles: highlight[Praktikos ataskaita / referatas ir pan. (įrašyti rašto darbo tipą)], subtitles: highlight[Praktikos ataskaita / referatas ir pan. (įrašyti rašto darbo tipą)],
authors: ( authors: (
(highlight[Vardenis Pavardenis], highlight[Projekto autorius]), (highlight[Vardenis Pavardenis], highlight[Projekto autorius]),
(highlight[Vardenis Pavardenis], highlight[Vadovas]), (highlight[Vardenis Pavardenis], highlight[Vadovas]),
), ),
place: highlight[Kaunas], place: highlight[Kaunas],
year: highlight[#datetime.today().year()], year: highlight[#datetime.today().year()],
centerAuthors: false, centerAuthors: false,
authorNamesFirst: true, // if false, roles will be displayed first authorNamesFirst: true, // if false, roles will be displayed first
) = { ) = {
let subHeaders = (faculty,) let subHeaders = (faculty,)
if department != none { if department != none {
subHeaders = (faculty, department) subHeaders = (faculty, department)
} }
if type(subtitles) != array { if type(subtitles) != array {
subtitles = (subtitles,) subtitles = (subtitles,)
} }
ktu-title-header-block( ktu-title-header-block(
subHeaders: subHeaders, subHeaders: subHeaders,
bigTitle: title, bigTitle: title,
subTitles: subtitles, subTitles: subtitles,
) )
v(94pt) v(94pt)
if centerAuthors { if centerAuthors {
ktu-author-table(authors: authors, namesFirst: authorNamesFirst, alignment: center) ktu-author-table(authors: authors, namesFirst: authorNamesFirst, alignment: center)
} else { } else {
ktu-author-table(authors: authors, namesFirst: authorNamesFirst) ktu-author-table(authors: authors, namesFirst: authorNamesFirst)
} }
align(center+bottom, block([*#place, #year*])) align(center + bottom, block([*#place, #year*]))
} }
#let ktu-heading-page-centered( #let ktu-heading-page-centered(
faculty: highlight[Fakulteto pavadinimas], faculty: highlight[Fakulteto pavadinimas],
department: none, // optional department: none, // optional
title: highlight[Rašto darbo pavadinimas], title: highlight[Rašto darbo pavadinimas],
subtitles: highlight[Praktikos ataskaita / referatas ir pan. (įrašyti rašto darbo tipą)], subtitles: highlight[Praktikos ataskaita / referatas ir pan. (įrašyti rašto darbo tipą)],
authors: ( authors: (
(highlight[Vardenis Pavardenis], highlight[Projekto autorius]), (highlight[Vardenis Pavardenis], highlight[Projekto autorius]),
(highlight[Vardenis Pavardenis], highlight[Vadovas]), (highlight[Vardenis Pavardenis], highlight[Vadovas]),
), ),
authorNamesFirst: true, // if false, roles will be displayed first authorNamesFirst: true, // if false, roles will be displayed first
place: highlight[Kaunas], place: highlight[Kaunas],
year: highlight[#datetime.today().year()], year: highlight[#datetime.today().year()],
) = { ) = {
ktu-heading-page( ktu-heading-page(
faculty: faculty, faculty: faculty,
department: department, department: department,
title: title, title: title,
subtitles: subtitles, subtitles: subtitles,
authors: authors, authors: authors,
place: place, place: place,
year: year, year: year,
centerAuthors: true, centerAuthors: true,
authorNamesFirst: authorNamesFirst, authorNamesFirst: authorNamesFirst,
) )
} }
#let ktu-heading-page-normal( #let ktu-heading-page-normal(
faculty: highlight[Fakulteto pavadinimas], faculty: highlight[Fakulteto pavadinimas],
department: none, // optional department: none, // optional
title: highlight[Rašto darbo pavadinimas], title: highlight[Rašto darbo pavadinimas],
subtitles: highlight[Praktikos ataskaita / referatas ir pan. (įrašyti rašto darbo tipą)], subtitles: highlight[Praktikos ataskaita / referatas ir pan. (įrašyti rašto darbo tipą)],
authors: ( authors: (
(highlight[Vardenis Pavardenis], highlight[Projekto autorius]), (highlight[Vardenis Pavardenis], highlight[Projekto autorius]),
(highlight[Vardenis Pavardenis], highlight[Vadovas]), (highlight[Vardenis Pavardenis], highlight[Vadovas]),
), ),
authorNamesFirst: true, // if false, roles will be displayed first authorNamesFirst: true, // if false, roles will be displayed first
place: highlight[Kaunas], place: highlight[Kaunas],
year: highlight[#datetime.today().year()], year: highlight[#datetime.today().year()],
) = { ) = {
ktu-heading-page( ktu-heading-page(
faculty: faculty, faculty: faculty,
department: department, department: department,
title: title, title: title,
subtitles: subtitles, subtitles: subtitles,
authors: authors, authors: authors,
place: place, place: place,
year: year, year: year,
centerAuthors: false, centerAuthors: false,
authorNamesFirst: authorNamesFirst, authorNamesFirst: authorNamesFirst,
) )
} }
#let ktu-academic-honestly-declaration-page( #let ktu-academic-honestly-declaration-page(
@@ -229,22 +235,22 @@
author: highlight[Vardenis Pavardenis], author: highlight[Vardenis Pavardenis],
projectTitle: highlight[Projekto pavadinimas], projectTitle: highlight[Projekto pavadinimas],
) = { ) = {
ktu-title-header-block( ktu-title-header-block(
subHeaders: (faculty, author), subHeaders: (faculty, author),
bigTitle: projectTitle, bigTitle: projectTitle,
subTitles: ("Akademinio sąžiningumo deklaracija",) subTitles: ("Akademinio sąžiningumo deklaracija",),
) )
v(20pt) v(20pt)
[ [
Patvirtinu, kad: Patvirtinu, kad:
+ baigiamąjį projektą parengiau savarankiškai ir sąžiningai, nepažeisdama(s) kitų asmenų autoriaus ar kitų teisių, laikydamasi(s) Lietuvos Respublikos autorių teisių ir gretutinių teisių įstatymo nuostatų, Kauno technologijos universiteto (toliau -- Universitetas) intelektinės nuosavybės valdymo ir perdavimo nuostatų bei Universiteto akademinės etikos kodekse nustatytų etikos reikalavimų; + baigiamąjį projektą parengiau savarankiškai ir sąžiningai, nepažeisdama(s) kitų asmenų autoriaus ar kitų teisių, laikydamasi(s) Lietuvos Respublikos autorių teisių ir gretutinių teisių įstatymo nuostatų, Kauno technologijos universiteto (toliau -- Universitetas) intelektinės nuosavybės valdymo ir perdavimo nuostatų bei Universiteto akademinės etikos kodekse nustatytų etikos reikalavimų;
+ baigiamajame projekte visi pateikti duomenys ir tyrimų rezultatai yra teisingi ir gauti teisėtai, nei viena šio projekto dalis nėra plagijuota nuo jokių spausdintinių ar elektroninių šaltinių, visos baigiamojo projekto tekste pateiktos citatos ir nuorodos yra nurodytos literatūros sąraše; + baigiamajame projekte visi pateikti duomenys ir tyrimų rezultatai yra teisingi ir gauti teisėtai, nei viena šio projekto dalis nėra plagijuota nuo jokių spausdintinių ar elektroninių šaltinių, visos baigiamojo projekto tekste pateiktos citatos ir nuorodos yra nurodytos literatūros sąraše;
+ įstatymų nenumatytų piniginių sumų už baigiamąjį projektą ar jo dalis niekam nesu mokėjęs (-usi); + įstatymų nenumatytų piniginių sumų už baigiamąjį projektą ar jo dalis niekam nesu mokėjęs (-usi);
+ suprantu, kad išaiškėjus nesąžiningumo ar kitų asmenų teisių pažeidimo faktui, man bus taikomos akademinės nuobaudos pagal Universitete galiojančią tvarką ir būsiu pašalinta(s) iš Universiteto, o baigiamasis projektas gali būti pateiktas Akademinės etikos ir procedūrų kontrolieriaus tarnybai nagrinėjant galimą akademinės etikos pažeidimą. + suprantu, kad išaiškėjus nesąžiningumo ar kitų asmenų teisių pažeidimo faktui, man bus taikomos akademinės nuobaudos pagal Universitete galiojančią tvarką ir būsiu pašalinta(s) iš Universiteto, o baigiamasis projektas gali būti pateiktas Akademinės etikos ir procedūrų kontrolieriaus tarnybai nagrinėjant galimą akademinės etikos pažeidimą.
#v(10pt) #v(10pt)
#h(58%) #author #h(58%) #author
#h(58%) _Patvirtinta elektroniniu būdu_ #h(58%) _Patvirtinta elektroniniu būdu_
] ]
} }
+323 -321
View File
@@ -1,66 +1,66 @@
#import "@preview/codly:1.3.0": codly, codly-init #import "@preview/codly:1.3.0": codly, codly-init
#import "config.typ": debug-author-table, enable-heading-experiment, __HEADING_EXPERIMENT, __FIG_PER_SECTION, __UPPERCASE_SECTION_TITLES #import "config.typ": debug-author-table, enable-heading-experiment, __HEADING_EXPERIMENT, __FIG_PER_SECTION, __UPPERCASE_SECTION_TITLES
#import "fragments.typ": ( #import "fragments.typ": (
ktu-table, ktu-table,
// building blocks // building blocks
ktu-author-table, ktu-title-header-block, ktu-author-table, ktu-title-header-block,
ktu-heading-page, ktu-heading-page-centered, ktu-heading-page-normal, ktu-heading-page, ktu-heading-page-centered, ktu-heading-page-normal,
ktu-academic-honestly-declaration-page ktu-academic-honestly-declaration-page
) )
#import "figures.typ": ( #import "figures.typ": (
ref-no, custom-ref, ref-no, custom-ref,
__fig-supplement, __fig-supplement,
__figure-supplement-of, __figure-supplement-of,
__get-locatable-element-number, __get-locatable-element-number,
__reset-figure-counters, __reset-figure-counters,
__equation-numbering, __equation-numbering,
__normalize-figure-kinds, __normalize-figure-kinds,
__USER_FIGURE_KINDS, __USER_FIGURE_KINDS,
__format-ref, __format-ref,
__format-figure, __format-figure,
) )
/** /**
* Paruošta pagal "Rašto ..." * Paruošta pagal "Rašto ..."
*/ */
/* /*
* Further reading required: * Further reading required:
* - Double line spacing | https://github.com/typst/typst/issues/106 * - Double line spacing | https://github.com/typst/typst/issues/106
* - Proposal: change `leading` option to `line-height` | https://github.com/typst/typst/issues/4224 * - Proposal: change `leading` option to `line-height` | https://github.com/typst/typst/issues/4224
*/ */
#let __METADATA_HEADING_ALIGN_LEFT = metadata("heading-align-left"); #let __METADATA_HEADING_ALIGN_LEFT = metadata("heading-align-left");
/// ///
/// Insert a heading without a number. /// Insert a heading without a number.
/// ///
/// Usually used for introductory or summary sections at the start and end. /// Usually used for introductory or summary sections at the start and end.
/// - headingElement (heading): The heading's title. /// - headingElement (heading): The heading's title.
/// - alignLeft (bool): Whether the heading should be left-aligned or centered. /// - alignLeft (bool): Whether the heading should be left-aligned or centered.
/// -> /// ->
#let unnumbered-heading(headingElement, alignLeft: false) = { #let unnumbered-heading(headingElement, alignLeft: false) = {
let fields = headingElement.fields() let fields = headingElement.fields()
let body = fields.body let body = fields.body
let level = fields.at("level", default: 1) let level = fields.at("level", default: 1)
if alignLeft { if alignLeft {
body = body + __METADATA_HEADING_ALIGN_LEFT body = body + __METADATA_HEADING_ALIGN_LEFT
} }
heading(level: level, numbering: none, body) heading(level: level, numbering: none, body)
} }
#let appendix-item(body) = { #let appendix-item(body) = {
heading( heading(
metadata("appendix-heading") + "priedas. " + body, metadata("appendix-heading") + "priedas. " + body,
level: 2, level: 2,
numbering: (..any) => {str(any.at(1))} numbering: (..any) => {str(any.at(1))}
) )
} }
// Utility function to round numbers with padded zeros // Utility function to round numbers with padded zeros
@@ -69,8 +69,7 @@
let s = str(rounded) let s = str(rounded)
let parts = s.split(".") let parts = s.split(".")
let integer-part = parts.at(0) 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 padded-decimal = if decimals > 0 {
let current-decimal-length = decimal-part.len() let current-decimal-length = decimal-part.len()
@@ -98,124 +97,124 @@
/// - title (auto | content | none): Same as outline title. /// - title (auto | content | none): Same as outline title.
/// -> outline /// -> outline
#let __ktu_outline( #let __ktu_outline(
depth: none, depth: none,
indent: 0em, // Disable the default outline indenting indent: 0em, // Disable the default outline indenting
target: heading, target: heading,
title: auto title: auto,
) = { ) = {
// TODO: įtrauka // TODO: įtrauka
set block(spacing: 0em) set block(spacing: 0em)
// genius solution by @two_horus on Discord (364397430059302912) // genius solution by @two_horus on Discord (364397430059302912)
show outline: o => context { show outline: o => context {
// If it's a heading, show the default outline with bold text // If it's a heading, show the default outline with bold text
if (o.target == selector(heading)) { if (o.target == selector(heading)) {
// Determine whether to uppercase section titles based on the global setting // Determine whether to uppercase section titles based on the global setting
let isUpper = __UPPERCASE_SECTION_TITLES.get() let isUpper = __UPPERCASE_SECTION_TITLES.get()
// Define known target widths based on KTU template // Define known target widths based on KTU template
let targets = (0.64cm, 0.96cm, 1.28cm, 1.6cm, 1.92cm) let targets = (0.64cm, 0.96cm, 1.28cm, 1.6cm, 1.92cm)
// Apply custom outline entry formatting
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 newGap = target - measurement.width
// Uppercase body if need be // Apply custom outline entry formatting
let bodyContent = it.element.body show outline.entry: it => {
if isUpper and (it.level == 1 or it.element.numbering == none) { // Recompute the gap based on the prefix content, so that the outline entry is indented
bodyContent = upper(bodyContent) // from the left regardless of the length of the prefix (based on the requirement)
} let prefixContent = it.prefix()
let measurement = measure(prefixContent)
// Reconstruct the it.inner content with the new body let target = targets.at(it.level - 1, default: 0.64cm)
let formattedInner = { let newGap = target - measurement.width
bodyContent if it.element.body.has("children") and it.element.body.children.at(0) == metadata("appendix-heading") {
[ ] // whitespace is required for backwards compat target = 0.64cm
box(width: 1fr, it.fill)
[ ] // whitespace is required for backwards compat
it.page()
}
link(
it.element.location(),
it.indented(prefixContent, formattedInner, gap: newGap),
)
}
show outline.entry.where(level: 1): e => {
strong(e)
}
o
// If it's an image
} else if (o.target == figure.where(kind: image)) {
show outline.entry: it => link(
it.element.location(),
it.indented(
[*#__get-locatable-element-number(it.element) #__fig-supplement(image).*],
[ #it.inner()], gap: 0pt
),
)
o
// If it is a table, show table formatting
} else if (o.target == figure.where(kind: table)) {
show outline.entry: it => link(
it.element.location(),
it.indented(
[*#__get-locatable-element-number(it.element) #__fig-supplement(table).*],
[ #it.inner()], gap: 0pt
),
)
o
// If it is a table, show table formatting
} else if (o.target == figure.where(kind: raw)) {
show outline.entry: it => link(
it.element.location(),
it.indented(
[*#__get-locatable-element-number(it.element) #__fig-supplement(raw).*],
[ #it.inner()], gap: 0pt
),
)
o
// Otherwise, try to determine what kind of outline it is
} else {
/*[
#o.target #type(o.target),
#(o.target == "heading")
#(o.target == heading)
#(o.target == figure.where(kind: heading))
#(o.target == heading.where())
#(o.target == selector(heading))
]*/
// Any other figure kind (generally, user defined kinds)
show outline.entry: it => link(
it.element.location(),
it.indented(
[*#__get-locatable-element-number(it.element) #__figure-supplement-of(it.element).*],
[ #it.inner()], gap: 0pt
),
)
o
} }
let newGap = target - measurement.width
// Uppercase body if need be
let bodyContent = it.element.body
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, formattedInner, gap: newGap),
)
}
show outline.entry.where(level: 1): e => {
strong(e)
}
o
// If it's an image
} else if (o.target == figure.where(kind: image)) {
show outline.entry: it => link(
it.element.location(),
it.indented(
[*#__get-locatable-element-number(it.element) #__fig-supplement(image).*],
[ #it.inner()], gap: 0pt
),
)
o
// If it is a table, show table formatting
} else if (o.target == figure.where(kind: table)) {
show outline.entry: it => link(
it.element.location(),
it.indented(
[*#__get-locatable-element-number(it.element) #__fig-supplement(table).*],
[ #it.inner()], gap: 0pt
),
)
o
// If it is a table, show table formatting
} else if (o.target == figure.where(kind: raw)) {
show outline.entry: it => link(
it.element.location(),
it.indented(
[*#__get-locatable-element-number(it.element) #__fig-supplement(raw).*],
[ #it.inner()], gap: 0pt
),
)
o
// Otherwise, try to determine what kind of outline it is
} else {
/*[
#o.target #type(o.target),
#(o.target == "heading")
#(o.target == heading)
#(o.target == figure.where(kind: heading))
#(o.target == heading.where())
#(o.target == selector(heading))
]*/
// Any other figure kind (generally, user defined kinds)
show outline.entry: it => link(
it.element.location(),
it.indented(
[*#__get-locatable-element-number(it.element) #__figure-supplement-of(it.element).*],
[ #it.inner()], gap: 0pt
),
)
o
} }
outline(depth: depth, indent: indent, target: target, title: title) }
outline(depth: depth, indent: indent, target: target, title: title)
} }
// Doesn't work in Typst 0.12.0 due to relative paths // Doesn't work in Typst 0.12.0 due to relative paths
#let bibliography-list(path) = { #let bibliography-list(path) = {
bibliography(path, title: "Literatūros sąrašas", full: true) bibliography(path, title: "Literatūros sąrašas", full: true)
} }
/// Returns a KTU style conformant outline. /// Returns a KTU style conformant outline.
@@ -225,24 +224,24 @@
/// - title (auto | content | none): Same as outline title. /// - title (auto | content | none): Same as outline title.
/// -> outline /// -> outline
#let ktu-outline( #let ktu-outline(
depth: none, depth: none,
indent: 0em, // Disable the default outline indenting indent: 0em, // Disable the default outline indenting
target: heading, target: heading,
title: auto title: auto,
) = { ) = {
__ktu_outline(depth: depth, indent: indent, target: target, title: title) __ktu_outline(depth: depth, indent: indent, target: target, title: title)
} }
#let ktu-table-of-contents(depth: 3) = { #let ktu-table-of-contents(depth: 3) = {
ktu-outline(target: heading, title: "Turinys", depth: depth) ktu-outline(target: heading, title: "Turinys", depth: depth)
} }
#let ktu-table-list() = { #let ktu-table-list() = {
ktu-outline(title: heading("Lentelių sąrašas", outlined: true), target: figure.where(kind: table)) ktu-outline(title: heading("Lentelių sąrašas", outlined: true), target: figure.where(kind: table))
} }
#let ktu-picture-list() = { #let ktu-picture-list() = {
ktu-outline(title: heading("Paveikslų sąrašas", outlined: true), target: figure.where(kind: image)) ktu-outline(title: heading("Paveikslų sąrašas", outlined: true), target: figure.where(kind: image))
} }
#let ktu-code-list() = { #let ktu-code-list() = {
@@ -255,185 +254,188 @@
/// - title (str): Title of the outline /// - title (str): Title of the outline
/// - kind (str): Type of the figure /// - kind (str): Type of the figure
#let custom-list(title, kind) = { #let custom-list(title, kind) = {
__ktu_outline(title: heading(title, outlined: true), target: figure.where(kind: kind)) __ktu_outline(title: heading(title, outlined: true), target: figure.where(kind: kind))
} }
#let setup-code(body) = { #let setup-code(body) = {
show: codly-init.with() show: codly-init.with()
codly( codly(
fill: white, fill: white,
zebra-fill: none, zebra-fill: none,
stroke: none, stroke: none,
display-name: false, display-name: false,
display-icon: false, display-icon: false,
) )
show raw: set text(font: "Hack", spacing: 80%) show raw: set text(font: "Hack", spacing: 80%)
body body
} }
#let __page_rules(font: "Times New Roman", body) = { #let __page_rules(font: "Times New Roman", body) = {
// Page size and margins // Page size and margins
set page( set page(
paper: "a4", paper: "a4",
width: 210mm, width: 210mm,
height: 297mm, height: 297mm,
margin: ( margin: (
left: 30mm, left: 30mm,
right: 10mm, right: 10mm,
bottom: 20mm, bottom: 20mm,
top: 20mm top: 20mm,
) ),
) )
set page(width: 595pt, height: 842pt) set page(width: 595pt, height: 842pt)
// Numbering rules // Numbering rules
set page(numbering: none, number-align: right) set page(numbering: none, number-align: right)
// Use Lithuanian quotes // Use Lithuanian quotes
set smartquote(quotes: "„“") set smartquote(quotes: "„“")
// Heading numbering // Heading numbering
set heading(numbering: "1.") set heading(numbering: "1.")
// Number equations // Number equations
set math.equation(numbering: __equation-numbering) set math.equation(numbering: __equation-numbering)
// Set text font // Set text font
set text( set text(
font: font, font: font,
size: 12pt, size: 12pt,
lang: "lt", lang: "lt",
// Change where the bounding box is drawn for the text // Change where the bounding box is drawn for the text
top-edge: "ascender", top-edge: "ascender",
bottom-edge: "descender", bottom-edge: "descender",
kerning: false, // Disable kerning kerning: false, // Disable kerning
) )
// Text line interval, defined differently in Typst // Text line interval, defined differently in Typst
let leading = 1.15em // Your line spacing (1, 1.5, 2, etc.) let leading = 1.15em // Your line spacing (1, 1.5, 2, etc.)
let leading = leading - 0.75em // "Normalization" let leading = leading - 0.75em // "Normalization"
set par(leading: leading) set par(leading: leading)
// Indentation for lists and enumerations // Indentation for lists and enumerations
set enum(indent: 12pt) set enum(indent: 12pt)
set list(indent: 12pt) set list(indent: 12pt)
body body
} }
#let setup-page( #let setup-page(
font: "Times New Roman", font: "Times New Roman",
uppercaseSectionTitles: false, uppercaseSectionTitles: false,
unnumberedHeadingAlignment: center, unnumberedHeadingAlignment: center,
body body,
) = { ) = {
show: __page_rules.with(font: font) show: __page_rules.with(font: font)
// Pagal formaliuosius rašto darbų reikalavimus // Pagal formaliuosius rašto darbų reikalavimus
// Tarpas tarp teksto pastraipų // Tarpas tarp teksto pastraipų
set par(spacing: 10pt) set par(spacing: 10pt)
set block(below: 10pt)
// Teksto lygiuotė, abipusė
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 => {
// Align everything left
set align(left)
// Visų antraščių teksto dydis vienodas
// Visų antraščių teksto šifras paryškintas
set text(size: 12pt)
set block(below: 10pt) set block(below: 10pt)
// Teksto lygiuotė, abipusė let useExperiment = __HEADING_EXPERIMENT.get()
set par(justify: true)
set linebreak(justify: true)
let maybe-uppercase(body) = { // TODO: intervalas tarp eilučių – 1,15 kiekvienai antraštei
if uppercaseSectionTitles {
upper(body) // Antraštė be nr.
} else { if it.numbering == none {
body // 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[#maybe-uppercase(it.body)]
if useExperiment {
v(10pt)
}
} }
// Antraštės // Skyrius
// Force them into blocks so they don't count as paragraphs if it.numbering != none and it.level == 1 {
show heading: it => { // abipusė lygiuotė
// Align everything left set par(justify: true)
set align(left)
// Visų antraščių teksto dydis vienodas // Reset figure counters if numbering per section is enabled
// Visų antraščių teksto šifras paryškintas if __FIG_PER_SECTION.get() {
set text(size: 12pt) __reset-figure-counters()
set block(below: 10pt) }
let useExperiment = __HEADING_EXPERIMENT.get() // po antraštės - 10 pt
block[#counter(heading).display() #maybe-uppercase(it.body)]
// TODO: intervalas tarp eilučių – 1,15 kiekvienai antraštei if useExperiment {
v(10pt)
// Antraštė be nr. }
if it.numbering == none {
// 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[#maybe-uppercase(it.body)]
if useExperiment {
v(10pt)
}
}
// Skyrius
if it.numbering != none and it.level == 1 {
// abipusė lygiuotė
set par(justify: true)
// 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() #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 {
// abipusė lygiuotė
set par(justify: true)
// prieš ir po antraštės - 10 pt
if useExperiment {
v(10pt)
}
block[#counter(heading).display() #it.body]
if useExperiment {
v(10pt)
}
}
} }
// Reference style and numbering // Determine whether the heading has appending metadata attached and adjust its display accordingly
show ref: it => __format-ref(it) let isAppendixHeading = it.body.has("children") and it.body.children.at(0) == metadata("appendix-heading")
if isAppendixHeading {
// Figure captions and numbering block[#counter(heading).display(it.numbering) #it.body]
show figure: it => __format-figure(it)
// Bibliography citing style
set bibliography(style: "assets/iso690-numeric-lt.csl")
// Block equations are left-aligned
show math.equation.where(block: true): it => {
align(left, it)
} }
body // Poskyris ir skyrelis
if not isAppendixHeading and it.numbering != none and it.level != 1 {
// abipusė lygiuotė
set par(justify: true)
// prieš ir po antraštės - 10 pt
if useExperiment {
v(10pt)
}
block[#counter(heading).display() #it.body]
if useExperiment {
v(10pt)
}
}
}
// Reference style and numbering
show ref: it => __format-ref(it)
// Figure captions and numbering
show figure: it => __format-figure(it)
// Bibliography citing style
set bibliography(style: "assets/iso690-numeric-lt.csl")
// Block equations are left-aligned
show math.equation.where(block: true): it => {
align(left, it)
}
body
} }
/// Configure the template for a KTU paper. /// Configure the template for a KTU paper.
@@ -445,23 +447,23 @@
/// `(command: (supplement: "komanda", ref-name: "komanda"))`. `ref-name` /// `(command: (supplement: "komanda", ref-name: "komanda"))`. `ref-name`
/// defaults to `supplement`. Use them with `figure(kind: "command", ...)`. /// defaults to `supplement`. Use them with `figure(kind: "command", ...)`.
#let ktu-paper( #let ktu-paper(
font: "Times New Roman", font: "Times New Roman",
figureNumberingPerSection: false, figureNumberingPerSection: false,
figureKinds: (:), figureKinds: (:),
// Not sure about formal conformity of deviating // Not sure about formal conformity of deviating
// from the defaults of the next options, // from the defaults of the next options,
// but some modules may require them // but some modules may require them
uppercaseSectionTitles: false, uppercaseSectionTitles: false,
unnumberedHeadingAlignment: center, unnumberedHeadingAlignment: center,
body body,
) = context { ) = context {
show: setup-page.with( show: setup-page.with(
font: font, font: font,
uppercaseSectionTitles: uppercaseSectionTitles, uppercaseSectionTitles: uppercaseSectionTitles,
unnumberedHeadingAlignment: unnumberedHeadingAlignment, unnumberedHeadingAlignment: unnumberedHeadingAlignment,
) )
__FIG_PER_SECTION.update(figureNumberingPerSection) __FIG_PER_SECTION.update(figureNumberingPerSection)
__USER_FIGURE_KINDS.update(__normalize-figure-kinds(figureKinds)) __USER_FIGURE_KINDS.update(__normalize-figure-kinds(figureKinds))
__UPPERCASE_SECTION_TITLES.update(uppercaseSectionTitles) __UPPERCASE_SECTION_TITLES.update(uppercaseSectionTitles)
body body
} }