mirror of
https://github.com/JustAnyones/ktu-paper.git
synced 2026-09-19 12:48:27 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3e91fbfefd
|
||
|
|
2e3f4a890e
|
||
|
|
3040693015
|
||
|
|
67947b07a7
|
||
|
|
cd64907a36
|
||
|
|
920866695c
|
@@ -1,3 +1,12 @@
|
|||||||
# ktu-paper
|
# 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. A final Bachelor's thesis written with this template has successfully passed the formal review.
|
||||||
|
|
||||||
|
## Initiating the template
|
||||||
|
Install the downloaded template under the following directory:
|
||||||
|
- LINUX: `~/.local/share/typst/packages/local/ktu-paper/0.2.1/`
|
||||||
|
|
||||||
|
And then initiate a new project:
|
||||||
|
```sh
|
||||||
|
typst init @local/ktu-paper:0.2.1
|
||||||
|
```
|
||||||
|
|||||||
@@ -6,6 +6,11 @@
|
|||||||
/// 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)
|
||||||
|
|
||||||
|
/// 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 = 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)
|
||||||
|
|||||||
+9
-7
@@ -39,7 +39,7 @@
|
|||||||
|
|
||||||
/// Helper function to resolve figure numbers (either global "1" or section-based "1.1").
|
/// Helper function to resolve figure numbers (either global "1" or section-based "1.1").
|
||||||
/// It takes a figure item and referenced location and returns the appropriate number as a string.
|
/// It takes a figure item and referenced location and returns the appropriate number as a string.
|
||||||
#let __get-figure-number(fig-item, loc) = context {
|
#let __get-figure-number(fig-item, loc) = {
|
||||||
if type(fig-item) != content {
|
if type(fig-item) != content {
|
||||||
panic("can only get figure number for content elements")
|
panic("can only get figure number for content elements")
|
||||||
}
|
}
|
||||||
@@ -48,17 +48,17 @@
|
|||||||
panic("can only get figure number for figure elements")
|
panic("can only get figure number for figure elements")
|
||||||
}
|
}
|
||||||
|
|
||||||
let perSection = __FIG_PER_SECTION.get()
|
let perSection = __FIG_PER_SECTION.at(loc)
|
||||||
if perSection {
|
if perSection {
|
||||||
let chapter = counter(heading).at(loc).at(0, default: 0)
|
let chapter = counter(heading).at(loc).at(0, default: 0)
|
||||||
let figNum = counter(figure.where(kind: fig-item.kind)).at(loc).at(0, default: 1)
|
let figNum = counter(figure.where(kind: fig-item.kind)).at(loc).at(0, default: 1)
|
||||||
[#chapter.#figNum]
|
str(chapter) + "." + str(figNum)
|
||||||
} else {
|
} else {
|
||||||
let caption = fig-item.caption
|
let caption = fig-item.caption
|
||||||
if caption != none and caption.numbering != none {
|
if caption != none and caption.numbering != none {
|
||||||
caption.counter.at(loc).at(0)
|
str(caption.counter.at(loc).at(0))
|
||||||
} else {
|
} else {
|
||||||
[#counter(figure.where(kind: fig-item.kind)).at(loc).at(0)]
|
str(counter(figure.where(kind: fig-item.kind)).at(loc).at(0))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -124,12 +124,14 @@
|
|||||||
}
|
}
|
||||||
set text(size: 11pt)
|
set text(size: 11pt)
|
||||||
|
|
||||||
|
let fig-num = context __get-figure-number(it, here())
|
||||||
|
|
||||||
// Tables have captions at the top
|
// Tables have captions at the top
|
||||||
if it.kind == table {
|
if it.kind == table {
|
||||||
align(left)[*#__get-figure-number(it, here()) #supplement#separator* #caption.body]
|
align(left)[*#fig-num #supplement#separator* #caption.body]
|
||||||
it.body
|
it.body
|
||||||
} else {
|
} else {
|
||||||
it.body
|
it.body
|
||||||
[*#__get-figure-number(it, here()) #supplement#separator* #caption.body]
|
align(center)[*#fig-num #supplement#separator* #caption.body]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+49
-8
@@ -1,5 +1,5 @@
|
|||||||
#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
|
#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,
|
||||||
ktu-heading-page-centered, ktu-heading-page-normal, ktu-academic-honestly-declaration-page
|
ktu-heading-page-centered, ktu-heading-page-normal, ktu-academic-honestly-declaration-page
|
||||||
@@ -192,6 +192,9 @@
|
|||||||
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
|
||||||
|
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)
|
||||||
|
|
||||||
@@ -207,9 +210,25 @@
|
|||||||
target = 0.64cm
|
target = 0.64cm
|
||||||
}
|
}
|
||||||
let newGap = target - measurement.width
|
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(
|
link(
|
||||||
it.element.location(),
|
it.element.location(),
|
||||||
it.indented(prefixContent, it.inner(), gap: newGap),
|
it.indented(prefixContent, formattedInner, gap: newGap),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -382,6 +401,8 @@
|
|||||||
|
|
||||||
#let setup-page(
|
#let setup-page(
|
||||||
font: "Times New Roman",
|
font: "Times New Roman",
|
||||||
|
uppercaseSectionTitles: false,
|
||||||
|
unnumberedHeadingAlignment: center,
|
||||||
body
|
body
|
||||||
) = {
|
) = {
|
||||||
show: __page_rules.with(font: font)
|
show: __page_rules.with(font: font)
|
||||||
@@ -396,6 +417,14 @@
|
|||||||
set par(justify: true)
|
set par(justify: true)
|
||||||
set linebreak(justify: true)
|
set linebreak(justify: true)
|
||||||
|
|
||||||
|
let maybe-uppercase(body) = {
|
||||||
|
if uppercaseSectionTitles {
|
||||||
|
upper(body)
|
||||||
|
} else {
|
||||||
|
body
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Antraštės
|
// Antraštės
|
||||||
// Force them into blocks so they don't count as paragraphs
|
// Force them into blocks so they don't count as paragraphs
|
||||||
show heading: it => {
|
show heading: it => {
|
||||||
@@ -413,11 +442,11 @@
|
|||||||
|
|
||||||
// Antraštė be nr.
|
// Antraštė be nr.
|
||||||
if it.numbering == none {
|
if it.numbering == none {
|
||||||
// Centruota lygiuotė
|
// Centruota lygiuotė by default, but can be overridden by the user
|
||||||
set align(center)
|
set align(unnumberedHeadingAlignment)
|
||||||
|
|
||||||
// atstumas prieš ir po antraštės - 10 pt
|
// atstumas prieš ir po antraštės - 10 pt
|
||||||
block[#it.body]
|
block[#maybe-uppercase(it.body)]
|
||||||
if useExperiment {
|
if useExperiment {
|
||||||
v(10pt)
|
v(10pt)
|
||||||
}
|
}
|
||||||
@@ -437,7 +466,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// po antraštės - 10 pt
|
// po antraštės - 10 pt
|
||||||
block[#counter(heading).display() #it.body]
|
block[#counter(heading).display() #maybe-uppercase(it.body)]
|
||||||
if useExperiment {
|
if useExperiment {
|
||||||
v(10pt)
|
v(10pt)
|
||||||
}
|
}
|
||||||
@@ -478,14 +507,26 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Configure the template for a KTU paper.
|
/// Configure the template for a KTU paper.
|
||||||
/// - font (str): Font to use for the paper.
|
/// - font (str): Text font to use for the paper.
|
||||||
/// - figureNumberingPerSection (bool): Whether to number figures per section rather than globally.
|
/// - figureNumberingPerSection (bool): Whether to number figures per section rather than globally.
|
||||||
|
/// - uppercaseSectionTitles (bool): Whether to uppercase section titles.
|
||||||
|
/// - unnumberedHeadingAlignment (alignment): Alignment for unnumbered headings.
|
||||||
#let ktu-paper(
|
#let ktu-paper(
|
||||||
font: "Times New Roman",
|
font: "Times New Roman",
|
||||||
figureNumberingPerSection: false,
|
figureNumberingPerSection: false,
|
||||||
|
// 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
|
body
|
||||||
) = context {
|
) = context {
|
||||||
show: setup-page.with(font: font)
|
show: setup-page.with(
|
||||||
|
font: font,
|
||||||
|
uppercaseSectionTitles: uppercaseSectionTitles,
|
||||||
|
unnumberedHeadingAlignment: unnumberedHeadingAlignment,
|
||||||
|
)
|
||||||
__FIG_PER_SECTION.update(figureNumberingPerSection)
|
__FIG_PER_SECTION.update(figureNumberingPerSection)
|
||||||
|
__UPPERCASE_SECTION_TITLES.update(uppercaseSectionTitles)
|
||||||
body
|
body
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
#import "@local/ktu-paper:0.2.0": (
|
#import "@local/ktu-paper:0.3.0": (
|
||||||
ktu-paper, setup-code,
|
ktu-paper, setup-code,
|
||||||
ktu-table-of-contents, ktu-picture-list, ktu-table-list,
|
ktu-table-of-contents, ktu-picture-list, ktu-table-list,
|
||||||
ktu-heading-page-normal,
|
ktu-heading-page-normal,
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
#import "@local/ktu-paper:0.2.0": (
|
#import "@local/ktu-paper:0.3.0": (
|
||||||
ktu-paper, setup-code,
|
ktu-paper, setup-code,
|
||||||
ktu-table-of-contents, ktu-picture-list, ktu-table-list,
|
ktu-table-of-contents, ktu-picture-list, ktu-table-list,
|
||||||
ktu-heading-page-normal,
|
ktu-heading-page-normal,
|
||||||
|
|||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "ktu-paper"
|
name = "ktu-paper"
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
compiler = "0.15.1"
|
compiler = "0.15.0"
|
||||||
entrypoint = "src/lib.typ"
|
entrypoint = "src/lib.typ"
|
||||||
repository = "https://github.com/svetikas/ktu-paper"
|
repository = "https://github.com/svetikas/ktu-paper"
|
||||||
authors = ["Dominykas Svetikas <https://svetikas.lt>"]
|
authors = ["Dominykas Svetikas <https://svetikas.lt>"]
|
||||||
|
|||||||
Reference in New Issue
Block a user