Skip to content

#set page(..) doesn't work directly after tag #2987

Closed

Description

@tornaria

Description

Simple example:

#let var = state("var", 0)
#set page(paper: "a7", flipped: true)
#set page(fill:blue)
#var.update(1)
#set page(fill:red)
This page is blue! (var = #var.display())
#var.update(2)
#pagebreak()
This page is red! (var = #var.display())

I would expect the first page to be red, but it is blue. If one comments out the line #var.update(1), or if it's moved after the #set page(fill:red) then both pages are red.

This issue affects polylux as in the following example:

#import "@preview/polylux:0.3.1": *
#import themes.clean: *

#show: clean-theme.with(
  footer: [Author, institution],
  short-title: [Short title],
)

#slide[#lorem(20)]
#slide[#lorem(20)]

Here the header and footer is not added to the first slide, since the call to #set page(...) inside #slide(...) is not applied to the first page because clean-theme(...) already updated state.

This might be related to #2326 and/or #1886.

Reproduction URL

No response

Operating system

Linux

Typst version

  • I am using the latest version of Typst

Activity

  1. added
    bug
    on Dec 16, 2023
  2. tornaria commented on Dec 17, 2023

    @tornaria
    Author

    I realized the same thing happens in subsequent pages: if a state update is done after a pagebreak and before #set page().

    Change the snippet above to:

    #let var = state("var", 0)
    #set page(paper: "a7", flipped: true)
    #set page(fill:blue)
    #var.update(1)
    #set page(fill:red)
    This page is blue! (var = #var.display())
    #var.update(2)
    #pagebreak()
    #var.update(3)
    #set page(fill:green)
    This page is red! (var = #var.display())

    Then the second page is red (not green).

  3. tornaria commented on Dec 17, 2023

    @tornaria
    Author

    And this also affects polylux as in:

    #import "@preview/polylux:0.3.1": *
    #import themes.clean: *
    
    #show: clean-theme.with(
      footer: [Author, institution],
      short-title: [Short title],
    )
    
    #slide[#lorem(20)]
    #slide[#lorem(20)]
    
    #utils.register-section("Introduction")
    
    #slide[#lorem(20)]
    #slide[#lorem(20)]

    The third slide is also missing the header and footer (because the second slide ends with a pagebreak, the register-section call updates state, and so the #set page in the third slide doesn't work).

    It seems that state updates are attached to a page, so if it's before the first page or if a pagebreak has been issued, modifying the state causes a new page to be created before #set page gets a chance to do. The state update needs to happen between the two pages (or before the first page in the original issue).

  4. added
    styling
    on Dec 18, 2023
  5. changed the title [-]#set page(..) doesn't work in first page after state update[/-] [+]`#set page(..)` doesn't work directly after tag[/+] on Jul 16, 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

    bugstyling

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions