Skip to content

Commit 068e1f3

Browse files
authored
Merge pull request #8 from FussballAndy/feature/tudaexercise
Add tudaexercise template
2 parents e092308 + b1c468a commit 068e1f3

File tree

20 files changed

+633
-254
lines changed

20 files changed

+633
-254
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,8 @@ tudapub*.pdf
77
example_*.pdf
88
test*.pdf
99

10-
!example_tudapub.pdf
10+
!example_tudapub.pdf
11+
12+
.vscode
13+
.DS_Store
14+
.venv

README.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Typst Template for the Corporate Design of TU Darmstadt :book:
2-
This **unofficial** template can be used to write in [Typst](https://github.com/typst/typst) with the corporate design of [TU Darmstadt](https://www.tu-darmstadt.de/).
1+
# Typst Templates for the Corporate Design of TU Darmstadt :book:
2+
These **unofficial** templates can be used to write in [Typst](https://github.com/typst/typst) with the corporate design of [TU Darmstadt](https://www.tu-darmstadt.de/).
33

44
#### Disclaimer
55
Please ask your supervisor if you are allowed to use typst and this template for your thesis or other documents.
@@ -18,13 +18,18 @@ For missing features, ideas or other problems you can just open an issue :wink:.
1818
| Template | Preview | Example | Scope |
1919
|----------|---------|---------|-------|
2020
| [tudapub](templates/tudapub/template/tudapub.typ) | <img src="templates/tudapub/preview/tudapub_prev-01.png" height="300px"> | [example_tudapub.pdf](example_tudapub.pdf) <br/> [example_tudapub.typ](example_tudapub.typ) | Master and Bachelor thesis |
21-
| [tuda-exercise](templates/tudaexercise/template/tudaexercise.typ) | <img src="templates/tudaexercise/preview/tudaexercise_prev-1.png" height="300px"> | [example_tudaexercise-TODO.pdf](TODO) <br/> [example_tudaexercise-TODO-.typ](TODO.typ) | Exercises |
21+
| [tudaexercise](templates/tudaexercise/template/tudaexercise.typ) | <img src="templates/tudaexercise/preview/tudaexercise_prev-1.png" height="300px"> | [Example File](templates_examples/tudaexercise/main.typ) | Exercises |
2222

2323
## Usage
2424
Create a new typst project based on this template locally.
2525
```bash
26+
# for tudapub
2627
typst init @preview/athena-tu-darmstadt-thesis
2728
cd athena-tu-darmstadt-thesis
29+
30+
# for tudaexercise
31+
typst init @preview/athena-tu-darmstadt-exercise
32+
cd athena-tu-darmstadt-exercise
2833
```
2934
Or create a project on the typst web app based on this template.
3035

@@ -35,7 +40,7 @@ For a manual setup create a folder for your writing project and download this te
3540
```bash
3641
mkdir my_thesis && cd my_thesis
3742
mkdir templates && cd templates
38-
git clone https://github.com/JeyRunner/tuda-typst-templates templates/
43+
git clone https://github.com/JeyRunner/tuda-typst-templates
3944
```
4045
</details>
4146

@@ -48,12 +53,16 @@ cd asssets/logos
4853
./convert_logo.sh
4954
```
5055

56+
Note: The here used `pdf2svg` command might not be available. In this case we recommend a online converter like [PDF24 Tools](https://tools.pdf24.org/en/pdf-to-svg). There also is a [tool](https://github.com/FussballAndy/typst-img-to-local) to install images as local typst packages.
57+
5158
Also download the required fonts `Roboto` and `XCharter`:
5259
```bash
5360
cd asssets/fonts
5461
./download_fonts.sh
5562
```
56-
Now you can install all fonts in the folders in `fonts` on your system.
63+
Optionally you can install all fonts in the folders in `fonts` on your system. But you can also use Typst's `--font-path` option. Or install them in a folder and add the folder to `TYPST_FONT_PATHS` for a single font folder.
64+
65+
Note: wget might not be available. In this case either download it or replace the command with something like `curl <url> -o <filename> -L`
5766

5867
<details>
5968
<summary>Create a main.typ file for the manual template installation.</summary>
@@ -82,7 +91,7 @@ Some Text
8291
typst --watch main.typ --font-path asssets/fonts/
8392
```
8493

85-
This will watch your file and recompile it to a pdf when the file is saved. For writing, you can use [Vscode](https://code.visualstudio.com/) with these extensions: [Typst LSP](https://marketplace.visualstudio.com/items?itemName=nvarner.typst-lsp) and [Typst Preview](https://marketplace.visualstudio.com/items?itemName=mgt19937.typst-preview). Or use the [typst web app](https://typst.app/) (here you need to upload the logo and the fonts).
94+
This will watch your file and recompile it to a pdf when the file is saved. For writing, you can use [Vscode](https://code.visualstudio.com/) with these extensions: [Tinymist Typst](https://marketplace.visualstudio.com/items?itemName=myriad-dreamin.tinymist). Or use the [typst web app](https://typst.app/) (here you need to upload the logo and the fonts).
8695

8796
Note that we add `--font-path` to ensure that the correct fonts are used.
8897
Due to a bug (typst/typst#2917 typst/typst#2098) typst sometimes uses the font `Roboto condensed` instead of `Roboto`.

assets/logos/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
*.jpeg
22
*.png
33
*.svg
4-
*.pdf
4+
*.pdf
5+
!tuda_replace.svg

assets/logos/tuda_replace.svg

Lines changed: 21 additions & 0 deletions
Loading

common/colorutil.typ

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#let calc-color-component(srgb) = {
2+
if srgb <= 0.03928 {
3+
return srgb / 12.92
4+
} else {
5+
return calc.pow((srgb + 0.055) / 1.055, 2.4)
6+
}
7+
}
8+
9+
#let calc-relative-luminance(color) = {
10+
let rgb_color = rgb(color.to-hex())
11+
let components = rgb_color.components(alpha: false)
12+
13+
let r_srgb = float(components.at(0))
14+
let b_srgb = float(components.at(1))
15+
let g_srgb = float(components.at(2))
16+
return calc-color-component(r_srgb) * 0.2126 + calc-color-component(b_srgb) * 0.0722 + calc-color-component(g_srgb) * 0.7152
17+
}
18+
19+
#let calc-contrast(rl1, rl2) = {
20+
let l1 = calc.max(rl1, rl2)
21+
let l2 = calc.min(rl1, rl2)
22+
return (l1 + 0.05) / (l2 + 0.05)
23+
}

common/dictutil.typ

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#let overwrite-dict(new, base) = {
2+
for key in base.keys() {
3+
if key in new {
4+
base.insert(key, new.at(key))
5+
}
6+
}
7+
return base
8+
}

common/headings.typ

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
#import "props.typ": tud_heading_line_thin_stroke
1+
#import "props.typ": tud_heading_line_thin_stroke, tud_header_line_height
2+
3+
#let tud_body_line_height = tud_header_line_height / 2
24

35
#let tud-heading-with-lines(
46
heading_margin_before: 0mm,
@@ -42,4 +44,49 @@
4244
v(10pt)
4345
)
4446
]
47+
}
48+
49+
#let tuda-section-lines(above: 1.8em, below: 1.2em, ruled: true, body) = {
50+
block(
51+
width: 100%,
52+
inset: 0mm,
53+
outset: 0mm,
54+
above: above,
55+
below: below,
56+
{
57+
set block(spacing: 0.2em)
58+
if ruled {
59+
line(length: 100%, stroke: tud_body_line_height)
60+
}
61+
body
62+
if ruled {
63+
line(length: 100%, stroke: tud_body_line_height)
64+
}
65+
}
66+
)
67+
}
68+
69+
70+
/// Creates a section similar to headers
71+
/// But does not add other text or a counter.
72+
/// ```
73+
/// #tuda-section("Lorem ipsum")
74+
/// ```
75+
/// - title (str): The title of this section
76+
#let tuda-section(title) = {
77+
tuda-section-lines(text(title, font: "Roboto", weight: "bold", size: 11pt))
78+
}
79+
80+
/// Creates a subsection similar to level 2 headers.
81+
/// But does not add other text or a counter.
82+
/// ```
83+
/// #tuda-subsection("Lorem ipsum")
84+
/// ```
85+
/// - title (str): The title of this subsection
86+
#let tuda-subsection(title) = {
87+
tuda-section-lines(above: 1.4em, below: 1em, text(title, font: "Roboto", weight: "regular", size: 11pt))
88+
}
89+
90+
#let tuda-subsection-unruled(title) = {
91+
tuda-section-lines(above: 1.4em, below: 1em, ruled: false, text(title, font: "Roboto", weight: "regular", size: 11pt))
4592
}

