0

I would like to have different page number formats for different sections of the document. I notice I can do per page numbering style using \thispagestyle (How to change page number location for first page only) but how can I do the same for a given section rather than a page? I.e., something like the following:

\begin{document}
\input{sectionA} %% page numbering style: -A-<page number>-
\input{sectionB} %% page numbering style: -B-<page number>-
\end{document}

I tried to use \thispagestyle but that doesn't quite work.

  • To be honest, i don't understand the question. Are you searching for How to use pagenumbering in the document? Can you show us with a minimal working example what you are trying to achieve? – Johannes_B Jan 20 '15 at 17:05
  • There is also \renewcommand{\thepage}{- A -\arabic{page}} and \setcounter{page}{1} – John Kormylo Jan 20 '15 at 17:14
  • @john-kormylo I'm basically looking for something like what you mentioned except that I am using fancyhdrs – JRR Jan 20 '15 at 17:23
  • 1
    I guess the sections are also numbered with letters, so i would suggest \renewcommand{\thepage}{\thesection--\arabic{page}} along with the aforementioned etcounter Or define globally that pages are counted sectionwise. This is all independant from fancyhdr, but seeing an MWE would be great to provide a solid solution. – Johannes_B Jan 20 '15 at 17:38
  • if you want to change just the letter that prefaces the page number, then define the page number field in header definition to use a command for that part of the number field, and change the value of the command just after the relevant sectioning command. but perhaps you want to start renumbering with 1? an "ascii" example would help. also be aware that the page heading style takes effect with the first page output after the change is invoked, so if your sections don't start on a new page, then the end of a previous section may get an inappropriate page reference. – barbara beeton Jan 20 '15 at 17:48
2

The following should do what you want. It numbers the secions alphabetically, starts every section on a new page and resets the page counter. It also works with hyperref.

jrrSectionNumbering

\documentclass{article}
\usepackage{etoolbox}
\pretocmd{\section}{\clearpage\setcounter{page}{1}}{}{}
\usepackage{blindtext}
\renewcommand{\thesection}{\Alph{section}}
\renewcommand{\thepage}{\thesection--\arabic{page}}
\usepackage{hyperref}
\begin{document}
\tableofcontents
\section{Wobbling Walrus}
\blindtext[30]
\section{Limbo Lion}
\blindtext[30]
\section{Disco Dogs}
\blindtext[30]
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.