This won’t work because of the header-ascent
parameter of page
. See Page Function – Typst Documentation
header-ascent
The amount the header is raised into the top margin.
Default: 30% + 0pt
Visual representation of what you are trying to do
#set rect(width: 100%, height: 100%, fill: aqua)
#let show-size = {
layout(size => {
[#calc.round(size.width.cm(), digits: 2) cm #sym.times #calc.round(size.height.cm(), digits: 2) cm.]
})
}
#set page(
"a4",
margin: (top: 25mm, x: 20mm, bottom: 10mm),
header: [#rect(show-size)],
footer: [#rect(show-size)],
)
#rect(fill: gray)[What you are trying to use
#show-size]
#set rect(inset: 0pt)
#set page(
header-ascent: 0cm,
footer-descent: 0mm,
)
#rect(fill: gray)[The full page
#show-size]
If you add
#set page(
header-ascent: 0cm,
...
)
then you will have access to the full size of the header. Not that I recommend that approach.
You could consider using the background
parameter of page
instead of header
.
#set page(
"a4",
margin: (top: 25mm, x: 20mm, bottom: 10mm),
background: {
place(top + left, dx: 25mm, line(
// The red line is 25mm long, to visualize
length: 25mm,
angle: 90deg,
stroke: red,
))
place(top + left, dy: 25mm, line(length: 100%)) // This is the line you want
},
)
And of course readjust your margins.