#Custom header

1 messages · Page 1 of 1 (latest)

versed glen
#

Hello,
I am trying to create such a header but I can't seem to be able to achieve this.

  set page(
    paper: "a4",
    margin: (x: 2.5cm, y: yPageMargin),
    header: locate(loc => {
      rect(fill: red,
      "Foo"
      " "
      [#counterInt]

      rect(fill: red)
      
    }),
    header-ascent: 0%
  )

Even then it doesn't seem to stack like in the normal page flow and I am clueless how to achieve it.

bronze steeple
#

locate, at least the way you're using it, is deprecated by the way

#

But if the margins or top margin are known and you want it to be precise this seems to work (assuming you want it to be as in the left image)

#set page(
  header: [
    Foo #context box(line(angle: 90deg, length: page.margin - page.margin * page.header-ascent.ratio)) Bar
  ],
)
#

of course you probably don't need - page.margin * page.header-ascent.ratio because the line will exceed the page border either way

#

?r pagesize=default theme=light

#set page(
  margin: 2cm,
  header: stack(dir: ltr, spacing: 5pt,
    "Foo",
    context line(angle: 90deg, length: page.margin - page.margin * page.header-ascent.ratio),
    "Bar"
  )
)

#place(top + left, line(length: 100%, angle: 90deg))
#place(top + right, line(length: 100%, angle: 90deg))
#place(top + left, line(length: 100%))
#context place(top + left, dy: -page.header-ascent.ratio * page.margin, line(length: 100%))
#place(bottom + left, line(length: 100%))