Is it possible to align page numbers "outer" or "inner" without manually creating a footer?

I would like page numbers to be aligned to the outside of pages; that is, to the left on verso and to the right on recto. I can do this with an if inside a manual footer, but all I need is the basic numbering so it’d be nice to have this with a simple rule. I tried this:

#set page(number-align: left)
#show page: it => context {
  let abspage = locate(here()).page();
  if calc.odd(abspage) {
    set page(number-align: right)
  }
  it
}

But that doesn’t seem to work. I also tried this:

// page(number-align) not manually set
#show page: it => context {
  let abspage = locate(here()).page();
  if calc.odd(abspage) {
    set page(number-align: right)
  } else {
    set page(number-align: left)
  }
  it
}

In general, is there any easy way to align like this or do we just have to branch on the parity of the page number every time? I don’t see a relevant option in the alignment type.

Well the page setup guide mentions:

In case you need to right- or left-align the page number, use the number-alignargument of the page set rule. Alternating alignment between even and odd pages is not currently supported using this property. To do this, you’ll need to specify a custom footer with your footnote and query the page counter as described in the section on conditionally omitting headers and footers.

So I guess the answer is no.

1 Like