I want to change the page numbering style for a document that I have such that the section number and page number (relative to the current section) are given, e.g., 3-14, would indicate the 14th page in sec. 3 (which maybe the 45th page overall).
I could get this in my footer by customizing the footer with secnum-pagenum, and resetting the page number counter for each section, but the TOC wouldn't be correct. (I'm assuming this as I haven't actually tried it). Anyone out there know how to get the pagenumbers to appear like this in both the footer and the TOC?
Page Layout ⇒ custom page numbers?
Re: custom page numbers?
Try with
PREAMBLE
\usepackage{fancyhdr}
DOCUMENT
\pagestyle{fancy}
\fancyfoot[C]{\thesection-\thepage}
but you will have to reset the page counter each section with
\setcounter{page}{1}
PREAMBLE
\usepackage{fancyhdr}
DOCUMENT
\pagestyle{fancy}
\fancyfoot[C]{\thesection-\thepage}
but you will have to reset the page counter each section with
\setcounter{page}{1}
custom page numbers?
Sorry if I wasn't clear. I can get the footer to show correctly by doing exactly what you have suggested. The problem that I have is the Table of Contents. In the TOC only the page # is shown, so with 17 sections I have 17 different page # 1's. I want the TOC to show the page number to be 1-1, or 17-1 according to which section it is.mtnbkr wrote: Anyone out there know how to get the pagenumbers to appear like this in both the footer and the TOC?
Thanks for the reply. Anyone else out there have a suggestion?
Re: custom page numbers?
Sorry I thought this would change the TOC too, but I have seen it doesn´t...
I have been searching a solution for a while, but....no idea, maybe it would be possible by modifiying a command using the titlesec or titletoc packages, but I have no idea at the moment...I guess the fancyhdr package can´t achieve to solve this problem...
I have been searching a solution for a while, but....no idea, maybe it would be possible by modifiying a command using the titlesec or titletoc packages, but I have no idea at the moment...I guess the fancyhdr package can´t achieve to solve this problem...
custom page numbers?
Here is a hackish solution:
Note that this is very likely to fail in interesting ways if some other command or package tries to do something to the page numbering. Especially, \pagenumbering will destroy the effect.
A similar hack isThe chappg package goes some steps further, but works only with chapters.
Code: Select all
\documentclass[english]{article}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{blindtext}
\makeatletter
\@addtoreset{page}{section}
\def\@stpelt#1{\global\csname c@#1\endcsname\expandafter\ifx\csname c@#1\endcsname\c@page\@ne\else\z@\fi}
\def\thepage{\thesection--\@arabic\c@page}
\makeatother
\begin{document}
\tableofcontents
\Blinddocument
\Blinddocument
\end{document}
A similar hack is
Code: Select all
\makeatletter
\@addtoreset{page}{section}
\def\thepage{\thesection--\number\numexpr\c@page+1\relax}
\makeatother
Re: custom page numbers?
Thanks, that did the it for me. Just what I was looking for.