I found a conversation about repeating footer (caption?) here (start). @PgBiel and I had a few ideas, but it looks like the goal was a bit different: get footer on all pages except last one.
Here is a slightly modified version:
#set page(height: 8em, width: 10em, fill: gray)
#let next-page-table(next-page-content: [], ..table-args) = context {
let columns = table-args.named().at("columns", default: 1)
let column-amount = if type(columns) == int {
columns
} else if type(columns) == array {
columns.len()
} else {
1
}
// Counter of tables so we can create a unique table-part-counter for each table
let table-counter = counter("table")
table-counter.step()
// Counter for the amount of pages in the table
// It is increased by one for each footer repetition
let table-part-counter = counter("table-part" + str(table-counter.get().first()))
show <table-footer>: footer => {
table-part-counter.step()
context {
// if table-part-counter.get() != table-part-counter.final() {
if table-part-counter.get().first() > 1 {
// Display the footer only if we aren't at the last page
footer
}
}
}
table(
..table-args,
table.footer(
// The 'next page' content spans all columns and has no stroke
// Must be selectable by the show rule above which hides it at the last page
table.cell(colspan: column-amount, stroke: none, [#next-page-content <table-footer>])
)
)
// Compensate for the empty footer at the last page of the table
v(-measure(next-page-content).height)
}
first page
#pagebreak()
#next-page-table(
next-page-content: [Next page!],
columns: 3,
..range(3 * 9).map(i => str.from-unicode("a".to-unicode() + i))
)
#pagebreak()
last page
I’m not sure you can get anywhere close to a clean solution (I don’t even know how to correctly change the code to get at least some sort of solution). I also don’t think you can get something like figure.where(kind: table).supplement to recreate the table caption instead of using hard-codded caption-like footer text. And also, I haven’t found any open issue for that:
I also sometimes ideally want a solution for that: “Table 1. …”, “Continuation of Table 1” (something like that). So you can create an issue for this.