Page LayoutComplicated page numbering!

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
pooley343
Posts: 17
Joined: Mon Oct 20, 2008 2:53 pm

Complicated page numbering!

Post by pooley343 »

Hello to you all,

I need some help with some page numbering.

I am writing a report which has three distint sections:

1. Pre-report (Table of Contents, Revision History etc) page numbering in lower case roman
2. Main Report (Section 1, Section 2 etc) page numbering in arabic starting at 1.
3. Appendices (Appendix A, Appendix B) page numbering as appendix A1, A2, A3 for Appendix A, B1, B2, B3 for Appendix B and so on.

I have been able to do all this, including getting the toc to work (which wasn't easy) but I am taking this a step further.

I also want to add the total number of pages (in the header) so say the pre-report is 5 pages, report is 20, appendix is 5. I want a way of saying page 1 of 30 which will work even when I reset the page count at the start of the report.

I know that this is complicated and I would really appreciate the help.

Thanks.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Complicated page numbering!

Post by gmedina »

perhaps the lastpage package could be useful.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
pooley343
Posts: 17
Joined: Mon Oct 20, 2008 2:53 pm

Complicated page numbering!

Post by pooley343 »

No, I have tried that, unfortunately because I am resetting the page number at the start of the main report and the appendices are number A1, A2, B1, B2 so the \lastpage gives "Page 10 of B2" for example.

What I need is a way of getting the total number of pages. I was thinking about maybe some counter to do it but I don't know how to program that.
mas
Posts: 226
Joined: Thu Dec 04, 2008 4:39 am

Complicated page numbering!

Post by mas »

pooley343 wrote:What I need is a way of getting the total number of pages. I was thinking about maybe some counter to do it but I don't know how to program that.
You can try this in the preamble :

Code: Select all

\usepackage{everyshi}
\makeatletter
\let\totalpages\relax
\newcounter{mypage}
\EveryShipout{\stepcounter{mypage}}
\AtEndDocument{\clearpage
   \immediate\write\@auxout{%
    \string\gdef\string\totalpages{\themypage}}}
\makeatother
\totalpages will give you the total page count.

Regards,

sridhar

OS: Debian/GNU Linux; LaTeX System : TeXLive; Editor : Vim
Post Reply