Compare commits

..

No commits in common. "main" and "v0.6.2" have entirely different histories.
main ... v0.6.2

16 changed files with 177 additions and 293 deletions

View File

@ -24,7 +24,7 @@ jobs:
nix-shell --run ./run-ci.sh nix-shell --run ./run-ci.sh
- name: Upload artifact - name: Upload artifact
id: artifact-upload id: artifact-upload
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v3
with: with:
name: example-document name: example-document
path: ${{ github.workspace }}/example.pdf path: ${{ github.workspace }}/example.pdf
@ -47,7 +47,7 @@ jobs:
go-version: '>=1.20.1' go-version: '>=1.20.1'
- name: Download Artifcat - name: Download Artifcat
id: download id: download
uses: actions/download-artifact@v4 uses: actions/download-artifact@v3
with: with:
name: example-document name: example-document
path: ${{ github.workspace }}/Example.pdf path: ${{ github.workspace }}/Example.pdf

View File

@ -17,7 +17,7 @@ function format() {
exit 1 exit 1
fi fi
local imports=$(rg "#import \"([a-z0-9/\-.]+\.typ)\"" -Nor '$1' "$1") local imports=$(rg "#import \"([a-z0-9/\-]+\.typ)\"" -Nor '$1' "$1")
# format all included files # format all included files
while IFS= read -r line; do while IFS= read -r line; do
@ -26,16 +26,6 @@ function format() {
fi fi
format "$wd/$line" "$2" format "$wd/$line" "$2"
done <<< "$imports" done <<< "$imports"
local includes=$(rg "#import \"([a-z0-9/\-.]+\.typ)\"" -Nor '$1' "$1")
# format all included files
while IFS= read -r line; do
if [ -z "$line" ]; then
continue
fi
format "$wd/$line" "$2"
done <<< "$includes"
} }
case $1 in case $1 in

View File

@ -1,5 +1,5 @@
let let
nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/tarball/nixos-unstable"; nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/tarball/nixos-24.11";
pkgs = import nixpkgs { config = {}; overlays = []; }; pkgs = import nixpkgs { config = {}; overlays = []; };
in in

View File

