diff --git a/README.md b/README.md index 1a121e3..3b3bdf7 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,21 @@ -# Y-Sec Typst Template - Midterm/Exam +# Y-Sec Typst Templates -Check out [demo.typ](demo.typ) for details. +## Installation + +### Typst +Avec cargo: + +``` +cargo install typst-cli +``` + +### Y-Sec Templates + +``` +git clone ~/.local/share/typst/packages/y-sec +``` + +## Templates: + + - [Test écrit](exam) ([exemple](exam/demo.typ), [pdf](exam/demo.pdf)) + - [Laboratoire](lab) diff --git a/exam/demo.pdf b/exam/demo.pdf new file mode 100644 index 0000000..604c594 Binary files /dev/null and b/exam/demo.pdf differ diff --git a/demo.typ b/exam/demo.typ similarity index 100% rename from demo.typ rename to exam/demo.typ diff --git a/lib.typ b/exam/lib.typ similarity index 100% rename from lib.typ rename to exam/lib.typ diff --git a/typst.toml b/exam/typst.toml similarity index 100% rename from typst.toml rename to exam/typst.toml diff --git a/lab/demo.typ b/lab/demo.typ new file mode 100644 index 0000000..4a24724 --- /dev/null +++ b/lab/demo.typ @@ -0,0 +1,26 @@ +#import "lab.typ" : laboratoire, question, operation +#show: doc => laboratoire( + title: "Some random lab", + course: "XYZ", + doc +) + += Section + +#operation[Commencez ici] + +bla bla + +== Sous-section + +bli bli + +#operation[ Une manipulation à effectuer ] + +#question[ Quelle est la réponse ? ][asd] + += Autre sous-section + +blu blu + +#question[xxxx][yyyyyy] diff --git a/lab/lib.typ b/lab/lib.typ new file mode 100644 index 0000000..39ab005 --- /dev/null +++ b/lab/lib.typ @@ -0,0 +1,77 @@ + +#show heading: h => { + let fresh = counter(heading).get(); + counter("manipulation").update(fresh) + counter("question").update(fresh) + h + } + +#let context_step(key) = context { + let lvl = query(selector(heading).before(here())).at(-1).level+1; + counter(key).step(level: lvl) +} + +#let laboratoire(course: "Course Name", title: "Course title", doc) = { + set page( + header: [#course - Labo X - #title], + footer: [], + numbering: "1 / 1" + ); + doc +} + +#set heading(numbering: "1.1") + +#let pretty_block(color, title, x) = { + + let edge = color; + + block(radius: (top: 3pt), + inset: 4pt, + stroke: 1pt + edge, + fill: color.lighten(50%), + width: 100%, + below: 0pt, + text(weight: "bold", title)) + + block(radius: (bottom: 3pt), + inset: 7pt, + stroke: 1pt + edge, + fill: color.lighten(80%), + width: 100%, + x) + +} + +#let operation(x) = { + context_step("manipulation") + pretty_block(rgb("#9f82ff"), "Manipulation " + context counter("manipulation").display(), x) +} +#let question(q,a) = { + context_step("question") + pretty_block(green, "Question " + context counter("question").display("1.1"), q) + pretty_block(red, "Réponse " + context counter("question").display("1.1"), a) + +} + +#show: laboratoire + += Section + +#operation[Commencez ici] + +bla bla + +== Sous-section + +bli bli + +#operation[ Une manipulation à effectuer ] + +#question[ Quelle est la réponse ? ][asd] + += Autre sous-section + +blu blu + +#question[xxxx][yyyyyy] \ No newline at end of file diff --git a/lab/typst.toml b/lab/typst.toml new file mode 100644 index 0000000..3b5a0c2 --- /dev/null +++ b/lab/typst.toml @@ -0,0 +1,7 @@ +[package] +name = "lab" +version = "0.1.0" +entrypoint = "lib.typ" +authors = ["Maxime Augier "] +license = "MIT" +description = "Enoncé de laboratoire"