mirror of
https://github.com/kristoferssolo/LU-DF-Typst-Template.git
synced 2025-10-21 18:50:33 +00:00
chore: make a template
This commit is contained in:
parent
ce96deba3e
commit
e26f01c1d5
BIN
example.png
BIN
example.png
Binary file not shown.
|
Before Width: | Height: | Size: 501 KiB |
@ -1,62 +1,12 @@
|
||||
#import "@preview/headcount:0.1.0": *
|
||||
#import "@preview/tablex:0.0.9": tablex
|
||||
#import "utils.typ": render-abstract
|
||||
|
||||
#let indent = 1cm
|
||||
#let indent-par(body) = par(h(indent) + body)
|
||||
|
||||
#let merge(a, b) = {
|
||||
let result = a
|
||||
for (k, v) in b { result.at(k) = v }
|
||||
result
|
||||
}
|
||||
|
||||
#let render-abstract(role, abstract) = {
|
||||
// Define role-based defaults
|
||||
let defaults = if role == "primary" {
|
||||
(
|
||||
lang: "lv",
|
||||
title: "Anotācija",
|
||||
keyword-title: "Atslēgvārdi",
|
||||
text: [],
|
||||
keywords: [],
|
||||
)
|
||||
} else {
|
||||
(
|
||||
lang: "en",
|
||||
title: "Abstract",
|
||||
keyword-title: "Keywords",
|
||||
text: [],
|
||||
keywords: [],
|
||||
)
|
||||
}
|
||||
|
||||
// Merge defaults with overrides
|
||||
let abs = merge(defaults, abstract)
|
||||
|
||||
context [
|
||||
#set text(lang: abs.lang)
|
||||
#heading(
|
||||
level: 1,
|
||||
outlined: false,
|
||||
numbering: none,
|
||||
abs.title,
|
||||
)
|
||||
|
||||
// Abstract body text
|
||||
#abs.text
|
||||
|
||||
// Keywords
|
||||
#par(first-line-indent: 0cm)[
|
||||
*#abs.keyword-title*: #abs.keywords.join(", ").
|
||||
]
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
// This function gets your whole document as its `body` and formats
|
||||
// it as an article in the style of the IEEE.
|
||||
#let ludf(
|
||||
title: [Paper Title],
|
||||
title: [Title],
|
||||
// An array of authors. For each author you can specify a name,
|
||||
// location, and email. Everything but but the `name` and `code` is optional.
|
||||
authors: (),
|
||||
@ -83,11 +33,14 @@
|
||||
university: "Latvijas Universitāte",
|
||||
faculty: [Eksakto zinātņu un tehnoloģiju fakultāte\ Datorikas nodaļa],
|
||||
thesis-type: "Bakalaura darbs",
|
||||
date: none,
|
||||
date: (
|
||||
year: none,
|
||||
month: none,
|
||||
day: none,
|
||||
),
|
||||
place: none,
|
||||
logo: none,
|
||||
outline-title: "SATURS",
|
||||
replace-math-dot-with-comma: true,
|
||||
body,
|
||||
) = {
|
||||
// Set document metadata.
|
||||
@ -95,7 +48,10 @@
|
||||
|
||||
// Set the body font.
|
||||
set text(
|
||||
font: ("Times New Roman", "New Computer Modern", "TeX Gyre Termes"),
|
||||
font: (
|
||||
"Times New Roman",
|
||||
"New Computer Modern",
|
||||
),
|
||||
size: 12pt,
|
||||
hyphenate: auto,
|
||||
lang: "lv",
|
||||
@ -109,21 +65,20 @@
|
||||
)
|
||||
|
||||
|
||||
// Main body.
|
||||
set par(
|
||||
justify: true,
|
||||
leading: 1.5em,
|
||||
spacing: 1.5em,
|
||||
first-line-indent: (amount: indent, all: true),
|
||||
)
|
||||
|
||||
|
||||
// Configure equation numbering and spacing.
|
||||
set math.equation(numbering: "(1)")
|
||||
show math.equation: set block(spacing: 0.65em)
|
||||
// show math.equation: set text(weight: 400)
|
||||
|
||||
// replace `.` with `,`
|
||||
if replace-math-dot-with-comma == true {
|
||||
show math.equation: it => {
|
||||
show regex("\d+\.\d+"): num => {
|
||||
show ".": math.class("normal", ",")
|
||||
num
|
||||
}
|
||||
it
|
||||
}
|
||||
}
|
||||
|
||||
// Configure appearance of equation references
|
||||
show ref: it => {
|
||||
@ -148,7 +103,7 @@
|
||||
|
||||
// Headings
|
||||
set heading(numbering: "1.1.")
|
||||
show heading: set block(spacing: 1.5em)
|
||||
show heading: set block(spacing: 2em)
|
||||
show heading: it => {
|
||||
if it.level == 1 {
|
||||
pagebreak(weak: true)
|
||||
@ -164,15 +119,20 @@
|
||||
|
||||
set quote(block: true)
|
||||
|
||||
show table.cell.where(y: 0): strong
|
||||
|
||||
// Tables & figures
|
||||
show figure: set block(breakable: true) // allow for tables to span to next pages mid sentence
|
||||
show figure: set par(justify: false) // disable justify for figures (tables)
|
||||
show table.cell.where(y: 0): strong
|
||||
set table(align: left)
|
||||
show figure: set image(width: 80%)
|
||||
|
||||
set figure(numbering: dependent-numbering("1.1."))
|
||||
show figure: set figure.caption(position: top, separator: " ")
|
||||
show figure.caption: set align(end)
|
||||
|
||||
show figure.where(kind: image): set figure(supplement: "att")
|
||||
show figure.caption.where(kind: image): set align(start)
|
||||
show figure.caption: set text(size: 11pt)
|
||||
show figure.where(kind: image): set figure.caption(
|
||||
position: bottom,
|
||||
separator: ". ",
|
||||
@ -202,7 +162,7 @@
|
||||
}
|
||||
|
||||
// disable default reference suppliments
|
||||
set ref(supplement: it => {})
|
||||
// set ref(supplement: it => {})
|
||||
|
||||
// Custom show rule for references
|
||||
show ref: it => {
|
||||
@ -217,6 +177,7 @@
|
||||
..counter(el.func()).at(el.location()),
|
||||
)
|
||||
|
||||
|
||||
if el.func() == heading {
|
||||
return link(
|
||||
el.location(),
|
||||
@ -245,10 +206,10 @@
|
||||
// Code blocks
|
||||
show raw: set text(
|
||||
font: (
|
||||
"TeX Gyre Cursor",
|
||||
"JetBrainsMono NF",
|
||||
"JetBrains Mono",
|
||||
"Fira Code",
|
||||
"TeX Gyre Cursor",
|
||||
),
|
||||
features: (calt: 0),
|
||||
ligatures: false,
|
||||
@ -256,15 +217,6 @@
|
||||
)
|
||||
|
||||
|
||||
// Main body.
|
||||
set par(
|
||||
justify: true,
|
||||
leading: 1.5em,
|
||||
first-line-indent: (amount: indent, all: true),
|
||||
spacing: 1.5em,
|
||||
)
|
||||
|
||||
|
||||
// Display the paper's title and authors at the top of the page,
|
||||
// spanning all columns (hence floating at the scope of the
|
||||
// columns' parent, which is the page).
|
||||
@ -285,27 +237,23 @@
|
||||
v(1fr)
|
||||
|
||||
// Author information
|
||||
align(right, [
|
||||
#text(
|
||||
weight: "bold",
|
||||
"Darba " + if authors.len() > 1 { "autori:" } else { "autors:" },
|
||||
)\
|
||||
#authors.map(author => [#author.name, #author.code]).join("\n")
|
||||
context [
|
||||
#set par(first-line-indent: 0pt)
|
||||
#if authors.len() > 1 { "Autori:" } else { "Autors:" }
|
||||
#authors.map(author => strong(author.name)).join(", ")
|
||||
|
||||
#v(1em)
|
||||
#if authors.len() > 1 { "Studentu" } else { "Studenta" }
|
||||
apliecības Nr.: #authors.map(author => author.code).join(", ")
|
||||
|
||||
#if advisors.len() > 0 [
|
||||
#text(
|
||||
weight: "bold",
|
||||
"Darba " + if advisors.len() > 1 { "vadītāji:" } else { "vadītājs:" },
|
||||
)\
|
||||
Darba #if advisors.len() > 1 { "vadītāji:" } else { "vadītājs:" }
|
||||
#advisors.map(advisor => [#advisor.title #advisor.name]).join("\n")
|
||||
]
|
||||
])
|
||||
]
|
||||
|
||||
v(0.5fr)
|
||||
|
||||
align(center, upper([#place #date]))
|
||||
align(center, upper([#place #date.year]))
|
||||
|
||||
|
||||
// Start page numbering
|
||||
@ -332,5 +280,3 @@
|
||||
// Display bibliography.
|
||||
bibliography
|
||||
}
|
||||
|
||||
|
||||
170
main.typ
170
main.typ
@ -1,170 +0,0 @@
|
||||
#import "template.typ": ludf
|
||||
#show: ludf.with(
|
||||
authors: (
|
||||
(
|
||||
name: "John Doe",
|
||||
code: "jd00000",
|
||||
location: [Riga, Latvia],
|
||||
email: "jd00000@edu.lu.lv",
|
||||
),
|
||||
),
|
||||
advisors: (
|
||||
(
|
||||
title: "Mg. dat.",
|
||||
name: "Jone Doe",
|
||||
),
|
||||
),
|
||||
date: "2025",
|
||||
place: "Rīga",
|
||||
bibliography: bibliography("bibliography.yml"),
|
||||
abstract: (
|
||||
primary: (
|
||||
text: [
|
||||
#lorem(50)
|
||||
|
||||
#lorem(30)
|
||||
|
||||
#lorem(20)
|
||||
],
|
||||
keywords: (
|
||||
"Foo",
|
||||
"Bar",
|
||||
"Baz",
|
||||
),
|
||||
),
|
||||
secondary: (
|
||||
text: [
|
||||
#lorem(20)
|
||||
|
||||
#lorem(30)
|
||||
|
||||
#lorem(50)
|
||||
],
|
||||
keywords: (
|
||||
"foo",
|
||||
"bar",
|
||||
"baz",
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
= Document Title
|
||||
|
||||
== Headings
|
||||
This is a paragraph of body text. It should show how normal text looks.
|
||||
|
||||
=== Subheading
|
||||
Another paragraph with _emphasis_, *strong text*, and `inline code`.
|
||||
|
||||
== Lists
|
||||
|
||||
=== Unordered
|
||||
- Item one
|
||||
- Item two
|
||||
- Nested item
|
||||
- Another nested item
|
||||
- Item three
|
||||
|
||||
=== Ordered
|
||||
+ First
|
||||
+ Sub A
|
||||
+ Sub i
|
||||
+ Second
|
||||
+ Third
|
||||
|
||||
== Math
|
||||
Inline math: $e^(i pi) + 1 = 0$.
|
||||
|
||||
Block math:
|
||||
$
|
||||
lim_(-oo)^(infinity) e^(-x^2) d x = sqrt(pi)
|
||||
$ <math-1>
|
||||
|
||||
|
||||
And we can reference @math-1.
|
||||
|
||||
== Code
|
||||
Here is some code:
|
||||
|
||||
```rust
|
||||
fn main() {
|
||||
println!("Hello, Typst!");
|
||||
}
|
||||
```
|
||||
|
||||
== Quotes
|
||||
#quote[This is a blockquote.]
|
||||
|
||||
They can span multiple lines.
|
||||
|
||||
#quote(attribution: [Plato])[
|
||||
... ἔοικα γοῦν τούτου γε σμικρῷ τινι αὐτῷ τούτῳ σοφώτερος εἶναι, ὅτι
|
||||
ἃ μὴ οἶδα οὐδὲ οἴομαι εἰδέναι.
|
||||
]
|
||||
|
||||
#quote(attribution: [from the Henry Cary literal translation of 1897])[
|
||||
... I seem, then, in just this little thing to be wiser than this man at
|
||||
any rate, that what I do not know I do not think I know either.
|
||||
]
|
||||
|
||||
== Links <title>
|
||||
Here is a https://typst.app and
|
||||
here is a with a label -- #link("https://typst.app")[Typst website].
|
||||
|
||||
== Table
|
||||
Here’s a simple table:
|
||||
|
||||
#figure(
|
||||
table(
|
||||
columns: 4,
|
||||
table.header[Name][Age][Role][Lorem],
|
||||
"Alice", "24", "Engineer", lorem(8),
|
||||
"Bob", "30", "Designer", lorem(8),
|
||||
"Carol", "28", "Researcher", lorem(7),
|
||||
),
|
||||
caption: [Example table],
|
||||
) <table-1>
|
||||
|
||||
|
||||
== Figures
|
||||
#figure(
|
||||
image("example.png", width: 60%),
|
||||
caption: [An example image with caption.],
|
||||
) <image-1>
|
||||
#figure(
|
||||
image("example.png"),
|
||||
caption: [An example image with caption.],
|
||||
) <image-2>
|
||||
|
||||
- @image-1[]
|
||||
- @image-2
|
||||
- @table-1
|
||||
- @table-1[tabulu]
|
||||
- @title
|
||||
- @code[pielikumu]
|
||||
|
||||
A reference to an image (see @image-1[] and @image-2 and @table-1)
|
||||
|
||||
|
||||
== Footnotes
|
||||
This is a sentence with a footnote. #footnote("This is the footnote text.")
|
||||
|
||||
== References
|
||||
// We can reference @typst in text.
|
||||
|
||||
|
||||
#figure(
|
||||
caption: "Some caption",
|
||||
kind: "attachment",
|
||||
supplement: "pielikums",
|
||||
```rust
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[cfg_attr(feature = "bevy_reflect", derive(bevy_reflect::Reflect))]
|
||||
#[cfg_attr(feature = "bevy", derive(Component))]
|
||||
#[cfg_attr(feature = "bevy", reflect(Component))]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct Walls(u8);
|
||||
```,
|
||||
)<code>
|
||||
|
||||
89
template/main.typ
Normal file
89
template/main.typ
Normal file
@ -0,0 +1,89 @@
|
||||
#import "@preview/solo-lu-df:0.0.1": ludf
|
||||
|
||||
#show: ludf.with(
|
||||
title: "Darba Nosaukums",
|
||||
authors: (
|
||||
(
|
||||
name: "Jānis Bērziņš",
|
||||
code: "jb12345",
|
||||
location: [Riga, Latvia],
|
||||
email: "jb12345@edu.lu.lv",
|
||||
),
|
||||
(
|
||||
name: "Zane Kalniņa",
|
||||
code: "zk67890",
|
||||
location: [Riga, Latvia],
|
||||
email: "zk67890@edu.lu.lv",
|
||||
),
|
||||
),
|
||||
advisors: (
|
||||
(
|
||||
title: "Mg. dat.",
|
||||
name: "Ivars Ozoliņš",
|
||||
),
|
||||
),
|
||||
date: (
|
||||
year: 2025,
|
||||
),
|
||||
place: "Rīga",
|
||||
bibliography: bibliography("bibliography.yml"),
|
||||
abstract: (
|
||||
primary: (
|
||||
text: [
|
||||
#lorem(50)
|
||||
|
||||
#lorem(30)
|
||||
|
||||
#lorem(20)
|
||||
],
|
||||
keywords: (
|
||||
"Foo",
|
||||
"Bar",
|
||||
"Baz",
|
||||
),
|
||||
),
|
||||
secondary: (
|
||||
text: [
|
||||
#lorem(20)
|
||||
|
||||
#lorem(30)
|
||||
|
||||
#lorem(50)
|
||||
],
|
||||
keywords: (
|
||||
"foo",
|
||||
"bar",
|
||||
"baz",
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
#set heading(numbering: none)
|
||||
= Apzīmējumu saraksts
|
||||
/ Docs: Typst dokumentācija.#footnote[https://typst.com/docs/]
|
||||
/ Universe: Typst kopienas paketes un šabloni.#footnote[https://typst.app/universe/]
|
||||
|
||||
= Ievads
|
||||
#lorem(100)@typst
|
||||
|
||||
#set heading(numbering: "1.1.")
|
||||
|
||||
= Nodaļas nosaukums
|
||||
== Apakšnodaļas nosaukums
|
||||
== Apakšnodaļas nosaukums
|
||||
== Apakšnodaļas nosaukums
|
||||
|
||||
= Nodaļas nosaukums
|
||||
== Apakšnodaļas nosaukums
|
||||
== Apakšnodaļas nosaukums
|
||||
|
||||
= Nodaļas nosaukums
|
||||
== Apakšnodaļas nosaukums
|
||||
== Apakšnodaļas nosaukums
|
||||
|
||||
#set heading(numbering: none)
|
||||
= Rezultāti
|
||||
= Secinājumi
|
||||
|
||||
BIN
thumbnail.png
Normal file
BIN
thumbnail.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 391 KiB |
34
typst.toml
Normal file
34
typst.toml
Normal file
@ -0,0 +1,34 @@
|
||||
[package]
|
||||
name = "solo-lu-df"
|
||||
version = "0.0.1"
|
||||
compiler = "0.13.0"
|
||||
entrypoint = "lib.typ"
|
||||
repository = "https://github.com/kristoferssolo/LU-DF-Typst-Template"
|
||||
authors = ["Kristofers Solo <dev@kristofers.xyz>"]
|
||||
license = "MIT"
|
||||
description = "Write qualification papers, bachelor’s theses, and master’s theses for University of Lativa, Computer Science programme."
|
||||
keywords = [
|
||||
"University of Latvia",
|
||||
"LU",
|
||||
"Latvijas Universitāte",
|
||||
"Computer Science",
|
||||
"Computer Engineering",
|
||||
"Software",
|
||||
]
|
||||
categories = ["paper"]
|
||||
disciplines = ["computer-science"]
|
||||
exclude = [
|
||||
".github",
|
||||
"docs",
|
||||
"scripts",
|
||||
"examples",
|
||||
"tests",
|
||||
".typstignore",
|
||||
"Justfile",
|
||||
"thumbnail.png",
|
||||
]
|
||||
|
||||
[template]
|
||||
path = "template"
|
||||
entrypoint = "main.typ"
|
||||
thumbnail = "thumbnail.png"
|
||||
46
utils.typ
Normal file
46
utils.typ
Normal file
@ -0,0 +1,46 @@
|
||||
#let merge(a, b) = {
|
||||
let result = a
|
||||
for (k, v) in b { result.at(k) = v }
|
||||
result
|
||||
}
|
||||
|
||||
#let render-abstract(role, abstract) = {
|
||||
// Define role-based defaults
|
||||
let defaults = if role == "primary" {
|
||||
(
|
||||
lang: "lv",
|
||||
title: "Anotācija",
|
||||
keyword-title: "Atslēgvārdi",
|
||||
text: [],
|
||||
keywords: [],
|
||||
)
|
||||
} else {
|
||||
(
|
||||
lang: "en",
|
||||
title: "Abstract",
|
||||
keyword-title: "Keywords",
|
||||
text: [],
|
||||
keywords: [],
|
||||
)
|
||||
}
|
||||
|
||||
// Merge defaults with overrides
|
||||
let abs = merge(defaults, abstract)
|
||||
|
||||
context [
|
||||
#set text(lang: abs.lang)
|
||||
#heading(
|
||||
level: 1,
|
||||
outlined: false,
|
||||
numbering: none,
|
||||
abs.title,
|
||||
)
|
||||
|
||||
// Abstract body text
|
||||
#abs.text
|
||||
|
||||
// Keywords
|
||||
#par(first-line-indent: 0cm)[ *#abs.keyword-title*: ]
|
||||
#abs.keywords.join(", ").
|
||||
]
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user