Skip to content

Commit eb133d6

Browse files
authored
kthesis:0.1.7 (#5164)
1 parent 32c0875 commit eb133d6

30 files changed

Lines changed: 1861 additions & 0 deletions
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Rafael Oliveira
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
MIT No Attribution
2+
3+
Copyright (c) 2025 Rafael Oliveira
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so.
11+
12+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18+
SOFTWARE.
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
# KTHesis
2+
3+
An unofficial, slightly opinionated, extensible [Typst](https://typst.app/home/)
4+
template for writing a Degree Project thesis for KTH Royal Institute of
5+
Technology in Stockholm, Sweden.
6+
7+
Inspired by and partially adapted from Gerald Q. Maguire Jr.'s LaTeX template
8+
and KTH's official degree project report covers as published on the
9+
[institution's website](https://www.kth.se/en/omslag-till-ditt-exjobb-1.479838).
10+
11+
## Overview
12+
13+
This template is primarily targeted at Master's Degree theses, though it aims to
14+
be sufficiently generic so to also be suitable for other kinds of reports. It
15+
strives to simplify drafting and counts with the following features, among
16+
others:
17+
18+
- Supports both English and Swedish as primary language, with built-in
19+
translations for template-managed headings and sections;
20+
- Supports additional Abstracts in other languages;
21+
- Supports arbitrary extra preamble sections, such as a Glossary / Table of
22+
Acronyms - i.e., integrates well with
23+
[glossarium](https://typst.app/universe/package/glossarium) or similar;
24+
- Does not conflict with Typst's native
25+
[bibliography](https://typst.app/docs/reference/model/bibliography/) mechanism
26+
even without requiring any additional configuration - "plug and play";
27+
- Uses [hydra](https://typst.app/universe/package/hydra) to show the current
28+
Chapter title in the page header;
29+
- Uses [headcount](https://typst.app/universe/package/headcount) to make figure,
30+
table, and listing numbers dependent on Chapter number;
31+
- Includes built-in selective inclusion of indices: an index for figures,
32+
tables, and listings is automatically added if needed and omitted if not;
33+
- Can generate a "For DiVA" JSON-based trailing section for compatibility with
34+
existing, school-prevalent automation scripts; and
35+
- Provides a simple interface and tuning options.
36+
37+
## Getting Started
38+
39+
Visit the template's [homepage](https://typst.app/universe/package/kthesis/) and
40+
click "Create project in app" to try it out in the Typst web app.
41+
42+
Alternatively, you can also run `typst init @preview/kthesis` to bootstrap a new
43+
project via the Typst CLI.
44+
45+
## Usage
46+
47+
The main entrypoint is the function `kth-thesis`, which should be invoked with
48+
a `show` rule at the beginning of the document:
49+
50+
```typ
51+
#show: kth-thesis.with(primary-lang: "en")
52+
```
53+
54+
Additional configuration options are passed as needed. After this rule has been
55+
declared, you can write your thesis's content as normal. Level 1 headings (`=`)
56+
mark Chapters, Level 2 headings (`==`) delimitate Sections, Level 3 headings
57+
(`===`) indicate Subsections, and so on.
58+
59+
The second and last point of contact with the template is the function
60+
`setup-appendices`, which you may (if needed) opt to invoke in a `show` rule to
61+
mark the subsequent sections as appendices and switch the numbering to letters:
62+
63+
```typ
64+
#show: setup-appendices
65+
```
66+
67+
## Configuration
68+
69+
There are a number of options that can be passed to the `kth-thesis` function to
70+
customize how the final document looks. All of them are optional since they come
71+
with default values, but in most cases you'll gradually end up having to set
72+
all of them to get the behavior you want. Here's a description of what is
73+
available:
74+
75+
- `primary-lang`: Primary document language; either `en` or `sv`
76+
- `localized-info`: Language-specific information, including title, subtitle,
77+
abstract, and keywords
78+
- `authors`: Information about who is conducting the degree project
79+
- `supervisors`: Information about who is supervising the degree project
80+
- `examiner`: Information about who is evaluating the degree project
81+
- `course`: Degree project course of which this thesis is part
82+
- `degree`: Degree within the scope of which this project is being conducted
83+
- `national-subject-categories`: One or more mandatory classification codes,
84+
from [SCB's list](https://www.scb.se/contentassets/10054f2ef27c437884e8cde0d38b9cc4/standard-for-svensk-indelning--av-forskningsamnen-2011-uppdaterad-aug-2016.pdf)
85+
- `school`: KTH institution hosting the project
86+
- `trita-number`: TRITA number assigned by the school upon project completion
87+
- `host-company`: Company hosting the degree project, if any
88+
- `host-org`: Organization hosting the degree project, if any
89+
- `opponents`: Names of assigned opponents, if known
90+
- `presentation`: Final presentation details, if known
91+
- `cover-image`: Image to include on the front cover, if any
92+
- `acknowledgements`: Body of acknowledgements section
93+
- `extra-preambles`: Additional, arbitrary front-matter sections, if needed
94+
- `doc-date`: Document authoring/submission date
95+
- `doc-city`: Document city, for acknowledgments signature
96+
- `doc-extra-keywords`: Additional keywords for document metadata (but not text)
97+
- `with-for-diva`: Whether to include meta "For DiVA" section after back cover
98+
- `style`: Miscellaneous settings affecting the document's appearance
99+
100+
Exact syntax and semantics for each option are shown in the starter `thesis.typ`
101+
main file provided by this template.
102+
103+
**Note:** if `with-for-diva` is enabled, abstracts must use only very simple
104+
Typst constructs since content must be converted to HTML (which is a very lossy
105+
and naive process).
106+
107+
## Future Work
108+
109+
Feature requests (via issues) and patch submissions (via PRs) are very welcome.
110+
111+
Among others, in the future it might be nice to support:
112+
113+
- G5 size paper (traditional for theses in Sweden), instead of just A4;
114+
- Alternative, shorter author names for acknowledgements signature;
115+
- Multiple degrees, including the "Same"/"Both" mechanism for similar or
116+
distinct subject areas, respectively; and
117+
- Copyleft option, instead of just copyright;
118+
119+
## Conformance
120+
121+
This template is unofficial and has not been verified to fully conform to KTH's
122+
requirements, therefore you should use it at your own risk. However, available
123+
information appears to imply that the covers are the only standardized part of
124+
the degree project report, with students having freedom to decide on all other
125+
formatting, styling, and layout aspects (if accepted by the Examiner).
126+
127+
Covers (June 2024 version) have been replicated as best as possible in Typst
128+
from the provided DOTX templates, but future bids at refining fidelity may be
129+
attempted in the future, especially if and when LaTeX versions are published.
130+
131+
The covers use Arial, which is a proprietary font and may be difficult to get
132+
access to. This template will use Arial if it is available on the system at
133+
compile-time and `style.use-arial` is manually enabled (opt-in); otherwise, it
134+
will be replaced by an open, metric-compatible substitute: Liberation Sans.
135+
136+
## Licensing
137+
138+
This project and all materials in this repository are made available under the
139+
MIT License, except for the contents of the `/template` directory (i.e., the
140+
files given for the thesis authors to edit), which are instead licensed under
141+
MIT No Attribution.
142+
143+
SPDX-License-Identifier: MIT AND MIT-0

packages/preview/kthesis/0.1.7/assets/KTH_logo_RGB_bla.svg

Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
pkgs ? (import <nixpkgs> { }),
3+
unstable ? (import <unstable> { }),
4+
}:
5+
pkgs.mkShellNoCC {
6+
buildInputs = with pkgs; [
7+
unstable.typst
8+
unstable.typstyle
9+
poppler-utils # for pdfinfo, to see metadata
10+
];
11+
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#import "./utils.typ": sans-serif, t
2+
3+
#let front-cover(
4+
title: "Example Title in Primary Language",
5+
subtitle: "Example Subtitle in Primary Language",
6+
authors: ("Peter Grey", "Joan Yellow"),
7+
subject-area: "Technology",
8+
cycle: 2,
9+
credits: 15,
10+
cover-image: none,
11+
style,
12+
) = page(
13+
margin: (top: 12.5mm, rest: 25mm),
14+
{
15+
set align(center)
16+
set text(size: 12pt, font: sans-serif(style))
17+
18+
image("../assets/KTH_logo_RGB_bla.svg", width: 37.45mm)
19+
20+
[
21+
\
22+
23+
\
24+
25+
#t("degree-project-in") #subject-area \
26+
27+
#set text(size: 10pt)
28+
#t("cycle-" + str(cycle)), #credits #t("credits") \
29+
30+
\
31+
32+
#text(size: 26pt, strong(title)) \
33+
\
34+
#if subtitle != none [
35+
#text(size: 16pt, subtitle)
36+
\
37+
]
38+
39+
\
40+
]
41+
42+
for author in authors {
43+
strong(upper(author))
44+
linebreak()
45+
}
46+
47+
if cover-image != none {
48+
// from official cover template: 120 twips after author + 680 twips before
49+
// image = 800 twips = 40pt of vertical space
50+
v(40pt)
51+
52+
cover-image
53+
}
54+
},
55+
)
56+
57+
#let back-cover(
58+
trita-series: "EECS-EX",
59+
trita-number: "2026:0000",
60+
year: 2026,
61+
style,
62+
) = page(
63+
margin: (top: 65mm, bottom: 30mm, left: 74pt, right: 35mm),
64+
{
65+
set text(size: 12pt, font: sans-serif(style))
66+
67+
v(1fr)
68+
69+
set text(size: 10pt)
70+
show link: it => text(fill: rgb("#1954A6"), it) // not an official color?
71+
72+
// I don't know why they want an en-dash here...
73+
[
74+
TRITA -- #trita-series #trita-number \
75+
#set text(size: 8pt)
76+
#t("stockholm-sweden") #year \
77+
#link("https://www.kth.se", "www.kth.se")
78+
]
79+
},
80+
)

0 commit comments

Comments
 (0)