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

Show rules are messing up with outline entries #19

Open
gzagatti opened this issue Dec 20, 2023 · 1 comment
Open

Show rules are messing up with outline entries #19

gzagatti opened this issue Dec 20, 2023 · 1 comment

Comments

@gzagatti
Copy link

In the example below, I add a page break after H1. Normally, Typst will display the page after the break in the outline.

But when I insert thm-rules show rule after the heading show rule, the outline entry does not behave as expected anymore. The outline shows the page entry before the break.

#import "@preview/lemmify:0.1.5": *

#let (
  theorem, lemma, corollary,
  remark, proposition, example,
  proof, rules: thm-rules
) = default-theorems("thm-group", lang: "en")

#outline(target: heading.where(outlined: true))

#show heading: it => {
  if it.level == 1{
  pagebreak(weak: false)
    it
  } else if it.level == 2 {
    it
  } else {
    it
  }
}

#show: thm-rules

#[= Foo]

#[= Bar]

Hello!

If I reverse the order and call the show rule for thm-rule before heading, the problem goes away. I find this behavior very odd. My assumption is that lemmify shouldn't be messing up with headings in its show rule. Any idea of what's going on here?

@Marmare314
Copy link
Owner

I finally figured out what part of the code is causing this. It is the thm-reset-counter-heading-at function, specifically

show heading.where(level: level): it => {
  thm-reset-counter(group)
  it
}

Reversing the order of thm-reset-counter(group) and it seems to fix the issue. But I'm still not sure why this is causing the outline page number to be decreased.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants