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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- Added `begin-at-new-page` option for `task` and `subtask`
- Added `skip` option for `task` and `subtask`
- Added `bonus-style` option for `task`
- Added `theorem-counter-reset` option for `task` and `subtask`

## [0.4.0] - 2025-11-22

Expand Down
11 changes: 9 additions & 2 deletions examples/task-config.typ
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "@preview/sheetstorm:0.4.0": assignment, subtask, task
#import "@preview/sheetstorm:0.4.0": assignment, subtask, task, theorem

#show: assignment.with(
title: "Task Configuration Example",
Expand All @@ -10,6 +10,7 @@
// You can customize the task/subtask functions like so:
#let task = task.with(
todo-show: false,
theorem-counter-reset: true,
)
#let subtask = subtask.with(
numbering: ("a.", "i."),
Expand All @@ -33,8 +34,14 @@

#task(counter-show: false, name: "Name")[
You can disable the task number in the title.

#theorem[First theorem of the task.]
]

#task(hidden: true, counter: 7)[This task is hidden in the score box.]
#task(hidden: true, counter: 7)[
This task is hidden in the score box.

#theorem[Also the theorem counter was automatically reset.]
]

#task(skip: 1)[This would be task 8 but now it is task 9.]
14 changes: 14 additions & 0 deletions src/task.typ
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@
bonus-style: t => [#t (#context i18n.translate("Bonus"))],
/// Whether the task is hidden in the score box. -> bool
hidden: false,
/// Whether to reset the theorem counter at the start of the task. -> bool
theorem-counter-reset: false,
/// Padding above the task. -> auto | length
space-above: auto,
/// Padding below the task. -> auto | length
Expand Down Expand Up @@ -147,6 +149,10 @@
c("sheetstorm-todo").step()
}

if theorem-counter-reset {
c("sheetstorm-theorem-count").update(1)
}

let maybe-todo = context {
let curr-task = query(selector(<sheetstorm-task>).before(here()))
.last()
Expand Down Expand Up @@ -294,6 +300,8 @@
///
/// -> bool
numbering-cycle: false,
/// Whether to reset the theorem counter at the start of the subtask. -> bool
theorem-counter-reset: false,
/// The minimum indent of the subtask body.
///
/// The indent of the subtask body is the maximum of this value and the width of the marker.
Expand All @@ -316,6 +324,8 @@
/// -> content..
..body-args,
) = {
let c = std.counter

assert(body-args.named().len() == 0, message: "Unexpected named argument.")
assert(
body-args.pos().len() == 1 or body-args.pos().len() == 2,
Expand Down Expand Up @@ -348,6 +358,10 @@
})
}

if theorem-counter-reset {
c("sheetstorm-theorem-count").update(1)
}

let marker = if marker != auto { marker } else {
context {
let depth = state("sheetstorm-subtask").get().len() - 1
Expand Down
Binary file modified tests/examples/task-config/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 9 additions & 2 deletions tests/examples/task-config/test.typ
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "@local/sheetstorm:0.4.0": assignment, subtask, task
#import "@local/sheetstorm:0.4.0": assignment, subtask, task, theorem

#show: assignment.with(
title: "Task Configuration Example",
Expand All @@ -10,6 +10,7 @@
// You can customize the task/subtask functions like so:
#let task = task.with(
todo-show: false,
theorem-counter-reset: true,
)
#let subtask = subtask.with(
numbering: ("a.", "i."),
Expand All @@ -33,8 +34,14 @@

#task(counter-show: false, name: "Name")[
You can disable the task number in the title.

#theorem[First theorem of the task.]
]

#task(hidden: true, counter: 7)[This task is hidden in the score box.]
#task(hidden: true, counter: 7)[
This task is hidden in the score box.

#theorem[Also the theorem counter was automatically reset.]
]

#task(skip: 1)[This would be task 8 but now it is task 9.]
Loading