#set page with included pages creates two page breaks

6 messages · Page 1 of 1 (latest)

woeful flax
#

I have a template toc

#let toc(title, subtitle: none, short: none, date: none, note: none, body) = [
  #context if not state("included", false).get() [
    ...
  ] else [
    #heading([
      #if subtitle != none {
        subtitle
      } else {
        title
      }
    ])
  ]
  #show: show-target(paged: doc => {
    set page(
      header: context [
        ...
      ],
      footer: context [
        ...
      ],
    )
    body
  })

  ...
  #body
]

My main document looks like:

#import "/typst-utils/main.typ": *
#show: style
#show: toc.with("Test", short: "Test", date: "2025-10-10", subtitle: "Gesamtdokument")


#context state("included", false).update(true)

#context include "Include1.typ"
#context include "Include2.typ"

#context state("included", false).update(false)

#show: sources

And my included files like:

#import "/typst-utils/main.typ": *
#show: style

#show: toc.with("Include1", subtitle: "Include1", short: "Short")

Include1


#show: sources

The generated file is attached. As one can see the heading of the files (Includedx) takes a whole page, as it counts towards "Gesamtdokument" (top right is the file)

#

TL;DR the main issue for me is, that the
#heading in the toc show rule calls a set page for my "main"-Document, instead of the document it was called from (includedx)

page 3 and 5 (real pages, not footer pages) should not be there in the first place. The heading should be part of 4 and 6

prime void
#

this seems wrong
first body should probs be doc

#

anyway, but this might fix your issue:

#
#show: if state("included", false).get() {
  // Don't add header
  it => it
} else {
  show-target(paged: doc => ...)
}```