Compare commits

...

3 Commits

Author SHA1 Message Date
Sven Vogel 968f63be78 fixed: outline including appendices 2024-07-01 14:46:32 +02:00
Sven Vogel ac70aade96 added: appendix 2024-07-01 13:50:54 +02:00
Sven Vogel 77d197c029 updated style and example 2024-07-01 12:13:57 +02:00
18 changed files with 2081 additions and 141 deletions

View File

@ -1,17 +1,9 @@
# Praxisbericht-Template-Typst
Tempalte für Praxisberichte, T100, T200, T3000 und Bechelor Arbeiten. Im Gegensatz zu https://git.montehaselino.de/DHBW/Praxisbericht-Template wird Typst und nicht LaTeX als typsetting sprache verwendet.
The template makes use of ABB and DHBW branding.
## Geplante Features:
- Inhaltsverzeichnis
- Quelltextverzeichnis
- Abbildungsverzechnis
- Tabellenverzeichnis
- Literaturverzeichnis
- Glossar
- Abkürzungsverzeichnis
- Ligratures in code blöcken
- Diagramme
- Literatur
- Fußnoten
- Anhang
## Format
All pages have a margin of 2.5cm between header/footer/content and the page border.
Header and footer do not overlap into this margin.
Bibliography is formated with the IEEE style. Appendecies make use of the APA style.

9
examples/appendix.typ Normal file
View File

@ -0,0 +1,9 @@
= Ein Text im Anhang
#label("Anhang-A")
#lorem(50)
== Noch mehr Text im Anhang
#lorem(50)

0
examples/glossary.typ Normal file
View File

View File

@ -1,17 +1,60 @@
#import "../src/template.typ": dhbw-template
#show: dhbw-template
#let config = (
lang: "de",
region: "de",
author: (
name: "Sven Vogel",
semester: 4,
program: "Informationstechnik",
course: "TINF22IT2",
faculty: "Technik",
university: "DHBW Mannheim",
company: "ABB AG",
supervisor: "Florian Miedniak",
matriculation-number: 1191225),
thesis: (
title: "Konfiguration & Integration von PROFINET",
subtitle: "für die AC500 SPS",
submission-date: "20. März 2024",
timeframe: "1. Januar 2023 - 20. März 2024",
kind: "T2000",
summary: "",
abstract: "",
keywords: ( "IT", "PROFINET" ),
bibliography: bibliography("refs.yml"),
glossary: (
(
key: "oidc",
short: "OIDC",
long: "OpenID Connect",
desc: [OpenID is an open standard and decentralized authentication protocol promoted by the non-profit #link("https://en.wikipedia.org/wiki/OpenID#OpenID_Foundation")[OpenID Foundation].]
),
(
key: "potato",
short: "potato",
plural: "potatoes",
desc: [#lorem(10)]
),
),
appendices: include "appendix.typ"
))
#show: doc => dhbw-template(config: config, doc: doc)
= Lorem Ipsum
#lorem(25)
@oidc
#lorem(100)
@Anhang-A
== Lorem Ipsum 2
#lorem(200)
@texbook
= Lorem Ipsum 3
@ -31,9 +74,42 @@ $
"Hello", "World"),
caption: [ Some table ])
#pagebreak()
#figure(
```rust
fn main() -> {
use std::env;
use std::fs::OpenOptions;
use std::io::Write;
}
fn main() {
// Get the file path from the environment variable
let file_path = match env::var("OUTPUT_FILE") {
Ok(path) => path,
Err(_) => {
eprintln!("Error: OUTPUT_FILE environment variable is not set");
return;
}
};
// Open the file in append mode, create it if it doesn't exist
let mut file = match OpenOptions::new()
.append(true)
.create(true)
.open(&file_path)
{
Ok(file) => file,
Err(e) => {
eprintln!("Error opening file {}: {}", file_path, e);
return;
}
};
// Write "Hello, World" to the file
if let Err(e) = writeln!(file, "Hello, World") {
eprintln!("Error writing to file: {}", e);
} else {
println!("Successfully appended 'Hello, World' to {}", file_path);
}
}
```, caption: [Some code])

6
examples/refs.yml Normal file
View File

@ -0,0 +1,6 @@
texbook:
type: book
title: The {TeX} Book
author: Knuth, Donald E.
date: 1986
publisher: Addison-Wesley Professional

