mirror of
https://github.com/kristoferssolo/LU-DF-Typst-Template.git
synced 2025-10-21 18:50:33 +00:00
add attachments
This commit is contained in:
parent
4ada09b6b2
commit
ce96deba3e
31
main.typ
31
main.typ
@ -108,8 +108,9 @@ They can span multiple lines.
|
|||||||
any rate, that what I do not know I do not think I know either.
|
any rate, that what I do not know I do not think I know either.
|
||||||
]
|
]
|
||||||
|
|
||||||
== Links
|
== Links <title>
|
||||||
Here is a #link("https://typst.app")[Typst website].
|
Here is a https://typst.app and
|
||||||
|
here is a with a label -- #link("https://typst.app")[Typst website].
|
||||||
|
|
||||||
== Table
|
== Table
|
||||||
Here’s a simple table:
|
Here’s a simple table:
|
||||||
@ -132,16 +133,38 @@ Here’s a simple table:
|
|||||||
caption: [An example image with caption.],
|
caption: [An example image with caption.],
|
||||||
) <image-1>
|
) <image-1>
|
||||||
#figure(
|
#figure(
|
||||||
image("example.png", width: 60%),
|
image("example.png"),
|
||||||
caption: [An example image with caption.],
|
caption: [An example image with caption.],
|
||||||
) <image-2>
|
) <image-2>
|
||||||
|
|
||||||
|
- @image-1[]
|
||||||
|
- @image-2
|
||||||
|
- @table-1
|
||||||
|
- @table-1[tabulu]
|
||||||
|
- @title
|
||||||
|
- @code[pielikumu]
|
||||||
|
|
||||||
A reference to an image (see @image-1[] and @image-2 and @table-1)
|
A reference to an image (see @image-1[] and @image-2 and @table-1)
|
||||||
|
|
||||||
|
|
||||||
== Footnotes
|
== Footnotes
|
||||||
This is a sentence with a footnote. #footnote("This is the footnote text.")
|
This is a sentence with a footnote. #footnote("This is the footnote text.")
|
||||||
|
|
||||||
== References
|
== References
|
||||||
We can reference @typst in text.
|
// We can reference @typst in text.
|
||||||
|
|
||||||
|
|
||||||
|
#figure(
|
||||||
|
caption: "Some caption",
|
||||||
|
kind: "attachment",
|
||||||
|
supplement: "pielikums",
|
||||||
|
```rust
|
||||||
|
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||||
|
#[cfg_attr(feature = "bevy_reflect", derive(bevy_reflect::Reflect))]
|
||||||
|
#[cfg_attr(feature = "bevy", derive(Component))]
|
||||||
|
#[cfg_attr(feature = "bevy", reflect(Component))]
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
|
pub struct Walls(u8);
|
||||||
|
```,
|
||||||
|
)<code>
|
||||||
|
|
||||||
|
|||||||
59
template.typ
59
template.typ
@ -168,6 +168,8 @@
|
|||||||
|
|
||||||
// Tables & figures
|
// Tables & figures
|
||||||
set figure(numbering: dependent-numbering("1.1."))
|
set figure(numbering: dependent-numbering("1.1."))
|
||||||
|
show figure: set figure.caption(position: top, separator: " ")
|
||||||
|
show figure.caption: set align(end)
|
||||||
|
|
||||||
show figure.where(kind: image): set figure(supplement: "att")
|
show figure.where(kind: image): set figure(supplement: "att")
|
||||||
show figure.caption.where(kind: image): set align(start)
|
show figure.caption.where(kind: image): set align(start)
|
||||||
@ -178,31 +180,68 @@
|
|||||||
show heading: reset-counter(counter(figure.where(kind: image)))
|
show heading: reset-counter(counter(figure.where(kind: image)))
|
||||||
|
|
||||||
show figure.where(kind: table): set figure(supplement: "tabula")
|
show figure.where(kind: table): set figure(supplement: "tabula")
|
||||||
show figure.caption.where(kind: table): set align(end)
|
|
||||||
show figure.where(kind: table): set figure.caption(
|
|
||||||
position: top,
|
|
||||||
separator: " ",
|
|
||||||
)
|
|
||||||
show heading: reset-counter(counter(figure.where(kind: table)))
|
show heading: reset-counter(counter(figure.where(kind: table)))
|
||||||
|
|
||||||
show figure.where(kind: raw): set figure.caption(position: top)
|
show figure.where(kind: "attachment"): set figure(numbering: "1.1.")
|
||||||
|
show figure.where(kind: "attachment"): set figure.caption(separator: ". ")
|
||||||
show figure.where(kind: "attachment"): set figure.caption(position: top)
|
|
||||||
|
|
||||||
|
|
||||||
// Adapt supplement in caption independently from supplement used for references.
|
// Adapt supplement in caption independently from supplement used for references.
|
||||||
show figure: fig => {
|
show figure: fig => {
|
||||||
let prefix = fig.supplement
|
|
||||||
let numbers = numbering(fig.numbering, ..fig.counter.at(fig.location()))
|
let numbers = numbering(fig.numbering, ..fig.counter.at(fig.location()))
|
||||||
// Wrap figure captions in block to prevent the creation of paragraphs. In
|
// Wrap figure captions in block to prevent the creation of paragraphs. In
|
||||||
// particular, this means `par.first-line-indent` does not apply.
|
// particular, this means `par.first-line-indent` does not apply.
|
||||||
// See https://github.com/typst/templates/pull/73#discussion_r2112947947.
|
// See https://github.com/typst/templates/pull/73#discussion_r2112947947.
|
||||||
show figure.caption: it => block[
|
show figure.caption: it => block[
|
||||||
#emph([#numbers~#prefix#it.separator])*#it.body*
|
#emph([#numbers~#fig.supplement#it.separator])*#it.body*
|
||||||
|
]
|
||||||
|
show figure.caption.where(kind: "attachment"): it => block[
|
||||||
|
#numbers~#fig.supplement#it.separator#it.body
|
||||||
]
|
]
|
||||||
fig
|
fig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// disable default reference suppliments
|
||||||
|
set ref(supplement: it => {})
|
||||||
|
|
||||||
|
// Custom show rule for references
|
||||||
|
show ref: it => {
|
||||||
|
let el = it.element
|
||||||
|
if el == none {
|
||||||
|
return it
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
let numbers = numbering(
|
||||||
|
el.numbering,
|
||||||
|
..counter(el.func()).at(el.location()),
|
||||||
|
)
|
||||||
|
|
||||||
|
if el.func() == heading {
|
||||||
|
return link(
|
||||||
|
el.location(),
|
||||||
|
[#numbers #el.body],
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
let supplement = if type(it.supplement) == content {
|
||||||
|
if it.supplement == [] {
|
||||||
|
""
|
||||||
|
} else {
|
||||||
|
[~#it.supplement]
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
[~#it.supplement]
|
||||||
|
}
|
||||||
|
|
||||||
|
if el.func() == figure {
|
||||||
|
return link(el.location(), [#numbers#supplement])
|
||||||
|
}
|
||||||
|
it
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Code blocks
|
// Code blocks
|
||||||
show raw: set text(
|
show raw: set text(
|
||||||
font: (
|
font: (
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user