How to repeat the header (or a modified header) of a multi-page table?

Hi,

I discover how to use a header in table that can be repeat if #pagebreak() is used.

But I would like to know if it is possible to have a header (that is a all table) that can be repeated when page change but without using #pagebreak() function. That automaticly repeat a header if page change.

And in a second time, this header can change too.

An example of the need :

// set page a4

MY HEADER HERE (a table)

Some text... I don't know the size...

(Here according to the amount of text, the page is automaticcly changed)

MY HEADER HERE (I want it repetead here).

...

At a moment HEADER CHANGE
MY_NEW_HEADER for now will be that.
...


Hi @tooremdrama ,

To answer the first part of your question:

have a header (that is a all table) that can be repeated when page change but without using #pagebreak() function. That automaticly repeat a header if page change.

Typst does that out of the box with the repeat parameter of table.header (see documentation):

#table(
  table.header(repeat: true,)[header],
  [#lorem(1000)],
)

For the second part of your question,

And in a second time, this header can change too.

@bluss made a nice implementation of that here: How to Detect a Pagebreak? - #5 by bluss.

It is worth mentioning this workaround for repeating different figure caption that does include a different repeating table header: Add ability to repeat the caption (or a modified caption) of a multi-page table in subsequent pages · Issue #5057 · typst/typst · GitHub

Hope this helps!

1 Like

Thank you for you quick answer. I will test that.
But for the first part, I don’t want to repeat the header of a table.
I want to repeat all the table.

I wonder, if there is a way to have a header and footer for all the page that is repeated and at a moment, we can change it.

Maybe I was not clear, something like that :

HEADER
Content
FOOTER
// new page
HEADER
Content
FOOTER
//new page
HEADER 2
Content
FOOTER 2
...

Does it have to be a table header or are you just looking for a header and a footer that are repeated on every page? In the latter case, you can use the header and the footer of the Page Function – Typst Documentation. To change the header and the footer after two pages, just call the set rule for the page again. Note that this will automatically create a new page.

#set page(header: "HEADER", footer: "FOOTER")
#lorem(900)

#set page(header: "HEADER 2", footer: "FOOTER 2")
#lorem(100)
2 Likes

Yes, it will be a table in the header…

A table inside the header works, just not a table header (this only exists inside a table). Unfortunately, your specifications are not really clear…

#set page(
  header: table(columns: (1fr, 1fr, 1fr), "My", "header", "table"),
  footer: table(columns: (1fr, 1fr, 1fr), "My", "footer", "table"),
)
#lorem(900)
2 Likes

Perhaps something like this? How do I repeat a table’s header every page, but not the content?

I agree that the request is not that clear…

1 Like

This answer perfectly to my current need. I complicate myself alone :scream:

Thank you for all your answer, I discover a lot of thing that can be useful in future finally. ^^

2 Likes