mirror of
https://github.com/kristoferssolo/LU-DF-Typst-Template.git
synced 2025-10-21 18:50:33 +00:00
feat: add attachments
This commit is contained in:
parent
3e4719c17b
commit
a04e644822
@ -1,6 +1,6 @@
|
|||||||
#import "@preview/fletcher:0.5.8" as fletcher: diagram, edge, node
|
#import "@preview/fletcher:0.5.8" as fletcher: diagram, edge, node
|
||||||
#import fletcher.shapes: cylinder, ellipse
|
#import fletcher.shapes: cylinder, ellipse
|
||||||
#import "@preview/solo-lu-df:0.0.1": ludf
|
#import "@preview/solo-lu-df:0.0.1": *
|
||||||
#import "utils/tables.typ": function-table
|
#import "utils/tables.typ": function-table
|
||||||
#import "utils/diagrams.typ": data-store, dpd-database, dpd-edge, process
|
#import "utils/diagrams.typ": data-store, dpd-database, dpd-edge, process
|
||||||
|
|
||||||
@ -67,6 +67,23 @@
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
attachments: (
|
||||||
|
attachment(
|
||||||
|
caption: "foo",
|
||||||
|
label: <foo>,
|
||||||
|
table(
|
||||||
|
columns: (1fr, 1fr),
|
||||||
|
[foo], [bar],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
attachment(
|
||||||
|
caption: "bar",
|
||||||
|
table(
|
||||||
|
columns: (1fr, 1fr),
|
||||||
|
[foo], [bar],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
38
src/lib.typ
38
src/lib.typ
@ -1,7 +1,17 @@
|
|||||||
#import "utils.typ": make-abstract, make-documentary-page, make-title
|
#import "utils.typ": (
|
||||||
|
make-abstract, make-attachments, make-documentary-page, make-title,
|
||||||
|
)
|
||||||
|
|
||||||
#let indent = 1cm
|
#let indent = 1cm
|
||||||
|
|
||||||
|
#let attachment(caption: none, label: none, body) = {
|
||||||
|
(
|
||||||
|
content: body,
|
||||||
|
caption: caption,
|
||||||
|
label: label,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
// This function gets your whole document as its `body` and formats
|
// This function gets your whole document as its `body` and formats
|
||||||
// it as an article in the style of the IEEE.
|
// it as an article in the style of the IEEE.
|
||||||
#let ludf(
|
#let ludf(
|
||||||
@ -36,8 +46,9 @@
|
|||||||
date: datetime.today(),
|
date: datetime.today(),
|
||||||
place: none,
|
place: none,
|
||||||
logo: none,
|
logo: none,
|
||||||
outline-title: "SATURS",
|
outline-title: "Saturs",
|
||||||
attachments: none,
|
attachments: (),
|
||||||
|
attachment-title: "Pielikumi",
|
||||||
body,
|
body,
|
||||||
) = {
|
) = {
|
||||||
// Set document metadata.
|
// Set document metadata.
|
||||||
@ -134,7 +145,7 @@
|
|||||||
|
|
||||||
show figure.where(kind: table): set figure(supplement: "tabula")
|
show figure.where(kind: table): set figure(supplement: "tabula")
|
||||||
|
|
||||||
show figure.where(kind: "attachment"): set figure(numbering: "1.1.")
|
show figure.where(kind: "attachment"): set figure(numbering: "1.")
|
||||||
show figure.where(kind: "attachment"): set figure.caption(separator: ". ")
|
show figure.where(kind: "attachment"): set figure.caption(separator: ". ")
|
||||||
|
|
||||||
|
|
||||||
@ -153,6 +164,7 @@
|
|||||||
fig
|
fig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Custom show rule for references
|
// Custom show rule for references
|
||||||
show ref: it => {
|
show ref: it => {
|
||||||
let el = it.element
|
let el = it.element
|
||||||
@ -198,7 +210,11 @@
|
|||||||
let fig_num = counter(figure.where(kind: el.kind))
|
let fig_num = counter(figure.where(kind: el.kind))
|
||||||
.at(el.location())
|
.at(el.location())
|
||||||
.first()
|
.first()
|
||||||
let numbers = numbering("1.1.", chap, fig_num)
|
let numbers = if el.kind == "attachment" {
|
||||||
|
numbering("1.", fig_num)
|
||||||
|
} else {
|
||||||
|
numbering("1.1.", chap, fig_num)
|
||||||
|
}
|
||||||
|
|
||||||
let supplement = get-supplement(el.supplement)
|
let supplement = get-supplement(el.supplement)
|
||||||
|
|
||||||
@ -247,11 +263,14 @@
|
|||||||
|
|
||||||
// Table of contents.
|
// Table of contents.
|
||||||
// Uppercase 1st level headings in ToC
|
// Uppercase 1st level headings in ToC
|
||||||
show outline.entry.where(level: 1): it => {
|
show outline.entry.where(level: 1): it => { upper(it) }
|
||||||
upper(it)
|
|
||||||
}
|
|
||||||
|
|
||||||
outline(depth: 3, indent: indent, title: text(size: 14pt, outline-title))
|
outline(
|
||||||
|
depth: 3,
|
||||||
|
indent: indent,
|
||||||
|
title: text(size: 14pt, outline-title),
|
||||||
|
target: heading.where().or(figure.where(kind: "attachment")),
|
||||||
|
)
|
||||||
|
|
||||||
// Display the paper's contents.
|
// Display the paper's contents.
|
||||||
body
|
body
|
||||||
@ -259,6 +278,7 @@
|
|||||||
// Display bibliography.
|
// Display bibliography.
|
||||||
bibliography
|
bibliography
|
||||||
|
|
||||||
|
make-attachments(attachment-title, attachments)
|
||||||
|
|
||||||
make-documentary-page(
|
make-documentary-page(
|
||||||
title,
|
title,
|
||||||
|
|||||||
@ -157,3 +157,31 @@
|
|||||||
v(vspace)
|
v(vspace)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#let make-attachments(title, attachments) = {
|
||||||
|
if attachments == () {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
heading(level: 1, title, numbering: none)
|
||||||
|
|
||||||
|
for (i, att) in attachments.enumerate() {
|
||||||
|
let content = att.content
|
||||||
|
let caption = att.caption
|
||||||
|
let user-label = att.label
|
||||||
|
|
||||||
|
let final-label = if user-label != none {
|
||||||
|
user-label
|
||||||
|
} else {
|
||||||
|
label("attachment-" + str(i + 1))
|
||||||
|
}
|
||||||
|
|
||||||
|
[#figure(
|
||||||
|
content,
|
||||||
|
caption: caption,
|
||||||
|
kind: "attachment",
|
||||||
|
supplement: "pielikums",
|
||||||
|
)
|
||||||
|
#final-label
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user