v0.3.0, add customizable fill lightness
This commit is contained in:
parent
83a32d4fa0
commit
8668ad46e8
4 changed files with 19 additions and 13 deletions
|
|
@ -17,7 +17,7 @@ typship download -n local https://imsc.uni-graz.at/git/gjankowiak/typst-exam/
|
||||||
```bash
|
```bash
|
||||||
mkdir -p ~/.local/share/typst/packages/local/exam
|
mkdir -p ~/.local/share/typst/packages/local/exam
|
||||||
cd ~/.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)
|
## Quickstart (CLI)
|
||||||
|
|
@ -26,7 +26,7 @@ This will create an `exam` directory in the current directory,
|
||||||
containing the example below.
|
containing the example below.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
typst init @local/exam:0.2.0 exam
|
typst init @local/exam:0.3.0 exam
|
||||||
```
|
```
|
||||||
|
|
||||||
Tested typst version: `0.14.0`.
|
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):
|
Writing an exam is now easy (see [API](#api) for all options):
|
||||||
|
|
||||||
```typ
|
```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(
|
#show: exam.with(
|
||||||
title: "Exam",
|
title: "Exam",
|
||||||
|
|
|
||||||
15
src/lib.typ
15
src/lib.typ
|
|
@ -2,8 +2,6 @@
|
||||||
* Customisation
|
* Customisation
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#let lightgray = rgb("#eeeeee")
|
|
||||||
|
|
||||||
// Default font (embedded in Typst)
|
// Default font (embedded in Typst)
|
||||||
#let font-text = "libertinus serif"
|
#let font-text = "libertinus serif"
|
||||||
|
|
||||||
|
|
@ -117,7 +115,7 @@
|
||||||
}
|
}
|
||||||
let exercise_label = exercise_counter.display(exercise-numbering)
|
let exercise_label = exercise_counter.display(exercise-numbering)
|
||||||
exercise_registry.update(entries => entries + ((exercise_label, title, points),))
|
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(
|
table(
|
||||||
columns: (auto, 1fr, auto),
|
columns: (auto, 1fr, auto),
|
||||||
align: (left, center, right),
|
align: (left, center, right),
|
||||||
|
|
@ -151,6 +149,8 @@
|
||||||
|
|
||||||
exercise-numbering: "1",
|
exercise-numbering: "1",
|
||||||
|
|
||||||
|
fill-luma: 200,
|
||||||
|
|
||||||
body
|
body
|
||||||
) = {
|
) = {
|
||||||
|
|
||||||
|
|
@ -163,6 +163,7 @@ set page(paper: paper-size)
|
||||||
set text(size: font-size, lang: language, hyphenate: true)
|
set text(size: font-size, lang: language, hyphenate: true)
|
||||||
|
|
||||||
state("exercise-numbering").update(exercise-numbering)
|
state("exercise-numbering").update(exercise-numbering)
|
||||||
|
state("fill-luma").update(fill-luma)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Localization
|
* Localization
|
||||||
|
|
@ -224,7 +225,7 @@ let exercise_overview_table() = context {
|
||||||
columns.push(1fr)
|
columns.push(1fr)
|
||||||
[== #get_L("points_obtained")]
|
[== #get_L("points_obtained")]
|
||||||
set text(size: 14pt)
|
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(
|
table(
|
||||||
columns: columns,
|
columns: columns,
|
||||||
stroke: none,
|
stroke: none,
|
||||||
|
|
@ -287,8 +288,9 @@ v(1fr)
|
||||||
|
|
||||||
v(0.5cm)
|
v(0.5cm)
|
||||||
|
|
||||||
block(radius: 0.2cm, fill: lightgray, inset: 3pt, clip: true, table(
|
context{
|
||||||
fill: lightgray,
|
block(radius: 0.2cm, fill: luma(state("fill-luma").get()), inset: 3pt, clip: true, table(
|
||||||
|
fill: luma(state("fill-luma").get()),
|
||||||
stroke: none,
|
stroke: none,
|
||||||
columns: (auto, 1fr),
|
columns: (auto, 1fr),
|
||||||
gutter: 3pt,
|
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))
|
([#get_L("group")], rect(fill: white, width: 100%, radius: 0.2cm))
|
||||||
}
|
}
|
||||||
))
|
))
|
||||||
|
}
|
||||||
|
|
||||||
v(0.5cm)
|
v(0.5cm)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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
|
// General configuration
|
||||||
#show: exam.with(
|
#show: exam.with(
|
||||||
|
|
@ -36,6 +36,9 @@
|
||||||
|
|
||||||
// custom numbering of exercises
|
// custom numbering of exercises
|
||||||
// exercise-numbering: "1",
|
// exercise-numbering: "1",
|
||||||
|
|
||||||
|
// custom filling lightness for headings
|
||||||
|
// fill-luma: 150,
|
||||||
)
|
)
|
||||||
|
|
||||||
// First exercise
|
// First exercise
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "exam"
|
name = "exam"
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
entrypoint = "src/lib.typ"
|
entrypoint = "src/lib.typ"
|
||||||
authors = ["Gaspard Jankowiak"]
|
authors = ["Gaspard Jankowiak"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue