Skip to content

Adding invisible data (metadata()) after setting page.paper inside content (sub-document) creates an empty page #4407

Closed as not planned

Description

@Andrew15-5

Description

// 2 pages
// #set page(paper: "a5") // Doesn't matter
#metadata("") <begin-marker>
#[
  #set page(paper: "a5")
  Text
]
#metadata("") <end-marker>

// 1 page
// #set page(paper: "a5") // Doesn't matter
#metadata("") <begin-marker>
#set page(paper: "a5")
Text
#metadata("") <end-marker>

The first block creates one page with text and an empty page. The second doesn't add an unnecessary page at the end.

I am creating a bundle document that includes several other documents. This way I can have all reference links working and have an outline of all sub-document (with working links). But including a full document means including set/show rules, which creates a styled() content block/wrapper for each sub-document.

General AST structure
...
    [(
      metadata(value: ""), <- "sub-document starts" marker
      [ ],
      [ ],
      styled(child: [([Text], [ ])], ..), <- sub-document
      metadata(value: ""), <- "sub-document ends" marker
      [ ],
    )],
...

It would be normal in some cases if I replace seconds metadata() call with visible content (text). But still, maybe you want the text from outer (bundle document) be inserted into the same last sub-document's page (where there is still a lot of empty space) and not into a whole new page. This aspect can be potentially a new feature, but I don't know how exactly this can be controlled (maybe a new page.append-parbreak-if-inside-content).

I would like that at least an invisible data such as metadata() (or hide()?) won't create a new empty page as this is totally not a desirable behavior. But I have a feeling that this is impossible with the current (v0.11.0) design (maybe?). Or maybe a new check can be added that will "diff" the previous (bundle/global) set page() and the current (sub-document/nested) set page(). If they are identical then the last one will be removed and this way no new empty page at the end will appear. IMO, this is an easier route. But what if page.footer don't much?

To fix this, I can remove the sub-document's set page() by using a condition, but that condition would require a context so that I can query() the start/end sub-document labels/markers to see if the current document is inside a bundle document or not. At which point it will become #2326.

Similar but still different problem exists with set document (instead of set page) which is inside a context (to also check for is-sub-document()): #4065.

A general "embed sub-document" issue: #3723.

Reproduction URL

No response

Operating system

Linux

Typst version

  • I am using the latest version of Typst

Activity

  1. added
    bug
    on Jun 16, 2024
  2. laurmaedje commented on Jun 17, 2024

    @laurmaedje
    Member

    While it's a slightly different effect user-facing, this is internally the exact same problem as #2326, so I'll close as a duplicate.

  3. added
    duplicate
    on Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugduplicate

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions