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
16 changes: 16 additions & 0 deletions packages/preview/hand-in/1.1.0/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
MIT No Attribution

Copyright 2025 mkorje

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.
57 changes: 57 additions & 0 deletions packages/preview/hand-in/1.1.0/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# hand-in

A Typst template for clean and minimalist assignments.

## Usage

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`.

Alternatively, you can use the CLI to initialise a new project using this template with the command

```sh
typst init @preview/hand-in
```

This will create a new directory containing the file `main.typ` with a sample call to the `assignment` function in a show rule.

You can also use this template by copying the following to the top of a `.typ` file:

```typ
#import "@preview/hand-in:1.1.0": assignment
// Configure the text font and language, for example, here.
// Configure the template by modifying the below.
#show: assignment.with(
title: "Assignment 1",
student: (
name: "Typst Guy",
id: 1550003495,
),
subject: (
name: "Writing with Typst",
code: "TYP101",
),
)
// Start writing here!
```

## Configuration

This template provides the function `assignment` which takes the following arguments:

| Argument | Type | Description |
| --------- | ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `title` | [str] | The assignment's title. This argument is required. |
| `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. |
| `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. |
| `date` | [none] [auto] [datetime] | The assignment's creation date. This argument is optional. The default is `datetime.today()` |
| `body` | [content] | The assignment's content. |

[auto]: https://typst.app/docs/reference/foundations/auto/
[content]: https://typst.app/docs/reference/foundations/content/
[datetime]: https://typst.app/docs/reference/foundations/datetime/
[dictionary]: https://typst.app/docs/reference/foundations/dictionary/
[none]: https://typst.app/docs/reference/foundations/none/
[str]: https://typst.app/docs/reference/foundations/str/
80 changes: 80 additions & 0 deletions packages/preview/hand-in/1.1.0/lib.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/// Function to apply the assignment template to a document.
/// -> content
#let assignment(
/// The assignment's title. This argument is required.
/// -> str
title: "",
/// 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.
/// -> dictionary
student: (:),
/// The subject the assignment is for. Two keys are expected, `name` and
/// `code`, both of whose values are strings. This argument is required.
/// -> dictionary
subject: (:),
/// The assignment's creation date. This argument is optional. The default is
/// `datetime.today()`.
/// -> none | auto | datetime
date: datetime.today(),
/// The assignment's content.
/// -> content
body,
) = {
set document(
title: title,
author: student.name,
description: subject.code + ": " + subject.name,
date: date,
)

set text(size: 10pt)

set page(
paper: "a4",
margin: (
top: 118pt,
bottom: 96pt,
x: 128pt,
),
header-ascent: 14pt,
header: {
set text(size: 8pt)
grid(
columns: (auto, 1fr, auto),
rows: (auto, auto),
align: (left, center, right),
gutter: 6pt,
str(student.id), subject.code, date.display(),
student.name, subject.name, title,
)
},
footer-descent: 12pt,
footer: context {
set align(center)
set text(size: 8pt)
counter(page).display("1")
},
)

show heading.where(level: 1): it => {
pagebreak(weak: true)
set text(size: 10pt, weight: "bold")
it.body + [.]
}
show heading.where(level: 2): it => {
set text(size: 10pt, weight: "bold")
it.body + [.]
}

set enum(indent: 5pt, numbering: "(aiA)")
set list(indent: 5pt)

show quote: set align(center)

show math.equation: set block(breakable: true)

set par(leading: 5pt, justify: true)

body
}
26 changes: 26 additions & 0 deletions packages/preview/hand-in/1.1.0/template/main.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#import "@preview/hand-in:1.1.0": assignment

#set text(font: "TeX Gyre Pagella", lang: "en", region: "au")
#show math.equation: set text(font: "New Computer Modern Math")

#show: assignment.with(
title: "Assignment 1",
student: (
name: "Typst Guy",
id: 1550003495,
),
subject: (
name: "Writing with Typst",
code: "TYP101",
),
)

= Question 1
Which of the following are block equations in Typst?
+ ```typ $ $```
+ ```typ $ /* */ $```
+ ```typ $//
$```

== Answer
I thought this was an introductory Typst course!
Binary file added packages/preview/hand-in/1.1.0/thumbnail.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions packages/preview/hand-in/1.1.0/typst.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "hand-in"
version = "1.1.0"
entrypoint = "lib.typ"
authors = ["mkorje <@mkorje>"]
license = "MIT-0"
description = "Clean and minimalist assignment."
repository = "https://github.com/mkorje/typst-hand-in"
keywords = ["assignment", "homework", "problem set"]
categories = ["report"]
compiler = "0.13.1"

[template]
path = "template"
entrypoint = "main.typ"
thumbnail = "thumbnail.png"