common/props.typ

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
#let tud_heading_line_thin_stroke = 0.75pt
44

5-
5+
#let tud_header_line_height = 1.2pt
6+
#let tud_inner_page_margin_top = 22pt
7+
#let tud_title_logo_height = 22mm
68

79

810
#let tud_page_margin_title_page = (
@@ -31,4 +33,11 @@
3133
left: 25mm,
3234
right: 25mm,
3335
bottom: 15mm - 1mm // should be 20mm according to guidelines
36+
)
37+
38+
#let tud_exercise_page_margin = (
39+
top: 15mm,
40+
left: 15mm,
41+
right: 15mm,
42+
bottom: 20mm,
3443
)

common/tudacolors.typ

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,55 @@
5252
"9d": "961C26",
5353
"10d": "732054",
5454
"11d": "4C226A",
55+
)
56+
57+
#let text_colors = (
58+
"0a": black,
59+
"0b": white,
60+
"0c": white,
61+
"0d": white,
62+
"1a": white,
63+
"1b": white,
64+
"1c": white,
65+
"1d": white,
66+
"2a": white,
67+
"2b": white,
68+
"2c": white,
69+
"2d": white,
70+
"3a": white,
71+
"3b": white,
72+
"3c": white,
73+
"3d": white,
74+
"4a": black,
75+
"4b": white,
76+
"4c": white,
77+
"4d": white,
78+
"5a": black,
79+
"5b": black,
80+
"5c": black,
81+
"5d": white,
82+
"6a": black,
83+
"6b": black,
84+
"6c": white,
85+
"6d": white,
86+
"7a": black,
87+
"7b": black,
88+
"7c": white,
89+
"7d": white,
90+
"8a": white,
91+
"8b": white,
92+
"8c": white,
93+
"8d": white,
94+
"9a": white,
95+
"9b": white,
96+
"9c": white,
97+
"9d": white,
98+
"10a": white,
99+
"10b": white,
100+
"10c": white,
101+
"10d": white,
102+
"11a": white,
103+
"11b": white,
104+
"11c": white,
105+
"11d": white
55106
)

