[FEAT] Add dynamic page style for chapter page #57

Closed
opened 2025-05-11 01:51:17 +00:00 by nuluh · 1 comment
nuluh commented 2025-05-11 01:51:17 +00:00 (Migrated from github.com)

Problem Statement

The whole document has same position of page numbering at the bottom center.

Proposed Solution

This is best handled inside the .cls file using the fancyhdr package with conditional logic.

Alternatives Considered

No response

Component

LaTeX Document

Priority

Critical (blocks progress)

Implementation Ideas

  1. Load fancyhdr in thesis.cls
\RequirePackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{} % clear default
  1. Define global page style (top-right)
\fancyhead{} % clear
\fancyfoot{} % clear
\fancyhead[R]{\thepage}

This ensures all pages by default show page number at the top-right.

  1. Define custom page style for chapter first page
\fancypagestyle{plain}{%
  \fancyhf{} % clear everything
  \fancyfoot[C]{\thepage} % bottom center
}

Now, any page using the plain pagestyle will show page numbers bottom-centered, which is exactly what LaTeX applies by default for chapter openings and \maketitle.

Note: KOMA and memoir classes override plain, but in report (default class that being extending), this works perfectly and is standard in community examples.

  1. Optional: Re-apply page style after TOC-like macros
% At end of maketitle.tex or frontmatter files
\thispagestyle{plain} % ensures first page is bottom-centered
\cleardoublepage
\pagestyle{fancy}     % reapply standard top-right afterward

Or automate it by wrapping in the frontmatter macros.

Expected Benefits

The page number styling should automatically use bottom center only for first page of chapter, and use top right otherwise

Additional Context

No response

### Problem Statement The whole document has same position of page numbering at the bottom center. ### Proposed Solution This is best handled inside the .cls file using the `fancyhdr` package with conditional logic. ### Alternatives Considered _No response_ ### Component LaTeX Document ### Priority Critical (blocks progress) ### Implementation Ideas 1. Load fancyhdr in thesis.cls ```latex \RequirePackage{fancyhdr} \pagestyle{fancy} \fancyhf{} % clear default ``` 2. Define global page style (top-right) ```latex \fancyhead{} % clear \fancyfoot{} % clear \fancyhead[R]{\thepage} ``` This ensures all pages by default show page number at the top-right. 3. Define custom page style for chapter first page ```latex \fancypagestyle{plain}{% \fancyhf{} % clear everything \fancyfoot[C]{\thepage} % bottom center } ``` Now, any page using the plain pagestyle will show page numbers bottom-centered, which is exactly what LaTeX applies by default for chapter openings and \maketitle. > ✅ Note: KOMA and memoir classes override plain, but in report (default class that being extending), this works perfectly and is standard in community examples. 4. Optional: Re-apply page style after TOC-like macros ```latex % At end of maketitle.tex or frontmatter files \thispagestyle{plain} % ensures first page is bottom-centered \cleardoublepage \pagestyle{fancy} % reapply standard top-right afterward ``` Or automate it by wrapping in the frontmatter macros. ### Expected Benefits The page number styling should automatically use bottom center only for first page of chapter, and use top right otherwise ### Additional Context _No response_
nuluh commented 2025-05-11 17:28:17 +00:00 (Migrated from github.com)

5e08d4f8c6/latex/thesis.cls (L97-L104)

titlepage environment should be avoided since by default, a titlepage environment:

  • Suppresses page numbers
  • Does not increment the page counter
  • Resets to the same \thispagestyle every time

so latex can paginated naturally

https://github.com/nuluh/thesis/blob/5e08d4f8c6d72bc3dc9f0bbec958cc477155b2ca/latex/thesis.cls#L97-L104 `titlepage` environment should be avoided since by default, a titlepage environment: - Suppresses page numbers - Does not increment the page counter - Resets to the same \thispagestyle every time so latex can paginated naturally
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: nuluh/thesis#57