@ -11,78 +11,64 @@
// default configuration // default configuration
#let default-config = ( #let default-config = (
// language settings used to make decisions about hyphenation and others // language settings used to make decisions about hyphenation and others
lang: "en", // ISO 3166 language code of text: "de", "en" lang: "en", // ISO 3166 language code of text: "de", "en"
region: "en", // region code region: "en", // region code
// mark this thesis as draft // mark this thesis as draft
// Adds preleminarry note page and watermark // Adds preleminarry note page and watermark
draft: true, draft: true,
// information about author(s) // information about author(s)
university: ( university: (
program: "Informationtechnology", program: "Informationtechnology",
faculty: "Technik", faculty: "Technik",
name: "dualen Hochschule Baden-Württemberg", name: "dualen Hochschule Baden-Württemberg",
campus: "Eppelheim", campus: "Eppelheim"
),
supervisor-signature: false,
authors: ((), ()),
coauthors: (),
// information about thesis
thesis: (
title: "Unofficial ABB/DHBW Typst template",
subtitle: "for reports and thesises", // subtitle may be none
submission-date: "23rd march 2020",
timeframe: "1st january 2020 - 20th march 2020",
kind: "T2000",
// translated version of abstract, only used in case language is not english
summary: none,
abstract: none,
preface: none,
keywords: ("IT", "other stuff"),
bibliography: none, /* bibliography("refs.bib") */
glossary: none,
appendices: none,
confidentiality: true,
authorship: true,
),
style: (
header: (
content-padding: 1.5em,
underline-top-padding: 0pt,
logo-height: 5em,
logo-image: "res/ABB.svg",
), ),
footer: ( supervisor-signature: false,
content-padding: 1.5em, authors: ((),()),
), // information about thesis
page: ( thesis: (
format: "a4", title: "Unofficial ABB/DHBW Typst template",
margin: ( subtitle: "for reports and thesises", // subtitle may be none
left: 3cm, submission-date: "23rd march 2020",
right: 2.5cm, timeframe: "1st january 2020 - 20th march 2020",
top: 2.5cm, kind: "T2000",
bottom: 2.5cm, // translated version of abstract, only used in case language is not english
), summary: none,
), abstract: none,
text: ( preface: none,
size: 12pt, keywords: ( "IT", "other stuff" ),
font: "Fira Sans", bibliography: none /* bibliography("refs.bib") */,
), glossary: none,
heading: ( appendices: none),
font: "Fira Sans", style: (
), header: (
code: ( content-padding: 1.5em,
theme: "res/abb.tmTheme", underline-top-padding: 0pt,
font: "FiraCode Nerd Font", logo-height: 5em,
lines: false, logo-image: "res/ABB.svg"),
size: 10pt, footer: (
tab-size: 4, content-padding: 1.5em),
), page: (
link: ( format: "a4",
color: ABB-GRAY-02, margin: (
), left: 3cm,
), right: 2.5cm,
) top: 2.5cm,
bottom: 2.5cm)),
text: (
size: 12pt,
font: "Fira Sans"),
heading: (
font: "Fira Sans"),
code: (
theme: "res/abb.tmTheme",
font: "FiraCode Nerd Font",
lines: false,
size: 10pt,
tab-size: 4),
link: (
color: ABB-GRAY-02)))
// Insert a dictionary `update` into `base` but only the entries of update that also exist in base // Insert a dictionary `update` into `base` but only the entries of update that also exist in base
// Runs recursively on all sub dictionaries // Runs recursively on all sub dictionaries
@ -107,15 +93,7 @@
} else if val == none or type(val) == type(update_val) { } else if val == none or type(val) == type(update_val) {
base.insert(key, update_val) base.insert(key, update_val)
} else { } else {
panic( panic("missmatched dictionary entry `" + key + "` type: expected `" + type(val) + "` got `" + type(update_val) + "`")
"missmatched dictionary entry `"
+ key
+ "` type: expected `"
+ type(val)
+ "` got `"
+ type(update_val)
+ "`",
)
} }
} else { } else {
base.insert(key, val) base.insert(key, val)

View File

@ -59,13 +59,8 @@ SOFTWARE.*/
let textLink = if display != none { let textLink = if display != none {
[#display] [#display]
} else if ( } else if (
( is_first or long == true
is_first or long == true ) and entlong != [] and entlong != "" and long != false {
)
and entlong != []
and entlong != ""
and long != false
) {
[#entlong (#entry.short#suffix)] [#entlong (#entry.short#suffix)]
} else { } else {
[#entry.short#suffix] [#entry.short#suffix]
@ -113,13 +108,8 @@ SOFTWARE.*/
} }
let textLink = if ( let textLink = if (
( is_first or long == true
is_first or long == true ) and entlong != [] and entlong != "" and long != false {
)
and entlong != []
and entlong != ""
and long != false
) {
[#entlong (#short)] [#entlong (#short)]
} else { } else {
[#short] [#short]
@ -138,11 +128,9 @@ SOFTWARE.*/
// show rule to make the references for glossarium // show rule to make the references for glossarium
#let make-glossary(body) = { #let make-glossary(body) = {
show ref: r => { show ref: r => {
if ( if r.element != none and r.element.func() == figure and r
r.element != none .element
and r.element.func() == figure .kind == __glossarium_figure {
and r.element.kind == __glossarium_figure
) {
// call to the general citing function // call to the general citing function
gls(str(r.target), suffix: r.citation.supplement) gls(str(r.target), suffix: r.citation.supplement)
} else { } else {
@ -209,7 +197,6 @@ SOFTWARE.*/
#let hasLong = long != "" and long != [] #let hasLong = long != "" and long != []
#let hasDesc = desc != "" and desc != [] #let hasDesc = desc != "" and desc != []
#set align(left)
#block( #block(
below: 1.5em, below: 1.5em,
width: 100%, width: 100%,
@ -242,15 +229,16 @@ SOFTWARE.*/
) )
.values .values
.map(x => { .map(x => {
let page-numbering = x.page-numbering() let page-numbering = x.page-numbering()
if page-numbering == none { if page-numbering == none {
page-numbering = "1" page-numbering = "1"
}
link(x)[#numbering(
page-numbering,
..counter(page).at(x),
)]
} }
link(x)[#numbering( )
page-numbering,
..counter(page).at(x),
)]
})
.join(", ") .join(", ")
} }
], ],

View File

@ -8,6 +8,7 @@
// License: MIT // License: MIT
#let glossary(entries, config) = { #let glossary(entries, config) = {
assert( assert(
type(entries) == dictionary, type(entries) == dictionary,
message: "The glossary is not a dictionary", message: "The glossary is not a dictionary",
@ -43,18 +44,14 @@
if "desc" in v { if "desc" in v {
assert( assert(
type(v.desc) == str, type(v.desc) == str,
message: "The description of glossary entry `" message: "The description of glossary entry `" + k + "` is not a string",
+ k
+ "` is not a string",
) )
} }
if "group" in v { if "group" in v {
assert( assert(
type(v.group) == str, type(v.group) == str,
message: "The optional group of glossary entry `" message: "The optional group of glossary entry `" + k + "` is not a string",
+ k
+ "` is not a string",
) )
} else { } else {
let acronym_group = if config.lang == "de" { let acronym_group = if config.lang == "de" {
@ -93,13 +90,11 @@
} }
} }
return processed_glossary return processed_glossary.pairs().map(((key, entry)) => (
.pairs() key: key,
.map(((key, entry)) => ( short: entry.short,
key: key, long: eval(entry.at("long", default: ""), mode: "markup"),
short: entry.short, desc: eval(entry.at("desc", default: ""), mode: "markup"),
long: eval(entry.at("long", default: ""), mode: "markup"), group: entry.at("group", default: ""),
desc: eval(entry.at("desc", default: ""), mode: "markup"), ))
group: entry.at("group", default: ""),
))
} }

View File

@ -126,9 +126,7 @@
config, config,
context [ context [
// add bibliography if set // add bibliography if set
#if ( #if "bibliography" in config.thesis and config.thesis.bibliography != none {
"bibliography" in config.thesis and config.thesis.bibliography != none
) {
pagebreak(weak: true) pagebreak(weak: true)
counter(page).update(1) counter(page).update(1)
set bibliography( set bibliography(

View File

@ -8,6 +8,7 @@
#let new_abstract(config) = ( #let new_abstract(config) = (
context { context {
set align(center + horizon) set align(center + horizon)
// only include summary when a language other than english is used // only include summary when a language other than english is used

View File

@ -8,9 +8,6 @@
#let new_confidentiality_statement_page(config) = ( #let new_confidentiality_statement_page(config) = (
context { context {
if not config.thesis.confidentiality {
return
}
pagebreak(weak: true) pagebreak(weak: true)
@ -54,24 +51,13 @@
set align(horizon) set align(horizon)
grid( grid(
// set width of columns // set width of columns
// we need two, so make both half the page width // we need two, so make both half the page width
columns: (50%, 50%), columns: (50%, 50%),
row-gutter: 0.75em, row-gutter: 0.75em,
align(left, { line(length: 6cm) }), align(left, {line(length: 6cm)}),
align(left, { line(length: 6cm) }), align(left, {line(length: 6cm)}),
align( align(left, if text.lang == "de" [ Ort, Datum ] else if text.lang == "en" [ Place, Date ] else { panic("no translation for language: ", text.lang) }),
left, align(left, if text.lang == "de" [ Unterschrift ] else if text.lang == "en" [ Signature ] else { panic("no translation for language: ", text.lang) }))
if text.lang == "de" [ Ort, Datum ] else if text.lang == "en" [
Place, Date
] else { panic("no translation for language: ", text.lang) },
),
align(
left,
if text.lang == "de" [ Unterschrift ] else if text.lang == "en" [
Signature
] else { panic("no translation for language: ", text.lang) },
)
)
} }
) )

View File

@ -8,9 +8,6 @@
#let new_declaration_of_authorship(config) = ( #let new_declaration_of_authorship(config) = (
context { context {
if not config.thesis.authorship {
return
}
pagebreak(weak: true) pagebreak(weak: true)
@ -56,24 +53,13 @@
set align(horizon) set align(horizon)
grid( grid(
// set width of columns // set width of columns
// we need two, so make both half the page width // we need two, so make both half the page width
columns: (50%, 50%), columns: (50%, 50%),
row-gutter: 0.75em, row-gutter: 0.75em,
align(left, { line(length: 6cm) }), align(left, {line(length: 6cm)}),
align(left, { line(length: 6cm) }), align(left, {line(length: 6cm)}),
align( align(left, if text.lang == "de" [ Ort, Datum ] else if text.lang == "en" [ Place, Date ] else { panic("no translation for language: ", text.lang) }),
left, align(left, if text.lang == "de" [ Unterschrift ] else if text.lang == "en" [ Signature ] else { panic("no translation for language: ", text.lang) }))
if text.lang == "de" [ Ort, Datum ] else if text.lang == "en" [
Place, Date
] else { panic("no translation for language: ", text.lang) },
),
align(
left,
if text.lang == "de" [ Unterschrift ] else if text.lang == "en" [
Signature
] else { panic("no translation for language: ", text.lang) },
)
)
} }
) )

View File

@ -12,18 +12,16 @@
// NOTE: will not render in case the listing is empty // NOTE: will not render in case the listing is empty
#let render_filtered_outline(title: str, kind: selector) = ( #let render_filtered_outline(title: str, kind: selector) = (
context { context {
let elems = query(figure.where(kind: kind)) let elems = query(figure.where(kind: kind))
let count = elems.len() let count = elems.len()
show outline.entry: it => { show outline.entry: it => {
link(it.element.location())[ link(it.element.location())[
#v(12pt, weak: true) #v(12pt, weak: true)
#it.prefix() #text(weight: "regular", it.body)
#[:]
#h(0.5em)
#text(weight: "regular", it.body())
#box(width: 1fr, it.fill) #box(width: 1fr, it.fill)
#[ #it.page()] #[ #it.page]
] ]
} }
@ -125,14 +123,9 @@
#let new_outline() = { #let new_outline() = {
pagebreak(weak: true) pagebreak(weak: true)
show outline.entry: it => { show outline.entry.where(level: 1): it => {
if it.level == 1 { v(1.5em, weak: true)
v(1.5em, weak: true) strong(it)
strong(it)
} else {
v(1.0em, weak: true)
it
}
} }
render_heading_outline() render_heading_outline()

View File

@ -8,6 +8,7 @@
#let new_prerelease_note(config) = ( #let new_prerelease_note(config) = (
context { context {
pagebreak(weak: true) pagebreak(weak: true)
let thesis = config.thesis let thesis = config.thesis

View File

@ -21,27 +21,14 @@
if config.style.header.logo-image == none { if config.style.header.logo-image == none {
// error // error
} else if config.style.header.logo-image.len() > 0 { } else if config.style.header.logo-image.len() > 0 {
align( align(left, image(config.style.header.logo-image, height: config.style.header.logo-height))
left,
image(
config.style.header.logo-image,
height: config.style.header.logo-height,
),
)
} else { } else {
align( align(left, image("../res/DHBW.svg", height: config.style.header.logo-height))
left,
image("../res/DHBW.svg", height: config.style.header.logo-height),
)
}, },
// right align logo of DHBW // right align logo of DHBW
if config.style.header.logo-image.len() > 0 { if config.style.header.logo-image.len() > 0 {
align( align(right, image("../res/DHBW.svg", height: config.style.header.logo-height))
right, })
image("../res/DHBW.svg", height: config.style.header.logo-height),
)
}
)
#set align(center) #set align(center)
@ -112,7 +99,7 @@
#v(1.5em) #v(1.5em)
#let rows = int(config.authors.len() / 3 + 0.9) #let rows = int(config.authors.len() / 3 + 0.5)
#for i in range(0, rows) { #for i in range(0, rows) {
let cols = calc.min(config.authors.len() - i * 3, 3) let cols = calc.min(config.authors.len() - i * 3, 3)
@ -121,30 +108,20 @@
.authors .authors
.slice(i * 3, i * 3 + cols) .slice(i * 3, i * 3 + cols)
.map(author => par([ .map(author => par([
#if author.at("name", default: none) != none { #if author.at("name", default: none) != none {
text(size: 1.25em, author.name) text(size: 1.25em, author.name)
linebreak() linebreak()
} }
#if author.at("company", default: none) != none { #if author.at("company", default: none) != none {
text(size: 1em, author.company) text(size: 1em, author.company)
linebreak() linebreak()
} }
#if author.at("contact", default: none) != none { #if author.at("contact", default: none) != none {
text(size: 1em, author.contact) text(size: 1em, author.contact)
linebreak() linebreak()
} }
#str(author.matriculation-number), #author.course #str(author.matriculation-number), #author.course
]))) ])))
}
]
#v(1em)
#align(center)[
coauthored in part by
#linebreak()
#for author in config.coauthors {
author
} }
] ]
@ -158,21 +135,18 @@
align( align(
bottom, bottom,
grid( grid(
// set width of columns // set width of columns
// we need two, so make both half the page width // we need two, so make both half the page width
columns: (60%, 40%), columns: (60%, 40%),
align( align(left, if text.lang == "de" [
left, Unterschrift des betrieblichen Betreuers
if text.lang == "de" [ ] else if text.lang == "en" [
Unterschrift des betrieblichen Betreuers Signature of the company supervisor
] else if text.lang == "en" [ ] else [
Signature of the company supervisor #context panic("no translation for language: ", text.lang)
] else [ ]
#context panic("no translation for language: ", text.lang)
],
),
align(right, { line(length: 6cm) })
), ),
align(right, {line(length: 6cm)})),
) )
} }

