Skip to content

fix(templates): replace hardcoded total-pages in en/mcm and en/default Typst templates - #125

Merged
jihe520 merged 1 commit into
jihe520:mainfrom
Alumin-Hydro:fix/total-pages-hardcode
Sep 13, 2026
Merged

jihe520 merged 1 commit into
jihe520:mainfrom
Alumin-Hydro:fix/total-pages-hardcode

Conversation

@Alumin-Hydro

Copy link
Copy Markdown
Contributor

Problem

Both English Typst templates hardcode the header's total page count:

#let total-pages = "4"

Any paper longer than 4 pages — i.e. every real submission — gets impossible headers like "Page 5 of 4" / "Page 11 of 4". I hit this while running the full math-modeling workflow on HiMCM 2025 Problem A; the verification stage caught the broken header during PDF visual review.

Fix

  • en/mcm/main.typ: #let total-pages = context str(counter(page).final().first() - 2) — subtracts the two front-matter pages (summary sheet + title page), matching the existing physical - 2 offset already used for the current page number, so both sides of "Page X of Y" stay consistent.
  • en/default/main.typ: #let total-pages = context str(counter(page).final().first()) — that template's header uses counter(page).display() directly with no offset, so no subtraction.

Verification

  • typst compile succeeds for both templates.
  • Rendered final-page headers are self-consistent: mcm template → "Page 4 of 4" (6 physical pages), default template → "Page 4 of 4" (5 physical pages).
  • The zh templates were checked and do not use total-pages, so no other templates are affected.

… in en/mcm and en/default

Both English Typst templates hardcoded the total page count as "4" in the
page header, producing impossible headers like "Page 5 of 4" for any paper
longer than 4 pages (i.e. every real submission).

- en/mcm: total-pages now evaluates counter(page).final() minus the two
  front-matter pages (summary sheet + title page), matching the existing
  physical-page offset used for the current page number
- en/default: total-pages now evaluates counter(page).final() directly

Verified: both templates compile cleanly with typst 0.14 and produce
consistent "Page N of N" headers on the final page.
@jihe520
jihe520 merged commit 487f350 into jihe520:main Sep 13, 2026
@jihe520

jihe520 commented Sep 13, 2026

Copy link
Copy Markdown
Owner

tks!!

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.

3 participants