forked from pencelheimer/typst_nure_template
fix image & reference numbering
This commit is contained in:
73
template.typ
73
template.typ
@ -114,61 +114,52 @@
|
|||||||
set list(indent: 1.35cm, body-indent: 0.5cm, marker: [--])
|
set list(indent: 1.35cm, body-indent: 0.5cm, marker: [--])
|
||||||
|
|
||||||
// figures
|
// figures
|
||||||
|
show figure: it => {
|
||||||
|
v(spacing * 2, weak: true)
|
||||||
|
it
|
||||||
|
v(spacing * 2, weak: true)
|
||||||
|
}
|
||||||
|
|
||||||
set figure.caption(separator: [ -- ])
|
set figure.caption(separator: [ -- ])
|
||||||
show figure.where(kind: table): set figure.caption(position: top)
|
show figure.where(kind: table): set figure.caption(position: top)
|
||||||
show figure.caption.where(kind: table): set align(left)
|
show figure.caption.where(kind: table): set align(left)
|
||||||
|
|
||||||
let img = counter("image")
|
// figure numbering
|
||||||
let tab = counter("table")
|
show heading.where(level: 1): it => {
|
||||||
|
counter(math.equation).update(0)
|
||||||
show figure.where(kind: image): set figure(
|
counter(figure.where(kind: image)).update(0)
|
||||||
numbering: (..) => {
|
counter(figure.where(kind: table)).update(0)
|
||||||
img.step()
|
counter(figure.where(kind: raw)).update(0)
|
||||||
context str(counter(heading).get().at(0)) + "." + context img.display()
|
it
|
||||||
},
|
}
|
||||||
)
|
set math.equation(numbering: (..num) => numbering("(1.1)", counter(heading).get().at(0), num.pos().first()))
|
||||||
show figure.where(kind: table): set figure(
|
set figure(numbering: (..num) => numbering("1.1", counter(heading).get().at(0), num.pos().first()))
|
||||||
numbering: (..) => {
|
|
||||||
tab.step()
|
|
||||||
context str(counter(heading).get().at(0)) + "." + context tab.display()
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
// appearance of references to images and tables
|
// appearance of references to images and tables
|
||||||
|
set ref(
|
||||||
|
supplement: it => {
|
||||||
|
if it == none or not it.has("kind") {
|
||||||
|
it
|
||||||
|
} else if it.kind == image {
|
||||||
|
"див. рис."
|
||||||
|
} else if it.kind == table {
|
||||||
|
"див. таблицю"
|
||||||
|
} else {
|
||||||
|
it
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
show ref: it => {
|
show ref: it => {
|
||||||
let el = it.element
|
let el = it.element
|
||||||
|
|
||||||
if el == none or not el.has("kind") {
|
if el == none or not el.has("kind") {
|
||||||
return it
|
return it
|
||||||
}
|
}
|
||||||
|
if el.kind != image and el.kind != table {
|
||||||
let el_name = if el.kind == image {
|
|
||||||
"рис."
|
|
||||||
} else if el.kind == table {
|
|
||||||
"таблицю"
|
|
||||||
} else {
|
|
||||||
return it
|
return it
|
||||||
}
|
}
|
||||||
|
|
||||||
link(
|
[(#it)]
|
||||||
el.location(),
|
|
||||||
[(див. #el_name #numbering(el.numbering))],
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Maybe this will be better. Must be investigated.
|
|
||||||
//
|
|
||||||
// set math.equation(numbering: (..num) =>
|
|
||||||
// numbering("(1.1)", counter(heading).get().first(), num.pos().first())
|
|
||||||
// )
|
|
||||||
// set figure(numbering: (..num) =>
|
|
||||||
// numbering("1.1", counter(heading).get().first(), num.pos().first())
|
|
||||||
// )
|
|
||||||
|
|
||||||
show figure: it => {
|
|
||||||
v(spacing * 2, weak: true)
|
|
||||||
it
|
|
||||||
v(spacing * 2, weak: true)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// headings
|
// headings
|
||||||
@ -666,3 +657,5 @@
|
|||||||
heading(title)
|
heading(title)
|
||||||
doc
|
doc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// vim:sts=2:sw=2
|
||||||
|
Reference in New Issue
Block a user