scripts/publish.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import shutil
66
import pathlib
77
import re
8+
import sys
89

910

1011

@@ -31,6 +32,10 @@
3132
/common/
3233
/assets/
3334
35+
.DS_Store
36+
.venv
37+
.vscode
38+
3439
"""
3540

3641
# template folder names
@@ -58,7 +63,7 @@
5863
description='Copies this repo to typst local packages or locally cloned typst-packages while not copying the ignored files.'
5964
)
6065
parser.add_argument('--local', action='store_true',
61-
help='copy to $HOME/.local/share/typst/packages/local/<PACKAGE_NAME>/<VERSION>.99')
66+
help='copy to $TYPST_PACKAGE_ROOT/typst/packages/local/<PACKAGE_NAME>/<VERSION>.99')
6267
parser.add_argument('--clean-dist-folder-force', action='store_true',
6368
help='Delete the contents of the destinatio folder before copying without asking. ')
6469
parser.add_argument('--universe', type=str,
@@ -77,7 +82,15 @@
7782
exit(0)
7883

7984
if args.local:
80-
copy_dest_dir = str(pathlib.Path.home()) + "/.local/share/typst/packages/local/"
85+
if sys.platform.startswith("linux"):
86+
copy_dest_dir = str(pathlib.Path.home()) + "/.local/share/typst/packages/local/"
87+
elif sys.platform.startswith("win32"):
88+
copy_dest_dir = os.getenv("APPDATA") + "/typst/packages/local/"
89+
elif sys.platform.startswith("darwin"):
90+
copy_dest_dir = str(pathlib.Path.home()) + "/Library/Application Support/typst/packages/local/"
91+
else:
92+
print('Error: Unsupported platform')
93+
exit(0)
8194
elif args.universe is not None:
8295
copy_dest_dir = args.universe + '/packages/preview/'
8396

@@ -136,7 +149,7 @@ def copy_template(copy_dest_dir, template_folder_name = 'tudapub'):
136149
/templates_examples/*/logos/*
137150
!/templates_examples/*/logos/*.sh
138151
/templates_examples/*/fonts/*
139-
!/template_examples/*/fonts/*.sh
152+
!/templates_examples/*/fonts/*.sh
140153
""")
141154

142155

0 commit comments

Comments
 (0)