feat: add attachments

This commit is contained in:
Kristofers Solo 2025-08-26 16:46:01 +03:00
parent 3e4719c17b
commit a04e644822
Signed by: kristoferssolo
GPG Key ID: 8687F2D3EEE6F0ED
3 changed files with 75 additions and 10 deletions

View File

@ -1,6 +1,6 @@
#import "@preview/fletcher:0.5.8" as fletcher: diagram, edge, node
#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/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],
),
),
),
)

View File

@ -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 attachment(caption: none, label: none, body) = {
(
content: body,
caption: caption,
label: label,
)
}
// This function gets your whole document as its `body` and formats
// it as an article in the style of the IEEE.
#let ludf(
@ -36,8 +46,9 @@
date: datetime.today(),
place: none,
logo: none,
outline-title: "SATURS",
attachments: none,
outline-title: "Saturs",
attachments: (),
attachment-title: "Pielikumi",
body,
) = {
// Set document metadata.
@ -134,7 +145,7 @@
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: ". ")
@ -153,6 +164,7 @@
fig
}
// Custom show rule for references
show ref: it => {
let el = it.element
@ -198,7 +210,11 @@
let fig_num = counter(figure.where(kind: el.kind))
.at(el.location())
.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)
@ -247,11 +263,14 @@
// Table of contents.
// Uppercase 1st level headings in ToC
show outline.entry.where(level: 1): it => {
upper(it)
}
show outline.entry.where(level: 1): 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.
body
@ -259,6 +278,7 @@
// Display bibliography.
bibliography
make-attachments(attachment-title, attachments)
make-documentary-page(
title,

View File

@ -157,3 +157,31 @@
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
]
}
}