View File

@ -1,6 +1,15 @@
// .--------------------------------------------------------------------------.
// | Abstract |
// '--------------------------------------------------------------------------'
#let new_abstract(thesis) = context [
// Author: Sven Vogel
// Edited: 28.06.2024
// License: MIT
#let new_abstract(config) = context [
#let thesis = config.thesis
#pagebreak(weak: true)
#align(center + horizon)[
#if text.lang == "de" [

35
src/pages/appendix.typ Normal file
View File

@ -0,0 +1,35 @@
#let show-appendix(config: dictionary) = context {
counter(heading).update(0)
let title = if text.lang == "en" {
"Appendix"
} else {
"Anhang"
}
if "appendices" in config.thesis {
pagebreak(weak: true)
heading(level: 1, numbering: none, title)
v(-2em)
// APA style appendix
show heading: it => {
let number = if it.numbering != none {
counter(heading).display(it.numbering)
}
block()[
#title #number - #it.body
]
}
show heading.where(level: 1): it => v(2em) + it + v(1em)
show heading.where(level: 2): it => v(1em) + it + v(0.5em)
show heading.where(level: 3): it => v(0.5em) + it + v(0.25em)
set heading(numbering: "A.1", supplement: title)
config.thesis.appendices
}
}

View File

@ -1,7 +1,8 @@
#let new_confidentiality_statement_page(
thesis,
author) = context [
#let new_confidentiality_statement_page(config) = context [
#let thesis = config.thesis
#let author = config.author
#v(2em)
#if text.lang == "de" [

View File

@ -1,5 +1,8 @@
#let new_declaration_of_authorship(thesis, author) = context [
#let new_declaration_of_authorship(config) = context [
#let thesis = config.thesis
#let author = config.author
#v(2em)
#if text.lang == "de" [

View File

@ -1,7 +0,0 @@
#let new-glossar(glossary) = {
import "@preview/glossarium:0.4.1": make-glossary, print-glossary, gls, glspl
show: make-glossary
print-glossary(glossary)
}

View File

@ -55,10 +55,34 @@
pagebreak(weak: true)
outline(
target: heading.where(supplement: [chapter]),
title: heading(level: 3, title),
indent: auto)
}
#let render_appendix_outline() = context {
let supplement = if text.lang == "en" {
[Appendix]
} else {
[Anhang]
}
if query(heading.where(supplement: supplement)).len() > 0 {
let title = if (text.lang == "de") {
"Anhangsverzeichnis"
} else if text.lang == "en" {
"Table of Appendices"
}
pagebreak(weak: true)
outline(
target: heading.where(supplement: supplement),
title: heading(level: 3, title),
indent: auto)
}
}
#let new_outline() = {
show outline.entry.where(
level: 1,
@ -73,5 +97,7 @@
render_raw_outline()
render_appendix_outline()
render_heading_outline()
}

View File

@ -1,5 +1,8 @@
#let new_prerelease_note(thesis, author) = context [
#let new_prerelease_note(config) = context [
#let thesis = config.thesis
#let author = config.author
#v(2em)
#if text.lang == "de" [

View File

@ -1,22 +1,11 @@
#let new_title_page(
thesis,
author) = context [
#let new_title_page(config) = context [
#let LogoHeight = 1.5cm
#let thesis = config.thesis
#let author = config.author
#set align(center)
// logo of ABB and DHBW
#grid(
// set width of columns
// we need two, so make both half the page width
columns: (50%, 50%),
// left align logo of ABB
align(left, image("res/ABB.svg", height: LogoHeight)),
// right align logo of DHBW
align(right, image("res/DHBW.svg", height: LogoHeight)))
// title
#v(2cm)
#text(size: 2em, weight: "semibold", thesis.title)
@ -130,5 +119,5 @@
)
)
#counter(page).update(1)
#counter(page).update(0)
]

View File

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 52 KiB

1742
src/res/github.tmTheme Normal file

File diff suppressed because it is too large Load Diff

View File

