Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions packages/preview/kthesis/0.1.7/LICENSE-MIT
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2025 Rafael Oliveira

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
18 changes: 18 additions & 0 deletions packages/preview/kthesis/0.1.7/LICENSE-MIT-0
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
MIT No Attribution

Copyright (c) 2025 Rafael Oliveira

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
143 changes: 143 additions & 0 deletions packages/preview/kthesis/0.1.7/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
# KTHesis

An unofficial, slightly opinionated, extensible [Typst](https://typst.app/home/)
template for writing a Degree Project thesis for KTH Royal Institute of
Technology in Stockholm, Sweden.

Inspired by and partially adapted from Gerald Q. Maguire Jr.'s LaTeX template
and KTH's official degree project report covers as published on the
[institution's website](https://www.kth.se/en/omslag-till-ditt-exjobb-1.479838).

## Overview

This template is primarily targeted at Master's Degree theses, though it aims to
be sufficiently generic so to also be suitable for other kinds of reports. It
strives to simplify drafting and counts with the following features, among
others:

- Supports both English and Swedish as primary language, with built-in
translations for template-managed headings and sections;
- Supports additional Abstracts in other languages;
- Supports arbitrary extra preamble sections, such as a Glossary / Table of
Acronyms - i.e., integrates well with
[glossarium](https://typst.app/universe/package/glossarium) or similar;
- Does not conflict with Typst's native
[bibliography](https://typst.app/docs/reference/model/bibliography/) mechanism
even without requiring any additional configuration - "plug and play";
- Uses [hydra](https://typst.app/universe/package/hydra) to show the current
Chapter title in the page header;
- Uses [headcount](https://typst.app/universe/package/headcount) to make figure,
table, and listing numbers dependent on Chapter number;
- Includes built-in selective inclusion of indices: an index for figures,
tables, and listings is automatically added if needed and omitted if not;
- Can generate a "For DiVA" JSON-based trailing section for compatibility with
existing, school-prevalent automation scripts; and
- Provides a simple interface and tuning options.

## Getting Started

Visit the template's [homepage](https://typst.app/universe/package/kthesis/) and
click "Create project in app" to try it out in the Typst web app.

Alternatively, you can also run `typst init @preview/kthesis` to bootstrap a new
project via the Typst CLI.

## Usage

The main entrypoint is the function `kth-thesis`, which should be invoked with
a `show` rule at the beginning of the document:

```typ
#show: kth-thesis.with(primary-lang: "en")
```

Additional configuration options are passed as needed. After this rule has been
declared, you can write your thesis's content as normal. Level 1 headings (`=`)
mark Chapters, Level 2 headings (`==`) delimitate Sections, Level 3 headings
(`===`) indicate Subsections, and so on.

The second and last point of contact with the template is the function
`setup-appendices`, which you may (if needed) opt to invoke in a `show` rule to
mark the subsequent sections as appendices and switch the numbering to letters:

```typ
#show: setup-appendices
```

## Configuration

There are a number of options that can be passed to the `kth-thesis` function to
customize how the final document looks. All of them are optional since they come
with default values, but in most cases you'll gradually end up having to set
all of them to get the behavior you want. Here's a description of what is
available:

- `primary-lang`: Primary document language; either `en` or `sv`
- `localized-info`: Language-specific information, including title, subtitle,
abstract, and keywords
- `authors`: Information about who is conducting the degree project
- `supervisors`: Information about who is supervising the degree project
- `examiner`: Information about who is evaluating the degree project
- `course`: Degree project course of which this thesis is part
- `degree`: Degree within the scope of which this project is being conducted
- `national-subject-categories`: One or more mandatory classification codes,
from [SCB's list](https://www.scb.se/contentassets/10054f2ef27c437884e8cde0d38b9cc4/standard-for-svensk-indelning--av-forskningsamnen-2011-uppdaterad-aug-2016.pdf)
- `school`: KTH institution hosting the project
- `trita-number`: TRITA number assigned by the school upon project completion
- `host-company`: Company hosting the degree project, if any
- `host-org`: Organization hosting the degree project, if any
- `opponents`: Names of assigned opponents, if known
- `presentation`: Final presentation details, if known
- `cover-image`: Image to include on the front cover, if any
- `acknowledgements`: Body of acknowledgements section
- `extra-preambles`: Additional, arbitrary front-matter sections, if needed
- `doc-date`: Document authoring/submission date
- `doc-city`: Document city, for acknowledgments signature
- `doc-extra-keywords`: Additional keywords for document metadata (but not text)
- `with-for-diva`: Whether to include meta "For DiVA" section after back cover
- `style`: Miscellaneous settings affecting the document's appearance

Exact syntax and semantics for each option are shown in the starter `thesis.typ`
main file provided by this template.

**Note:** if `with-for-diva` is enabled, abstracts must use only very simple
Typst constructs since content must be converted to HTML (which is a very lossy
and naive process).

## Future Work

Feature requests (via issues) and patch submissions (via PRs) are very welcome.

Among others, in the future it might be nice to support:

- G5 size paper (traditional for theses in Sweden), instead of just A4;
- Alternative, shorter author names for acknowledgements signature;
- Multiple degrees, including the "Same"/"Both" mechanism for similar or
distinct subject areas, respectively; and
- Copyleft option, instead of just copyright;

## Conformance

This template is unofficial and has not been verified to fully conform to KTH's
requirements, therefore you should use it at your own risk. However, available
information appears to imply that the covers are the only standardized part of
the degree project report, with students having freedom to decide on all other
formatting, styling, and layout aspects (if accepted by the Examiner).

Covers (June 2024 version) have been replicated as best as possible in Typst
from the provided DOTX templates, but future bids at refining fidelity may be
attempted in the future, especially if and when LaTeX versions are published.

The covers use Arial, which is a proprietary font and may be difficult to get
access to. This template will use Arial if it is available on the system at
compile-time and `style.use-arial` is manually enabled (opt-in); otherwise, it
will be replaced by an open, metric-compatible substitute: Liberation Sans.

## Licensing

This project and all materials in this repository are made available under the
MIT License, except for the contents of the `/template` directory (i.e., the
files given for the thesis authors to edit), which are instead licensed under
MIT No Attribution.

SPDX-License-Identifier: MIT AND MIT-0
1 change: 1 addition & 0 deletions packages/preview/kthesis/0.1.7/assets/KTH_logo_RGB_bla.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions packages/preview/kthesis/0.1.7/shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
pkgs ? (import <nixpkgs> { }),
unstable ? (import <unstable> { }),
}:
pkgs.mkShellNoCC {
buildInputs = with pkgs; [
unstable.typst
unstable.typstyle
poppler-utils # for pdfinfo, to see metadata
];
}
80 changes: 80 additions & 0 deletions packages/preview/kthesis/0.1.7/src/covers.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#import "./utils.typ": sans-serif, t

#let front-cover(
title: "Example Title in Primary Language",
subtitle: "Example Subtitle in Primary Language",
authors: ("Peter Grey", "Joan Yellow"),
subject-area: "Technology",
cycle: 2,
credits: 15,
cover-image: none,
style,
) = page(
margin: (top: 12.5mm, rest: 25mm),
{
set align(center)
set text(size: 12pt, font: sans-serif(style))

image("../assets/KTH_logo_RGB_bla.svg", width: 37.45mm)

[
\

\

#t("degree-project-in") #subject-area \

#set text(size: 10pt)
#t("cycle-" + str(cycle)), #credits #t("credits") \

\

#text(size: 26pt, strong(title)) \
\
#if subtitle != none [
#text(size: 16pt, subtitle)
\
]

\
]

for author in authors {
strong(upper(author))
linebreak()
}

if cover-image != none {
// from official cover template: 120 twips after author + 680 twips before
// image = 800 twips = 40pt of vertical space
v(40pt)

cover-image
}
},
)

#let back-cover(
trita-series: "EECS-EX",
trita-number: "2026:0000",
year: 2026,
style,
) = page(
margin: (top: 65mm, bottom: 30mm, left: 74pt, right: 35mm),
{
set text(size: 12pt, font: sans-serif(style))

v(1fr)

set text(size: 10pt)
show link: it => text(fill: rgb("#1954A6"), it) // not an official color?

// I don't know why they want an en-dash here...
[
TRITA -- #trita-series #trita-number \
#set text(size: 8pt)
#t("stockholm-sweden") #year \
#link("https://www.kth.se", "www.kth.se")
]
},
)
Loading
Loading