feat: revamp template API and box components

This commit is contained in:
Popa committed 2026-09-11 14:00:59 +02:00
1 parent 51fc2ef3c3
commit 337ff33853
8 files changed
+211 -130

No files matched your search

+17 -14
View File
@@ -1,6 +1,6 @@
#import "../config.typ": custom-raw-syntaxes
#import "../helpers.typ": content-to-string, render-footnote-entry
#import "../theme.typ": base-theme, code-theme, colors, common-theme, end-message, smallcaps
#import "../theme.typ": base-theme, code-theme, colors, common-theme, credits, smallcaps
#import "../components/student-table.typ": exercise-overview
/// Base template for exercise sheets.
@@ -13,21 +13,23 @@
students,
tutor,
tutor-label: none,
sheet: [Exercise Sheet],
sheet-label: [Exercise Sheet],
logo: none,
show-logo: true,
page-numbering: common-theme.page-numbering,
table-header-smallcaps: false,
text-font: base-theme.text-font,
math-font: base-theme.math-font,
show-end-message: false,
end-message: end-message,
no-pagebreak: true,
show-credits: false,
credits: credits,
body,
) = {
assert.eq(type(exercises), int, message: "exercises must be an integer")
assert(exercises > 0, message: "exercises must be a positive integer")
let ttl = sheet + if { sheetnumber < 10 } { " 0" } else { " " } + str(sheetnumber)
let ttl = if sheetnumber == none { sheet-label } else {
sheet-label + if { sheetnumber < 10 } { " 0" } else { " " } + str(sheetnumber)
}
set document(
title: ttl,
@@ -67,7 +69,9 @@
if first-h1.get() {
first-h1.update(false)
} else {
// pagebreak(weak: true)
if (not no-pagebreak) {
pagebreak(weak: true)
}
}
v(0.3em)
it
@@ -97,8 +101,8 @@
show raw.where(block: true): box.with(..base-theme.raw-block)
show raw.where(block: false): box.with(..code-theme.inline)
let logo-content = if not show-logo or logo == none {
[]
let logo-content = if logo == none {
none
} else {
logo
}
@@ -110,9 +114,8 @@
columns: (6fr, 1fr),
align: (start + horizon, end + horizon),
row-gutter: 0.25cm,
[
#title[#sheet #if sheetnumber < 10 { "0" };#sheetnumber]
],
title(ttl),
logo-content,
grid.cell(
@@ -134,10 +137,10 @@
body
if show-end-message {
if show-credits {
v(1fr)
set text(size: 10pt)
align(center)[#end-message]
align(center)[#credits]
}
}
+12 -12
View File
@@ -4,7 +4,7 @@
/// Computer science exercise sheet template.
#let computer-science-template(
sheetnumber: 0,
sheetnumber,
subtitle: none,
course,
students,
@@ -12,14 +12,14 @@
university,
institute,
department: none,
submit_until: none,
testats_from: none,
testats_until: none,
group-digits: false,
decimal-comma: false,
page-numbering: common-theme.page-numbering,
raw-syntaxes: custom-raw-syntaxes,
submit-until: none,
attestations-from: none,
attestations-until: none,
info-text: none,
page-numbering: common-theme.page-numbering,
group-digits: false,
decimal-comma: true,
raw-syntaxes: custom-raw-syntaxes,
text-font: computer-science-theme.text-font,
math-font: computer-science-theme.math-font,
table-header-smallcaps: false,
@@ -137,12 +137,12 @@
v(2em)
[
#if submit_until != none [
*Abgabe bis #german-date-time(submit_until);.*
#if submit-until != none [
*Abgabe bis #german-date-time(submit-until);.*
]
#if testats_from != none and testats_until != none [
*Testate vom #german-date-time(testats_from) bis #german-date-time(testats_until).*
#if attestations-from != none and attestations-until != none [
*Testate vom #german-date-time(attestations-from) bis #german-date-time(attestations-until).*
]
#if info-text != none [#info-text]