@ -7,8 +7,14 @@
// Edited: 27.06.2024
// License: MIT
#let HeaderPaddingBottom = 1.5em
#let LogoHeight = 3em
#let HeaderUnderlinePaddingTop = 0pt
// global style of document
#let global_styled_doc(doc: content) = context [
#let global_styled_doc(config: dictionary, body: content) = context [
#let thesis = config.thesis
// set page geometry
// paper format of A4
#set page(
@ -26,12 +32,22 @@
font: "Montserrat",
weight: "semibold")
#set heading(supplement: [chapter])
// Set header spacing
#show heading.where(level: 1): it => v(2em) + it + v(1em)
#show heading.where(level: 2): it => v(1em) + it + v(0.5em)
#show heading.where(level: 3): it => v(0.5em) + it + v(0.25em)
#set raw(tab-size: 4)
#set raw(tab-size: 4, theme: "res/github.tmTheme")
#show raw.where(block: true): code => {
show raw.line: line => {
text(fill: gray)[#line.number]
h(1em)
line.body
}
code
}
#set block(spacing: 2em)
#set par(
@ -39,68 +55,95 @@
first-line-indent: 1em,
leading: 1em)
#doc
]
#show link: set text(fill: red.darken(15%))
#show ref: set text(fill: red.darken(15%))
#let HeaderPaddingBottom = 1.5em
#let LogoHeight = 3em
#let HeaderUnderlinePaddingTop = 0pt
#let prelude_styled(body: content, thesis) = context [
#set heading(numbering: none)
#set page(
header-ascent: HeaderUnderlinePaddingTop + HeaderPaddingBottom,
numbering: "I",
margin: (top: 2.5cm + LogoHeight + HeaderUnderlinePaddingTop + HeaderPaddingBottom),
header: [
#grid(
columns: (1fr, auto),
align: (horizon, bottom),
context [ _ #thesis.title _ ],
image("pages/res/DHBW.svg", height: LogoHeight)
)
#v(HeaderUnderlinePaddingTop - 1em)
#line(length: 100%)
])
footer-descent: 1em,
margin: (top: 2.5cm + LogoHeight + HeaderUnderlinePaddingTop + HeaderPaddingBottom, bottom: 2.5cm + 1em),
numbering: (..nums) => {
let current-page = here().page()
if current-page == 1{
[]
} else if query(<end-of-prelude>).first().location().page() > current-page {
numbering("I", nums.pos().first())
} else if query(<end-of-content>).first().location().page() >= current-page {
numbering("1 / 1", ..nums)
} else {
numbering("a", nums.pos().first())
}
},
header: context {
set align(left)
if here().page() == 1 {
// logo of ABB and DHBW
grid(
// set width of columns
// we need two, so make both half the page width
columns: (50%, 50%),
// left align logo of ABB
align(left, image("res/ABB.svg", height: LogoHeight)),
// right align logo of DHBW
align(right, image("res/DHBW.svg", height: LogoHeight)))
} else if query(<end-of-prelude>).first().location().page() <= here().page() {
let headers-before = query(selector(heading.where(numbering: "1.", level: 1)).before(here()))
let header-title = thesis.title
if headers-before.len() > 0 {
header-title = headers-before.last().body
} else {
let headers-after = query(selector(heading.where(numbering: "1.", level: 1)).after(here()))
if headers-after.len() > 0 {
header-title = headers-after.first().body
}
}
grid(
columns: (1fr, auto),
align: (horizon, bottom),
context [ _ #header-title _ ],
image("res/DHBW.svg", height: LogoHeight))
v(HeaderUnderlinePaddingTop - 1em)
line(length: 100%)
} else {
grid(
columns: (1fr, auto),
align: (horizon, bottom),
context [ _ #config.thesis.title _ ],
image("res/DHBW.svg", height: LogoHeight)
)
v(HeaderUnderlinePaddingTop - 1em)
line(length: 100%)
}
})
#body
]
#let content_styled(body: content, thesis) = [
#let content_styled(config: dictionary, body: content) = [
// setup equate for sub equation labeling
#import "@preview/equate:0.2.0": equate
#show: equate.with(breakable: true, sub-numbering: true)
#set math.equation(numbering: "(1.1)")
#set heading(numbering: "1.")
#page(
header-ascent: HeaderUnderlinePaddingTop + HeaderPaddingBottom,
numbering: "1/1",
footer-descent: 1em,
margin: (top: 2.5cm + LogoHeight + HeaderUnderlinePaddingTop + HeaderPaddingBottom, bottom: 2.5cm + 1em),
header: context [
#let headers-before = query(selector(heading.where(numbering: "1.", level: 1)).before(here()))
#let header-title = thesis.title
#let thesis = config.thesis
#if headers-before.len() > 0 {
header-title = headers-before.last().body
} else {
let headers-after = query(selector(heading.where(numbering: "1.", level: 1)).after(here()))
if headers-after.len() > 0 {
header-title = headers-after.first().body
}
}
#grid(
columns: (1fr, auto),
align: (horizon, bottom),
context [ _ #header-title _ ],
image("pages/res/DHBW.svg", height: LogoHeight)
)
#v(HeaderUnderlinePaddingTop - 1em)
#line(length: 100%)
])[
#body
]
#body
]
#let end_styled(config: dictionary, body: content) = [
#set heading(numbering: "1.")
#let thesis = config.thesis
#body
]

