Add reference capability
This adds a new argument, `label`, and makes use of the referencing mechanism of Typst.
This commit is contained in:
parent
3882f4e791
commit
705dc665fc
@ -179,6 +179,20 @@ standard Typst counter functions to control gloss numbering:
|
|||||||
translation: [There always is in us a will for a great happiness.],
|
translation: [There always is in us a will for a great happiness.],
|
||||||
)", addl-bindings: (gloss-count: gloss-count))
|
)", addl-bindings: (gloss-count: gloss-count))
|
||||||
|
|
||||||
|
References to individual examples can be achieved using the `label` argument and the referencing mechanism of Typst:
|
||||||
|
|
||||||
|
#codeblock(
|
||||||
|
"See @sorcerers:
|
||||||
|
|
||||||
|
#numbered-gloss(
|
||||||
|
header: [Middle Welsh; modified from _Grammatical number in Welsh_ (1999) by Silva Nurmio (§~2.1.1)],
|
||||||
|
source: ([ac], [ny], [allvs], [y], [dewinyon], [atteb], [idav]),
|
||||||
|
morphemes: ([and], [#neg], [be_able.#smallcaps[pret].3#sg], [#smallcaps[def]], [sorcerer.#pl], [answer.#smallcaps[inf]], [to.3#sg.#smallcaps[m]]),
|
||||||
|
translation: [and the sorcerers could not answer him],
|
||||||
|
label: \"sorcerers\",
|
||||||
|
)
|
||||||
|
|
||||||
|
As we have seen in @sorcerers, […].", addl-bindings: (neg: neg, sg: sg, pl: pl))
|
||||||
|
|
||||||
== Styling lines of a gloss
|
== Styling lines of a gloss
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#import "abbreviations.typ"
|
#import "abbreviations.typ"
|
||||||
|
|
||||||
#let gloss-count = counter("gloss_count")
|
#let gloss-count = counter("gloss_count")
|
||||||
|
#let cmdlabel = label // a workround so we can use `label` as a variable name
|
||||||
|
|
||||||
#let build_gloss(item-spacing, formatters, gloss_line_lists) = {
|
#let build_gloss(item-spacing, formatters, gloss_line_lists) = {
|
||||||
assert(gloss_line_lists.len() > 0, message: "Gloss line lists cannot be empty")
|
assert(gloss_line_lists.len() > 0, message: "Gloss line lists cannot be empty")
|
||||||
@ -47,6 +48,7 @@
|
|||||||
additional-lines: (), //List of list of content
|
additional-lines: (), //List of list of content
|
||||||
translation: none,
|
translation: none,
|
||||||
translation-style: none,
|
translation-style: none,
|
||||||
|
label: none,
|
||||||
|
|
||||||
item-spacing: 1em,
|
item-spacing: 1em,
|
||||||
gloss-padding: 2.0em, //TODO document these
|
gloss-padding: 2.0em, //TODO document these
|
||||||
@ -121,13 +123,18 @@
|
|||||||
|
|
||||||
style(styles => {
|
style(styles => {
|
||||||
block(breakable: breakable)[
|
block(breakable: breakable)[
|
||||||
#stack(
|
#figure(
|
||||||
|
kind: "lingexample",
|
||||||
|
supplement: [Example],
|
||||||
|
numbering: it => [#gloss-count.display()],
|
||||||
|
stack(
|
||||||
dir: ltr, //TODO this needs to be more flexible
|
dir: ltr, //TODO this needs to be more flexible
|
||||||
left_padding,
|
left_padding,
|
||||||
[#gloss_number],
|
[#gloss_number],
|
||||||
gloss-padding - left_padding - measure([#gloss_number],styles).width,
|
gloss-padding - left_padding - measure([#gloss_number],styles).width,
|
||||||
[#gloss_items]
|
align(left)[#gloss_items],
|
||||||
)
|
),
|
||||||
|
) #if label != none {cmdlabel(label)}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user