Page Layout ⇒ custom page numbers?
custom page numbers?
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?
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
Re: custom page numbers?
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?
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?
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