Skip to content

Commit dbbc3c9

Browse files
authored
hand-in:1.1.0 (#3343)
1 parent 7e32048 commit dbbc3c9

File tree

6 files changed

+195
-0
lines changed

6 files changed

+195
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
MIT No Attribution
2+
3+
Copyright 2025 mkorje
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this
6+
software and associated documentation files (the "Software"), to deal in the Software
7+
without restriction, including without limitation the rights to use, copy, modify,
8+
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9+
permit persons to whom the Software is furnished to do so.
10+
11+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13+
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# hand-in
2+
3+
A Typst template for clean and minimalist assignments.
4+
5+
## Usage
6+
7+
You can use this template in the [official web app](https://typst.app/) by clicking "Start from template" on the dashboard and searching for `hand-in`.
8+
9+
Alternatively, you can use the CLI to initialise a new project using this template with the command
10+
11+
```sh
12+
typst init @preview/hand-in
13+
```
14+
15+
This will create a new directory containing the file `main.typ` with a sample call to the `assignment` function in a show rule.
16+
17+
You can also use this template by copying the following to the top of a `.typ` file:
18+
19+
```typ
20+
#import "@preview/hand-in:1.1.0": assignment
21+
22+
// Configure the text font and language, for example, here.
23+
24+
// Configure the template by modifying the below.
25+
#show: assignment.with(
26+
title: "Assignment 1",
27+
student: (
28+
name: "Typst Guy",
29+
id: 1550003495,
30+
),
31+
subject: (
32+
name: "Writing with Typst",
33+
code: "TYP101",
34+
),
35+
)
36+
37+
// Start writing here!
38+
```
39+
40+
## Configuration
41+
42+
This template provides the function `assignment` which takes the following arguments:
43+
44+
| Argument | Type | Description |
45+
| --------- | ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
46+
| `title` | [str] | The assignment's title. This argument is required. |
47+
| `student` | [dictionary] | The student authoring the assignment. Two keys are expected, `name` with a value of type string and `id` with a value of any type that can be converted to a string. This argument is required. |
48+
| `subject` | [dictionary] | The subject the assignment is for. Two keys are expected, `name` and `code`, both of whose values are strings. This argument is required. |
49+
| `date` | [none] [auto] [datetime] | The assignment's creation date. This argument is optional. The default is `datetime.today()` |
50+
| `body` | [content] | The assignment's content. |
51+
52+
[auto]: https://typst.app/docs/reference/foundations/auto/
53+
[content]: https://typst.app/docs/reference/foundations/content/
54+
[datetime]: https://typst.app/docs/reference/foundations/datetime/
55+
[dictionary]: https://typst.app/docs/reference/foundations/dictionary/
56+
[none]: https://typst.app/docs/reference/foundations/none/
57+
[str]: https://typst.app/docs/reference/foundations/str/
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/// Function to apply the assignment template to a document.
2+
/// -> content
3+
#let assignment(
4+
/// The assignment's title. This argument is required.
5+
/// -> str
6+
title: "",
7+
/// The student authoring the assignment. Two keys are expected, `name` with
8+
/// a value of type string and `id` with a value of any type that can be
9+
/// converted to a string. This argument is required.
10+
/// -> dictionary
11+
student: (:),
12+
/// The subject the assignment is for. Two keys are expected, `name` and
13+
/// `code`, both of whose values are strings. This argument is required.
14+
/// -> dictionary
15+
subject: (:),
16+
/// The assignment's creation date. This argument is optional. The default is
17+
/// `datetime.today()`.
18+
/// -> none | auto | datetime
19+
date: datetime.today(),
20+
/// The assignment's content.
21+
/// -> content
22+
body,
23+
) = {
24+
set document(
25+
title: title,
26+
author: student.name,
27+
description: subject.code + ": " + subject.name,
28+
date: date,
29+
)
30+
31+
set text(size: 10pt)
32+
33+
set page(
34+
paper: "a4",
35+
margin: (
36+
top: 118pt,
37+
bottom: 96pt,
38+
x: 128pt,
39+
),
40+
header-ascent: 14pt,
41+
header: {
42+
set text(size: 8pt)
43+
grid(
44+
columns: (auto, 1fr, auto),
45+
rows: (auto, auto),
46+
align: (left, center, right),
47+
gutter: 6pt,
48+
str(student.id), subject.code, date.display(),
49+
student.name, subject.name, title,
50+
)
51+
},
52+
footer-descent: 12pt,
53+
footer: context {
54+
set align(center)
55+
set text(size: 8pt)
56+
counter(page).display("1")
57+
},
58+
)
59+
60+
show heading.where(level: 1): it => {
61+
pagebreak(weak: true)
62+
set text(size: 10pt, weight: "bold")
63+
it.body + [.]
64+
}
65+
show heading.where(level: 2): it => {
66+
set text(size: 10pt, weight: "bold")
67+
it.body + [.]
68+
}
69+
70+
set enum(indent: 5pt, numbering: "(aiA)")
71+
set list(indent: 5pt)
72+
73+
show quote: set align(center)
74+
75+
show math.equation: set block(breakable: true)
76+
77+
set par(leading: 5pt, justify: true)
78+
79+
body
80+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#import "@preview/hand-in:1.1.0": assignment
2+
3+
#set text(font: "TeX Gyre Pagella", lang: "en", region: "au")
4+
#show math.equation: set text(font: "New Computer Modern Math")
5+
6+
#show: assignment.with(
7+
title: "Assignment 1",
8+
student: (
9+
name: "Typst Guy",
10+
id: 1550003495,
11+
),
12+
subject: (
13+
name: "Writing with Typst",
14+
code: "TYP101",
15+
),
16+
)
17+
18+
= Question 1
19+
Which of the following are block equations in Typst?
20+
+ ```typ $ $```
21+
+ ```typ $ /* */ $```
22+
+ ```typ $//
23+
$```
24+
25+
== Answer
26+
I thought this was an introductory Typst course!
70.1 KB
Loading
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[package]
2+
name = "hand-in"
3+
version = "1.1.0"
4+
entrypoint = "lib.typ"
5+
authors = ["mkorje <@mkorje>"]
6+
license = "MIT-0"
7+
description = "Clean and minimalist assignment."
8+
repository = "https://github.com/mkorje/typst-hand-in"
9+
keywords = ["assignment", "homework", "problem set"]
10+
categories = ["report"]
11+
compiler = "0.13.1"
12+
13+
[template]
14+
path = "template"
15+
entrypoint = "main.typ"
16+
thumbnail = "thumbnail.png"

0 commit comments

Comments
 (0)