generated from SillyFreak/typst-package-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aad626f
commit baf9c97
Showing
4 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#let _grid = grid | ||
|
||
/// An answer filled in a gap in a text. If the document is not in solution mode, the answer is | ||
/// hidden but the height of the element is preserved. | ||
/// | ||
/// Example: | ||
/// | ||
/// #task-example(lines: "2-", ```typ | ||
/// #import task-kinds.gap: gap | ||
/// #set par(leading: 1em) | ||
/// This is a #gap(width: 2cm)[difficult] question \ | ||
/// and it has #gap(width: 1.2cm, stroke: "box")[two] lines. | ||
/// ```) | ||
/// | ||
/// - answer (content): the answer to (maybe) display | ||
/// - width (auto, relative): the width of the region where an answer can be written | ||
/// - stroke (none, string, stroke): the stroke with which to mark the answer area. The special | ||
/// values `"underline"` or `"box"` may be given to draw one or four border lines with a default | ||
/// stroke. | ||
/// -> content | ||
#let gap(answer, width: auto, stroke: "underline") = context { | ||
import "../solution.typ" | ||
|
||
let stroke = stroke | ||
assert( | ||
type(stroke) != str or stroke in ("underline", "box"), | ||
message: "for string values, only \"underline\" or \"box\" are allowed", | ||
) | ||
if stroke == "underline" { | ||
stroke = (bottom: 0.5pt) | ||
} else if stroke == "box" { | ||
stroke = 0.5pt | ||
} | ||
|
||
let answer = answer | ||
if (not solution.get()) { | ||
answer = hide(answer) | ||
} | ||
|
||
box(width: width, stroke: stroke, outset: (y: 0.4em), align(center, answer)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
#import "choice.typ" | ||
#import "free-form.typ" | ||
#import "gap.typ" |