I need to change margin of a page on non first appeaser of page definition. Because of some crazy formatting required by my university i need to also add a table in background, and if be more specific “big table is added to first page of outline and none after”. For this i created a function page_tab. It returns an dictionary where background returns with required table using backgrounds variable, it has an context if statement
context if big == true {
if int(p_s) == int(counter(page).get().at(0)) {
//tab_big
} else { none }
} else {
// tab_small
}
this statement checks if the page the function call is the first by comparing int(p_s) == int(counter(page).get().at(0)). It works with background because it expects content, but the margin expects dictionary, yet context expression produce only context what cant be transformed in dict. I don’t know how to make it work at this point.
#let page_tab(
big: false,
theme: [],
author: [],
kurathor: [],
rec: [],
kontrol: [],
zatv: [],
grup: [],
rozdil: [],
p_s: int,
) = {
let backgrounds = context if big == true {
if int(p_s) == int(counter(page).get().at(0)) {
align(
left + top,
text(size: 9pt, font: "ISOCPEUR", block(
inset: (left: 2cm, top: 1cm, right: 8mm, bottom: 5mm),
width: auto,
height: auto,
grid(
align: center + horizon,
columns: (
1cm,
1.1cm,
2.5cm,
1.5cm,
1cm,
1fr,
5mm,
5mm,
5mm,
1.5cm,
2.3cm,
),
rows: (1fr, 0.5cm, 0.5cm, 0.5cm, 5mm, 5mm, 5mm, 5mm, 5mm),
stroke: 1pt,
grid.cell(colspan: 11)[~],
[ ],
[],
[],
[ ],
[ ],
grid.cell(colspan: 6, rowspan: 3, inset: (x: 5pt))[#{
set smartquote(enabled: false)
par(leading: 0.65em)[#text([#theme], size: 11pt)]
}],
[ ], [ ], [ ], [ ], [ ],
[Зм.], [Арк.], [№ докум.], [Підис], [Дата],
grid.cell(colspan: 2)[Розробив],
[#author],
[],
[],
grid.cell(rowspan: 5, inset: 1mm)[#text([_ЗМІСТ_], size: 20pt)],
grid.cell(colspan: 3)[Літ.],
[Аркуш],
[Аркушів],
grid.cell(colspan: 2)[Перевірив],
[#kurathor],
[],
[],
[],
[],
[],
[#counter(page).display()],
[#counter(page).final().at(0)],
grid.cell(colspan: 2)[Т. контр.],
[#rec],
[],
[],
grid.cell(colspan: 5, rowspan: 3)[_ #grup _],
grid.cell(colspan: 2)[Н. Контр.], [#kontrol], [], [],
grid.cell(colspan: 2)[Затв.], [#zatv], [], [],
),
)),
)
} else { none }
} else {
align(left + top, text(size: 9pt, block(
inset: (left: 2cm, top: 1cm, right: 8mm, bottom: 4mm),
width: auto,
height: auto,
grid(
align: center + horizon,
columns: (0.8cm, 1cm, 2.5cm, 1.5cm, 1cm, 1fr, 1.1cm),
rows: (1fr, 0.5cm, 0.5cm, 0.5cm),
stroke: 1pt,
grid.cell(colspan: 7)[~],
[ ],
[ ],
[ ],
[ ],
[ ],
grid.cell(rowspan: 3)[#text(size: 20pt)[#rozdil]],
[Аркуш],
[ ],
[ ],
[ ],
[ ],
[ ],
grid.cell(rowspan: 2)[#text(size: 14pt)[#counter(
page,
).display()]],
[Зм.], [Арк.], [№ докум.], [Підис], [Дата],
),
)))
}
let marg = if big == true {
if int(p_s) == int(counter(page).get().at(0)) {
page_marg_big
} else { page_marg }
} else {
page_marg
}
(
paper: "a4",
margin: marg,
background: backgrounds,
)
}
main.typ:
#{
context {
let page_st = counter(page).get().at(0)
set page(
..page_tab(
big: true,
theme: [theme],
author: [me],
kurathor: [],
kontrol: [],
zatv: [],
p_s: page_st,
),
)
outline()
}
}
P.S. I need to do this like this because the outline is not breakable




