# The `exam` package This is a simple package to typeset exams. With it, you can define exercises, and items, each with a number of points. A summary is then printed on the front page. ## Installation (Linux only) #### Using `typship` ```bash typship download -n local https://imsc.uni-graz.at/git/gjankowiak/typst-exam/ ``` #### Manually ```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.1.0.tar.gz | tar zx --xform 's/typst-exam/0.1.0/' ``` ## Usage Writing an exam is now easy (see [API](#api) for all options): ```typ #import "@local/exam:0.1.0": exam, exercise, exercise-items, mtext #show: exam.with( title: "Exam", course-title: [Abstract Binary Computation & Elegant Finite Graphs], institution: [Super University], date: "1. January 1970", course-short-title: "ABC & EFG", course-code: "π", duration-minutes: "90", ask-trainer-name: false, ask-group: true, language: "en", ) ``` ### Defining exercises and items A new exercise can be started using `#exercise("title", nb_points)`, for example: ```typ #exercise("Relations and their properties", 2) Consider the relation $R subset NN^2$, defined as follows: $ (x, y) in R #h(0.5cm) <==> #h(0.5cm) x + y #mtext[is odd]. $ Is $R$ reflexive? transitive? symmetric? antisymmetric? ``` On can also defined (sub-)items for the exercise using `#exercise-items(override_points:true, numbering:"a)", items)`, where `items` is an array of `(nb_points, statement)`. By default, the number of points the exercise is worth is recomputed as the sum of points for all items. This behaviour can be turned off by setting `override_points: false`. ```typ #exercise("Properties of functions", 3) Let $f : (0, +infinity) → (0, +infinity)$ with $f (x) = e^(-x)$. #exercise-items(( (1, [Is $f$ injective?]), (1, [Is $f$ surjective?]), (1, [Is $f$ bijective?]), )) #exercise("Logical operators", 3.14) Consider the following truthtable: #align(center, table( stroke: frame(0.5pt), columns: (auto, auto, auto), align: center, [$A$], [$B$], [$A or B$], [1], [1], [1], [1], [0], [1], [0], [1], [1], [0], [0], [1] )) #exercise-items(override-points: false, numbering: "i)", ( (1, [Is the truthtable correct?]), (1, [If not, fix it.]), )) ``` All together, this should output something like: ![screenshot](screenshot-example.png) You can also [play with it](https://typst.app/project/rrQbGYoQ3pePdfSMl0tmv4) on the Typst Playground (you might need an account). ### Utilities These are used in the example above. - `mtext(str)` to typeset text within math mode using the default text font. - `frame(stroke_width)` provides `stroke` for use in a `table`, horizontal lines only, top and bottom lines are bold. ### API ```typ #exam( title: "%KLAUSUR or EXAM%", course-title: [%COURSE_TITLE_FIRST_LINE% \ %COURSE_TITLE_SECOND_LINE%], course-short-title: "%course-short-title%", course-code: "%course-code%", date: "%DATE%", institution: smallcaps("NAWI Graz"), duration-minutes: "%DURATION%", ask-student-number: false, ask-trainer-name: false, ask-group: true, instructions: none, language: "de", // or "en" font-size: 12pt, paper-size: "a4", exercise-numbering: "1", ) ```