Skip to content

Synchronize page numbering in outline with page counter - #284

Merged
laurmaedje merged 1 commit into
typst:mainfrom
dvdvgt:fix/toc-page-number
Mar 25, 2023
Merged

laurmaedje merged 1 commit into
typst:mainfrom
dvdvgt:fix/toc-page-number

Conversation

@dvdvgt

@dvdvgt dvdvgt commented Mar 25, 2023

Copy link
Copy Markdown
Contributor

This PR addresses issue #275.

Description

Instead of inserting the number of the page where a heading is located, we now take into account the state of the page counter and therefore query the page counter at the location of the heading.

Discussion

  1. Currently (with the changes in this PR), when we have

    #outline()
    
    #pagebreak()
    #counter(page).update(1)
    = heading
    #counter(page).step()
    ...
    

    the heading will be listed with page number 1 instead of 2 in the outline, that is, if the page counter is altered after the heading, the page number in the outline will not match the page number appearing in the footer.

    I will be happy to change that, however I am unsure how to specifically query the state of the page counter at the end of a page.

  2. I tested what happens, if we have no numbering or footer set, that is, #set page(numbering: none, footer: none). It seems to behave correctly, however as this is my first time working with this codebase I cannot fully understand why this is the case. I'd recommend that the reviewer double checks the correctness.

@laurmaedje
laurmaedje merged commit 6545620 into typst:main Mar 25, 2023
@laurmaedje

Copy link
Copy Markdown
Member

I'll see whether I can handle the edge case with the page counter update in a general way.

yipinliu pushed a commit to yipinliu/typst that referenced this pull request Mar 27, 2023
* 'main' of https://github.com/typst/typst: (22 commits)
  Added IPA pronunciation (typst#349)
  Cache eviction helps
  Pronunciation
  Don't let the build script overwrite TYPST_VERSION (typst#154)
  Document behaviour of dictionary.insert() when key exists (typst#282)
  Add custom font search path support for typst cli (typst#270)
  Added return type to methods of colors in docs (typst#291)
  change page numbering for outline (typst#284)
  Newton's notation for derivatives (typst#281)
  Use correct smart quotes for Norwegian Bokmål language code (typst#278)
  Fix fill color obstructing page header and background (typst#277)
  Simplify heading block example
  Fix index out of bounds error in build script (typst#173)
  Replace infinite repeat layout panic with error (typst#235)
  Changed "ColorChoice::Always" to "ColorChoice::Auto" to honour user setting of TERM / NO_COLOR (typst#230)
  Fixed Typo (typst#227)
  Fix descriptions of some types (typst#206)
  Fix import syntax in tutorial (typst#205)
  Make alignment actually centered (typst#176)
  strip cli target (typst#143)
  ...
Dikluwe pushed a commit to Dikluwe/typst-crystalline that referenced this pull request Sep 12, 2026
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

Successfully merging this pull request may close these issues.

2 participants