Skip to content

Text show rule sometimes not applied in footnotes #1467

Closed as not planned
Closed as not planned

Description

@raphCode

Description

While using a show "text": "replacement" rule, I discovered that it is sometimes not applied in a footnote.
Adding / removing a pagebreak or unrelated text seems to influence whether that bug triggers.

#set page(width: auto, height: auto, margin: 5mm)

#let test = [
  #show "fail": "ok"
  fail
  #footnote[fail]
]

//#show "fail": "ok" // A
#test
#pagebreak() // B
#test
hello // C

In this example, the first footnote shows the replaced text, while the second one does not:
image

Variants:

  • uncomment line A: both work
  • delete line B: both fail
  • delete line C: both work

Reproduction URL

https://typst.app/project/pO-Qk0SloWuM-YvAQeFFIH

Operating system

Web app, Linux

Typst version

  • I am using the latest version of Typst

Activity

  1. added
    bug
    on Jun 11, 2023
  2. laurmaedje commented on Jun 12, 2023

    @laurmaedje
    Member

    Same reason as #1348

  3. added
    styling
    on Jun 12, 2023
  4. raphCode commented on Jun 13, 2023

    @raphCode
    ContributorAuthor

    Interesting.
    Can you please elaborate on the technical background of this issue?
    I want to understand how footnotes work and in which cases show rules are applied to footnotes.

    Having the inner workings of the issue in mind provides me with confidence that my document is working as intended.
    Right now the behavior seems very magical / random to me and I fear my document will break at unrelated future changes.

  5. laurmaedje commented on Jun 13, 2023

    @laurmaedje
    Member

    The footnote's entry is layouted with the styles common to the whole flow of content it is contained in (the whole document or the closest parent column container). A show rule at the beginning of the document is shared by all content and thus applies to the flow. If just a single word is before the show rule, the show rule is not shared anymore and thus not lifted upwards and does not apply to the flow and, by extension, not to the footnotes. Spaces and blank lines before the show rules are fine because they are trimmed away. Not saying that this behaviour is ideal in this case, but that's how it works, currently.

  6. raphCode commented on Jun 13, 2023

    @raphCode
    ContributorAuthor

    Thank you.

    To rephrase (maybe helpful for others):

    • there is the concept of Flow during layouting (could not find it in the docs tho)
    • a new Flow seems to be started:
      • at document start
      • after #pagebreak() (I was not able to get a new Flow after an automatic pagebreak)
      • after #page
      • in a multi-column document, maybe at columns (I have not tried that)
    • footnotes are styled in the context of its containing Flow, which might not necessarily be the context that is in scope when #footnote is called
    • When a show rule is defined at the correct position and scope, it is lifted up to be valid inside the whole Flow

    Footnotes, and document layouting in general, are very difficult to make intuitive. This issue is where one of the internal abstractions leak a bit, but with your explanation the behavior makes sense to me and seems reasonable.
    Thanks for typst :)

    (Should we close this or keep it open?)

  7. laurmaedje commented on Jun 13, 2023

    @laurmaedje
    Member

    Exactly!

    Should we close this or keep it open?

    I would close it as "working as intended" for now, but that doesn't mean no improvement is possible here. More that it's not an actionable issue as-is.

  8. raphCode commented on Jun 13, 2023

    @raphCode
    ContributorAuthor

    Alright!
    I opened a PR that includes the information in the docs, that might be helpful I think.
    #1484

  9. added a commit that references this issue on Apr 10, 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