Last active
April 22, 2024 02:09
-
-
Save mkpoli/da80878e775c62b05eff0cc916d730e5 to your computer and use it in GitHub Desktop.
Linguistics example sentence in Typst
This file contains hidden or 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
| #let examples = counter("example") | |
| #let std-numbering = numbering | |
| #let named_examples = state("named-examples", (:)) | |
| #let ex(text, tran, name: none, numbering: "1)", asterisk: false) = { | |
| examples.step() | |
| context { | |
| let current_numbering = examples.get() | |
| if name != none { | |
| named_examples.update(x => { | |
| if name in x { | |
| panic("Duplicate example name: " + name) | |
| } | |
| x.insert(name, current_numbering) | |
| return x | |
| }) | |
| } | |
| grid( | |
| columns: (auto, 1fr), | |
| rows: (auto, auto), | |
| column-gutter: 1em, | |
| row-gutter: 1em, | |
| grid.cell( | |
| rowspan: 2, | |
| std-numbering(numbering, ..examples.get()) | |
| ), | |
| { | |
| if asterisk { "*" } | |
| text | |
| }, | |
| tran | |
| ) | |
| } | |
| } | |
| #let refex(name, numbering: "1") = context { | |
| "Example " | |
| std-numbering(numbering, ..named_examples.final().at(name)) | |
| } |
This file contains hidden or 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
| #import "example.typ": ex | |
| #ex( | |
| name: "hello", | |
| [こんにちは], | |
| [Hello] | |
| ) | |
| #refex("hello") | |
| #ex( | |
| [ありがとう], | |
| [Thanks] | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment