From 8668ad46e8c657184d678f82937dccd51d8873a4 Mon Sep 17 00:00:00 2001 From: Gaspard Jankowiak Date: Mon, 15 Dec 2025 10:52:18 +0100 Subject: [PATCH] v0.3.0, add customizable fill lightness --- README.md | 6 +++--- src/lib.typ | 15 +++++++++------ template/exam.typ | 9 ++++++--- typst.toml | 2 +- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index b140acb..53fc1ec 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ typship download -n local https://imsc.uni-graz.at/git/gjankowiak/typst-exam/ ```bash mkdir -p ~/.local/share/typst/packages/local/exam cd ~/.local/share/typst/packages/local/exam -curl https://imsc.uni-graz.at/git/gjankowiak/typst-exam/archive/v0.2.0.tar.gz | tar zx --xform 's/typst-exam/0.2.0/' +curl https://imsc.uni-graz.at/git/gjankowiak/typst-exam/archive/v0.3.0.tar.gz | tar zx --xform 's/typst-exam/0.3.0/' ``` ## Quickstart (CLI) @@ -26,7 +26,7 @@ This will create an `exam` directory in the current directory, containing the example below. ```sh -typst init @local/exam:0.2.0 exam +typst init @local/exam:0.3.0 exam ``` Tested typst version: `0.14.0`. @@ -36,7 +36,7 @@ Tested typst version: `0.14.0`. Writing an exam is now easy (see [API](#api) for all options): ```typ -#import "@local/exam:0.2.0": exam, exercise, exercise-items, mtext, horiz-only +#import "@local/exam:0.3.0": exam, exercise, exercise-items, mtext, horiz-only #show: exam.with( title: "Exam", diff --git a/src/lib.typ b/src/lib.typ index 05e5090..cfc1db8 100644 --- a/src/lib.typ +++ b/src/lib.typ @@ -2,8 +2,6 @@ * Customisation */ -#let lightgray = rgb("#eeeeee") - // Default font (embedded in Typst) #let font-text = "libertinus serif" @@ -117,7 +115,7 @@ } let exercise_label = exercise_counter.display(exercise-numbering) exercise_registry.update(entries => entries + ((exercise_label, title, points),)) - block(radius: 1cm, stroke: none, fill: lightgray, inset: 1pt, + block(radius: 1cm, stroke: none, fill: luma(state("fill-luma").get()), inset: 1pt, table( columns: (auto, 1fr, auto), align: (left, center, right), @@ -151,6 +149,8 @@ exercise-numbering: "1", + fill-luma: 200, + body ) = { @@ -163,6 +163,7 @@ set page(paper: paper-size) set text(size: font-size, lang: language, hyphenate: true) state("exercise-numbering").update(exercise-numbering) +state("fill-luma").update(fill-luma) /* * Localization @@ -224,7 +225,7 @@ let exercise_overview_table() = context { columns.push(1fr) [== #get_L("points_obtained")] set text(size: 14pt) - block(radius: 0.3cm, stroke: none, fill: lightgray, inset: (x:0pt, y:4pt), + block(radius: 0.3cm, stroke: none, fill: luma(state("fill-luma").get()), inset: (x:0pt, y:4pt), table( columns: columns, stroke: none, @@ -287,8 +288,9 @@ v(1fr) v(0.5cm) -block(radius: 0.2cm, fill: lightgray, inset: 3pt, clip: true, table( - fill: lightgray, +context{ +block(radius: 0.2cm, fill: luma(state("fill-luma").get()), inset: 3pt, clip: true, table( + fill: luma(state("fill-luma").get()), stroke: none, columns: (auto, 1fr), gutter: 3pt, @@ -305,6 +307,7 @@ block(radius: 0.2cm, fill: lightgray, inset: 3pt, clip: true, table( ([#get_L("group")], rect(fill: white, width: 100%, radius: 0.2cm)) } )) +} v(0.5cm) diff --git a/template/exam.typ b/template/exam.typ index 847a832..2a160a4 100644 --- a/template/exam.typ +++ b/template/exam.typ @@ -1,4 +1,4 @@ -#import "@local/exam:0.2.0": exam, exercise, exercise-items, mtext, horiz-only +#import "@local/exam:0.3.0": exam, exercise, exercise-items, horiz-only, mtext // General configuration #show: exam.with( @@ -36,6 +36,9 @@ // custom numbering of exercises // exercise-numbering: "1", + + // custom filling lightness for headings + // fill-luma: 150, ) // First exercise @@ -54,8 +57,8 @@ Let $f : (0, +infinity) → (0, +infinity)$ with $f (x) = e^(-x)$. // Several sub-questions #exercise-items(( - (1, [Is $f$ injective?]), // The first argument is the number - // of points the item is worth + (1, [Is $f$ injective?]), // The first argument is the number + // of points the item is worth (1, [Is $f$ surjective?]), (2, [Is $f$ bijective?]), )) diff --git a/typst.toml b/typst.toml index e3f14e5..a1731b4 100644 --- a/typst.toml +++ b/typst.toml @@ -1,6 +1,6 @@ [package] name = "exam" -version = "0.2.0" +version = "0.3.0" entrypoint = "src/lib.typ" authors = ["Gaspard Jankowiak"] license = "MIT"