Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If a page ends with a heading, the page number has the style of the heading. #4022

Closed
1 task done
matj1 opened this issue Apr 26, 2024 · 3 comments
Closed
1 task done
Labels
bug Something isn't working duplicate This issue or pull request already exists

Comments

@matj1
Copy link

matj1 commented Apr 26, 2024

Description

If a page with a number ends with a heading, the page number too is large and bold (or however else headings are displayed).

It manifests in this example:

#set page(numbering: "1", number-align: top)
= thick number
#pagebreak()
= thin number
if there is something under the heading

Snímek obrazovky z 2024-04-26 14-06-55
Snímek obrazovky z 2024-04-26 14-07-10

I expect that the number would not take the style of headings. It seems that the heading is not ended properly.

Reproduction URL

https://typst.app/project/pVTEcA738PFjlwKgbr30PB

Operating system

Web app

Typst version

  • I am using the latest version of Typst
@matj1 matj1 added the bug Something isn't working label Apr 26, 2024
@Leedehai
Copy link
Contributor

It turns out it's not just the heading whose style can affect the page number's style. In fact, whatever style belonging to the last element on the page's proper (that is, excluding the page marginals) can affect the page number's style.

#set page(numbering: "1", number-align: center)
= thick number
#pagebreak()
= thin number
text under the heading
#pagebreak()
*thick text*
#pagebreak()
_italic text_
#pagebreak()
#text(fill: red, [red text])

@Leedehai
Copy link
Contributor

Leedehai commented Apr 28, 2024

Looks like a dupe of #241. Not an easy fix it seems, though one solution would be replacing page.rs typst::layout::page::Packed<PageElem>::layout()'s

                let sub = content
                    .clone()
                    .styled(AlignElem::set_alignment(align))
                    .layout(engine, styles, pod)?
                    .into_frame();

with

                let sub = content
                    .clone()
                    .styled(AlignElem::set_alignment(align))
                    .layout(engine, StyleChain::new(&Styles::new()), pod)? // Use a brand-new StyleChain!
                    .into_frame();

@laurmaedje laurmaedje closed this as not planned Won't fix, can't repro, duplicate, stale Apr 29, 2024
@laurmaedje laurmaedje added the duplicate This issue or pull request already exists label Apr 29, 2024
@laurmaedje
Copy link
Member

Not an easy fix it seems, though one solution would be replacing page.rs ...

That would break other things (the capability to change global styles from Rust, e.g. in the tests, but it would also mean that headers/footers would never respect a global #set text(font: ..)). But #241 is on my radar as I'm working on the realization and I'll try to fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants