ludwig-austermann / typst-din-5008-letter

A template for DIN 5008 inspired typst letter
MIT License
14 stars 0 forks source link

Footer on First Page, Page Number not on First Page #7

Open ondohotola opened 1 year ago

ondohotola commented 1 year ago

Can you revisit #3 again, because with 0.1.0 I don't l know any more how to turn the number off on the first page.

How do I turn off the footer for all but the first page, keeping the (self designed) footer in place?

ludwig-austermann commented 1 year ago

The best I can think of at the moment, it to write something like:

#import "@local/din-5008-letter:0.1.0"

#let hooks = din-5008-letter.block-hooks(
  pagenumber: (wordings: (:), styling: (:), extras: (:)) => locate(loc => if loc.page() > 1 {
    set align(right)
    text(styling.theme-color)[#loc.page()]
    text(gray.darken(50%), " / " + str(counter(page).final(loc).at(0)))
  }),
  footer: locate(loc => if loc.page() == 1 [custom footer,\ which only appears on\ the first page])
)

#show: din-5008-letter.letter.with(block-hooks: hooks)

#for i in range(15).map(x => calc.abs(x - 7)) {
  lorem(20 * i)
  parbreak()
}

But you can notice, that the bottom margin of the 2nd page is not ideal. Unfortunately, typst doesn't yet allow for margins, which depend on pagenumbers.

ondohotola commented 1 year ago

Thank you,

The following (almost) works for me :-)-O

#let myfooter = text(size: 1em)[my footer\ and another line ]

and then

  pagenumber: (
    wordings: (:),
    styling: (:),
    extras: (:)) => locate(loc =>
      if loc.page() > 1 {
        align(right)[
          #counter(page).display(
            (number, total) => text[#number / #total#v(3em)],
            both: true,
          )
        ]
    } else { align(center)[#line(length: 100%)#myfooter] }
  ),

I need to play with the line length a little as I have a line in the header where length: 100% results in a wider line.