I did pretty much everything you said:
new script
// calculates the next date which has weekday <weekday>
// @param: weekday: written in letters or with numbers
// @return: returns the date the weekday is reached again
#let next(weekday) = {
let sWeekday = ("", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday")
let day = datetime.today()
assert((weekday in range(1, 8)) or weekday in sWeekday, message: "please enter a weekday (monday-sunday) or a number from 1 to 7!")
for i in range(7) {
if (weekday == day.weekday() or weekday == sWeekday.at(day.weekday())) {
return day
}
day = day + duration(days: 1)
}
}
// names: an array with names the schedule should include
// specified starting time
// #let start_date = datetime(day: 28, month: 10, year: 2024)
// set start_date to today
// #let start_date = datetime.today()
// start next __ (monday-sunday or 1-7)
// #let start_time = {next("monday")}
// start_name: begin with name <names[start_name]>
// weeks: amount of weeks displayed in the table
// signature_width: width of the signature column (like 6cm, 3em, ...)
// heading: content above the table
#let cleaning_schedule(names, start_date: next("monday"), start_name: 0, weeks: 38, signature_width: 6cm, heading: [#heading()[cleaning schedule]]) = {
let array = ("Name", "Datum", "Unterschrift")
for i in range(weeks) {
array.push(names.at(calc.rem(i + (start_name), names.len())))
array.push((start_date + duration(days: 7*i)).display("[day].[month].[year] - " + (start_date + duration(days: 7*i + 6)).display("[day].[month].[year]")))
array.push(h(signature_width))
}
// displaying
align(center + horizon)[
#heading
#table(
columns: 3,
..array
)
]
}
# examples:
#cleaning_schedule(("name 1", "name 2"))
#cleaning_schedule(("name 1", "name 2"), [#heading()[#text(blue)[cleaning schedule]]])
#cleaning_schedule(("name 1", "name 2", "name 3", "name 4"), start_date: {next("wednesday")}, start_name: 2, weeks: 30, signature_width: 9cm, heading: [#heading()[#text(red)[cleaning schedule]]])
everything is withing the function cleaning_schedule
now (except the function next
of course). Also, you can now change the heading and change the width of the signature column with units like cm, em etc. You can even use relative units like percent which refers the remaining space I think. Almost everything has useful preset values, so you only HAVE to enter the names, but you can change other parameters if you like to as demonstrated in the examples at the end of the new script.