Skip to content

Instantly share code, notes, and snippets.

@zr-tex8r
Created April 22, 2024 13:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zr-tex8r/f539816a336e97a846878f08343ee02e to your computer and use it in GitHub Desktop.
Save zr-tex8r/f539816a336e97a846878f08343ee02e to your computer and use it in GitHub Desktop.
Linguistics example sentence in Typst🙃
#let use-examples(body) = {
show figure.where(kind: "example"): it => {
assert(it.body.func() == metadata)
// here implicit context is given by show rule
let number = numbering(it.numbering, ..it.counter.get())
grid(
columns: (auto, 1fr),
rows: (auto, auto),
column-gutter: 1em,
row-gutter: 1em,
grid.cell(
rowspan: 2,
number,
),
it.body.value.text,
it.body.value.tran,
)
}
body
}
#let ex(text, tran, numbering: "1)", asterisk: false) = {
figure(
kind: "example",
supplement: "Example",
numbering: numbering,
outlined: false,
metadata(( // tentatively placed as metadata
text: {
if asterisk { "*" }
text
},
tran: tran,
))
)
}
#import "examplezr.typ": ex, use-examples
#show: use-examples
#ex(
[こんにちは],
[Hello]
) <hello>
@hello
#ex(
[ありがとう],
[Thanks]
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment