andreasKroepelin / polylux

A package for creating slides in Typst
https://polylux.dev/book
MIT License
1.18k stars 55 forks source link

Footnote numbering increments with subslides #165

Open TakodaS opened 6 months ago

TakodaS commented 6 months ago
#slide[
  #one-by-one[
    One#footnote[Numbering starts at 1.]
  ][ footnote numbering increases... ]
]

With each subslide, the footnote numbering increments. Typst's footnote documentation says the following:

By default, the footnote numbering continues throughout your document. If you prefer per-page footnote numbering, you can reset the footnote counter in the page header. In the future, there might be a simpler way to achieve this.

However, since polylux implements new pages using pagebreak I'm not sure how to fix this.

AnnLIU15 commented 6 months ago

To reset the footnote counter in the page header according to the Typst documentation, you can simply modify the content of the slide in xxxx.typ. This adjustment might resolve your issue. However, be aware that the footnote content could appear before its corresponding citation.

For instance, you might download simple.typ and import it locally into your main.typ using the directive #import "libs/simple.typ": *. Then, modify the import statements as follows:

// previous
#import "../logic.typ"
// after modifying
#import "@preview/polylux:0.3.1": *
#import logic:*

Next, insert counter(footnote).update(0) after if sections == () [] else { deco-format(sections.last().body) } on line 52. This change should address the issue where "Footnote numbering increments with subslides".

1715236722693

The output is shown in the following image:

image

andreasKroepelin commented 6 months ago

This is known problem and has been discussed extensively elsewhere. It is indeed something that cannot be solved nicely by Polylux without Typst offering some "state freezing".

We can of course discuss whether it makes sense to just always start the footnote counter from 1 on every slide...

TakodaS commented 6 months ago

@AnnLIU15 This would have be be repeated on a theme-by-theme basis which is not great. I think the only real solution would be to refactor the code so that logic.typ:polylux-slide implements page rather than pagebreak. That way, page header options can be manipulated directly and will hopefully futureproof polylux against any changes.

@andreasKroepelin Can you explain the advantages of using pagebreak rather than just making a list of new pages and joining them to create subslides?

Or, alternatively, put in a feature request in Typst to add some more options in page break. Thoughts?

andreasKroepelin commented 6 months ago

I don't think there was a reason to use pagebreak rather than multiple pages 🤔 We could try using the latter, I guess...

TakodaS commented 6 months ago

I have tried implementing this, but ran into the problem that I need to replicate the weak: true argument of pagebreak using page. By inserting a weak pagebreak, i think typst runs over the code again and removes any blank slides that are generated by polylux. Without this, page(body) will generate a load of blank slides.

andreasKroepelin commented 6 months ago

Ah yeah that's probably the reason why I used pagebreak then.

tapyu commented 5 months ago

It is indeed something that cannot be solved nicely by Polylux without Typst offering some "state freezing".

Is there any prospective about it?

rmburg commented 5 months ago

We can of course discuss whether it makes sense to just always start the footnote counter from 1 on every slide...

I'd be very much in favor of this, at least as a temporary workaround. Currently, I have to add #counter(footnote).update(0) to the top of every slide that uses footnotes and subslides.

tapyu commented 5 months ago

Is there an opened issue in Typst addressing this topic? If no, it should be opened.

rmburg commented 5 months ago

Is there an opened issue in Typst addressing this topic? If no, it should be opened.

https://github.com/andreasKroepelin/polylux/issues/67 https://github.com/typst/typst/issues/1841