View File

@ -8,12 +8,18 @@
// License: MIT
// start of template pages and styles
#let dhbw-template(doc) = [
#let dhbw-template(config: dictionary, doc: content) = [
#import "style.typ": global_styled_doc, prelude_styled, content_styled
#import "style.typ": global_styled_doc, content_styled, end_styled
// set document properties
#set document(
author: config.author.name,
keywords: config.thesis.keywords,
title: config.thesis.title)
// apply global style to every element in the argument content
#global_styled_doc(doc: [
#global_styled_doc(config: config, body: [
#import "pages/titlepage.typ": new_title_page
#import "pages/declaration-of-authorship.typ": new_declaration_of_authorship
@ -21,60 +27,67 @@
#import "pages/prerelease-note.typ": new_prerelease_note
#import "pages/outline.typ": new_outline
#import "pages/abstract.typ": new_abstract
#import "pages/glossar.typ": new-glossar
#import "pages/appendix.typ": show-appendix
#set text(lang: "de", region: "de")
#let author = (
name: "Sven Vogel",
semester: 4,
program: "Informationstechnik",
course: "TINF22IT2",
faculty: "Technik",
university: "DHBW Mannheim",
company: "ABB AG",
supervisor: "Florian Miedniak",
matriculation-number: 1191225
)
#let thesis = (
title: "Konfiguration & Integration von PROFINET",
subtitle: "für die AC500 SPS",
submission-date: "20. März 2024",
timeframe: "1. Januar 2023 - 20. März 2024",
kind: "T2000",
summary: "",
abstract: "",
)
#let glossary = ()
// configure text locale
#set text(lang: config.lang, region: config.region)
// preppend title page
#new_title_page(thesis, author)
#new_title_page(config)
#prelude_styled(thesis, body: [
#pagebreak(weak: true)
#new_declaration_of_authorship(thesis, author)
// prelude includes: title, declaration of authorship, confidentiality statement, outline and abstract
// these will have roman page numbers
#pagebreak(weak: true)
#new_confidentiality_statement_page(thesis, author)
#pagebreak(weak: true)
#new_declaration_of_authorship(config)
#pagebreak(weak: true)
#new_prerelease_note(thesis, author)
#pagebreak(weak: true)
#new_confidentiality_statement_page(config)
#pagebreak(weak: true)
#new_outline()
#pagebreak(weak: true)
#new_prerelease_note(config)
#pagebreak(weak: true)
#new_abstract(thesis)
#pagebreak(weak: true)
#new_outline()
#pagebreak(weak: true)
#new-glossar(glossary)
])
// glossary is built inline here because the links must be
// exposed to the entire document
#import "@preview/glossarium:0.4.1": make-glossary, print-glossary, gls, glspl
#show: make-glossary
#content_styled(thesis, body: [
#pagebreak(weak: true)
#heading(supplement: [outline], "Glossar")
#print-glossary(config.thesis.glossary)
#pagebreak(weak: true)
#new_abstract(config)
#pagebreak(weak: true)
#counter(page).update(1)
// mark end of prelude
#metadata("prelude terminate") <end-of-prelude>
#content_styled(config: config, body: [
// code of document follows here
#doc
])
#metadata("content terminate") <end-of-content>
#end_styled(config: config, body: [
// add bibliography if set
#if config.thesis.bibliography != none {
pagebreak(weak: true)
set bibliography(style: "ieee")
config.thesis.bibliography
counter(page).update(1)
}
// appendix
#show-appendix(config: config)
])
])
]