Let’s say I have the following content function that I call multiple times in my multi-page document:
#let myText = [
#v(1em) \
#lorem(5)
]
I would like for the space function #v(1em) to not be visible whenever #myText occurs at the top of a page right after a page break, for consistent margins. I thought I could use #context with #if here().position().y != page.margin.top.length as a conditional for visibility of the space:
It seems like here().position().y is based on the baseline of the text content. When I set a larger text size for the document, the position value changes. Is there a way to refer to the top left corner of the “bounding box” instead of the baseline position?
Or is there another way of conditionally hiding content if it occurs at the start of a page?
Unfortunately that doesn’t seem to work. Even if I put v(1em, weak: true) at the start and end of the definition of myText, there are no gaps between consecutive calls of myText.
Basically, when I have the following layout:
= Some example sections (each section is a `myText`):
#myText()[custom body argument]
#myText()[custom body argument2]
#pagebreak
#myText()[custom body argument3]
#myText()[custom body argument4]
I would like equal gaps between header and myText and between each instance of myText. But if a myText occurs at the start of a page, I don’t want any spacing between the page margin and the block. v() or h() with weak: true doesn’t seem to do the trick.
equal gaps between header and myText and between each instance of myText
and
if a myText occurs at the start of a page, I don’t want any spacing between the page margin and the block
//Set up page and make the header & footer visible
#set rect(width: 100%, height: 100%)
#set page(
height: 5cm,
header: rect(),
footer: rect()
)
#let myText(content) = {
v(3em, weak: true)
content
}
= Some example sections:
#myText()[custom body argument]
#myText()[custom body argument2]
#pagebreak()
#myText()[custom body argument3 (after `pagebreak()`)]
#myText()[custom body argument4]
#myText()[custom body argument5]
#myText()[custom body argument6 (after autmatic page break)]
#myText()[custom body argument7]
#myText()[custom body argument8]