Compare commits

..

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

16 changed files with 174 additions and 294 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

@ -22,11 +22,10 @@
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, supervisor-signature: false,
authors: ((), ()), authors: ((),()),
coauthors: (),
// information about thesis // information about thesis
thesis: ( thesis: (
title: "Unofficial ABB/DHBW Typst template", title: "Unofficial ABB/DHBW Typst template",
@ -38,51 +37,38 @@
summary: none, summary: none,
abstract: none, abstract: none,
preface: none, preface: none,
keywords: ("IT", "other stuff"), keywords: ( "IT", "other stuff" ),
bibliography: none, /* bibliography("refs.bib") */ bibliography: none /* bibliography("refs.bib") */,
glossary: none, glossary: none,
appendices: none, appendices: none),
confidentiality: true,
authorship: true,
),
style: ( style: (
header: ( header: (
content-padding: 1.5em, content-padding: 1.5em,
underline-top-padding: 0pt, underline-top-padding: 0pt,
logo-height: 5em, logo-height: 5em,
logo-image: "res/ABB.svg", logo-image: "res/ABB.svg"),
),
footer: ( footer: (
content-padding: 1.5em, content-padding: 1.5em),
),
page: ( page: (
format: "a4", format: "a4",
margin: ( margin: (
left: 3cm, left: 3cm,
right: 2.5cm, right: 2.5cm,
top: 2.5cm, top: 2.5cm,
bottom: 2.5cm, bottom: 2.5cm)),
),
),
text: ( text: (
size: 12pt, size: 12pt,
font: "Fira Sans", font: "Fira Sans"),
),
heading: ( heading: (
font: "Fira Sans", font: "Fira Sans"),
),
code: ( code: (
theme: "res/abb.tmTheme", theme: "res/abb.tmTheme",
font: "FiraCode Nerd Font", font: "FiraCode Nerd Font",
lines: false, lines: false,
size: 10pt, size: 10pt,
tab-size: 4, tab-size: 4),
),
link: ( link: (
color: ABB-GRAY-02, 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%,
@ -250,7 +237,8 @@ SOFTWARE.*/
page-numbering, page-numbering,
..counter(page).at(x), ..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,9 +90,7 @@
} }
} }
return processed_glossary return processed_glossary.pairs().map(((key, entry)) => (
.pairs()
.map(((key, entry)) => (
key: key, key: key,
short: entry.short, short: entry.short,
long: eval(entry.at("long", default: ""), mode: "markup"), long: eval(entry.at("long", default: ""), mode: "markup"),

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)
@ -58,20 +55,9 @@
// 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)
@ -60,20 +57,9 @@
// 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)
@ -120,31 +107,17 @@
grid(columns: cols, column-gutter: 1.5em, ..config grid(columns: cols, column-gutter: 1.5em, ..config
.authors .authors
.slice(i * 3, i * 3 + cols) .slice(i * 3, i * 3 + cols)
.map(author => par([ .map(author => grid(
#if author.at("name", default: none) != none { columns: 1,
text(size: 1.25em, author.name) row-gutter: 1em,
linebreak() text(size: 1.25em, author.name),
} text(size: 1em, author.company),
#if author.at("company", default: none) != none { text(size: 1em, author.contact),
text(size: 1em, author.company) [
linebreak() #str(author.matriculation-number),
} #author.course
#if author.at("contact", default: none) != none { ],
text(size: 1em, author.contact) )))
linebreak()
}
#str(author.matriculation-number), #author.course
])))
}
]
#v(1em)
#align(center)[
coauthored in part by
#linebreak()
#for author in config.coauthors {
author
} }
] ]
@ -161,18 +134,15 @@
// 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,
if text.lang == "de" [
Unterschrift des betrieblichen Betreuers Unterschrift des betrieblichen Betreuers
] else if text.lang == "en" [ ] else if text.lang == "en" [
Signature of the company supervisor Signature of the company supervisor
] else [ ] else [
#context panic("no translation for language: ", text.lang) #context panic("no translation for language: ", text.lang)
], ]
),
align(right, { line(length: 6cm) })
), ),
align(right, {line(length: 6cm)})),
) )
} }

View File

@ -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.1"
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"