View File

@ -166,10 +166,10 @@
.map(make_row) .map(make_row)
.flatten() .flatten()
.map(c => if c.has("text") and c.text == "" { .map(c => if c.has("text") and c.text == "" {
v(1em) v(1em)
} else { } else {
c c
}) })
) )
}, },
) )
@ -193,15 +193,13 @@
// change the display supplement according to the text langugae // change the display supplement according to the text langugae
// based on: https://github.com/typst/typst/issues/3273 // based on: https://github.com/typst/typst/issues/3273
show figure.where(kind: raw): set figure( show figure.where(kind: raw): set figure(supplement: context {
supplement: context { if text.lang == "de" {
if text.lang == "de" { "Quelltext"
"Quelltext" } else {
} else { "Listing"
"Listing" }
} })
},
)
// APA style table // APA style table
set table( set table(
@ -247,9 +245,9 @@
header-ascent: style.header.content-padding, header-ascent: style.header.content-padding,
footer-descent: style.header.content-padding, footer-descent: style.header.content-padding,
margin: ( margin: (
top: style.page.margin.top top: style.page.margin.top + style.header.underline-top-padding + style
+ style.header.underline-top-padding .header
+ style.header.content-padding, .content-padding,
bottom: style.page.margin.bottom + style.footer.content-padding, bottom: style.page.margin.bottom + style.footer.content-padding,
left: style.page.margin.left, left: style.page.margin.left,
right: style.page.margin.right, right: style.page.margin.right,
@ -258,13 +256,15 @@
let current-page = here().page() let current-page = here().page()
if current-page == 1 { if current-page == 1 {
[] []
} else if ( } else if query(<end-of-prelude>)
query(<end-of-prelude>).first().location().page() > current-page .first()
) { .location()
.page() > current-page {
numbering("I", nums.pos().first()) numbering("I", nums.pos().first())
} else if ( } else if query(<end-of-content>)
query(<end-of-content>).first().location().page() >= current-page .first()
) { .location()
.page() >= current-page {
numbering("1", nums.pos().first()) numbering("1", nums.pos().first())
} else { } else {
numbering("a", nums.pos().first()) numbering("a", nums.pos().first())
@ -277,14 +277,10 @@
#if page-number == 1 { #if page-number == 1 {
[] []
} else if ( } else if query(<end-of-prelude>).first().location().page() > page-number {
query(<end-of-prelude>).first().location().page() > page-number
) {
set align(center) set align(center)
numbering("I", page-counter) numbering("I", page-counter)
} else if ( } else if query(<end-of-content>).first().location().page() >= page-number {
query(<end-of-content>).first().location().page() >= page-number
) {
numbering( numbering(
"1 / 1", "1 / 1",
page-counter, page-counter,
@ -300,11 +296,14 @@
if current-page == 1 { if current-page == 1 {
// logo moved to content // logo moved to content
} else if (
query(<end-of-content>).first().location().page() >= current-page } else if query(<end-of-content>)
and query(<end-of-prelude>).first().location().page() .first()
< current-page + 1 .location()
) { .page() >= current-page and query(<end-of-prelude>)
.first()
.location()
.page() < current-page + 1 {
let heading = currentH() let heading = currentH()
heading.at(0) heading.at(0)

View File

@ -24,9 +24,6 @@
contact: "sven.vogel123@web.de" contact: "sven.vogel123@web.de"
) )
), ),
coauthors: (
"Gorbatschew"
),
thesis: ( thesis: (
title: "Unofficial ABB/DHBW Typst template", title: "Unofficial ABB/DHBW Typst template",
subtitle: "for reports and thesises", subtitle: "for reports and thesises",
@ -40,8 +37,6 @@
bibliography: bibliography("refs.bib"), bibliography: bibliography("refs.bib"),
glossary: yaml("glossary.yml"), glossary: yaml("glossary.yml"),
appendices: include "appendix.typ", appendices: include "appendix.typ",
confidentiality: false,
authorship: false
), ),
style: ( style: (
header: ( header: (
@ -50,7 +45,7 @@
) )
)) ))
#import "@preview/wrap-it:0.1.1": wrap-content #import "@preview/wrap-it:0.1.0": wrap-content
= Lorem Ipsum = Lorem Ipsum

View File

@ -1,6 +1,6 @@
[package] [package]
name = "dhbw-abb-typst-template" name = "dhbw-abb-typst-template"
version = "0.6.3" version = "0.6.2"
entrypoint = "src/template.typ" entrypoint = "src/template.typ"
authors = ["Sven Vogel <sven.vogel1@de.abb.com>"] authors = ["Sven Vogel <sven.vogel1@de.abb.com>"]
license = "MIT" license = "MIT"