🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.text
Article #4943

Re: Page Numbers & Table of Contents in LaTeX

#4943
From: Tom Lane
Date: Tue, 26 Jul 1988 15:39
82 lines
3316 bytes
In article <1369@aplcomm.jhuapl.edu>, jw@aplvax.jhuapl.edu (Jeff Wong) writes:
> 	I am currently creating a new document style which requires that the
> page numbers be the section number with the page number of that section attached,
> for example, 2-4, or page four of section two.  This style carries over in the
> appendixes of this type of document such that I will end up with page numbers
> like B-2.  The document style which I am using as a basis is the 'article'
> document style.  I have created a new counter which is implemented as each new
> section is called and in my page style it specifies...
> 
> 	Amanda S. Hanes (using J.W.'s account)

Actually, you shouldn't be changing the page style at all.  What you want to
mess with is the \thepage macro, which defines how the page number is
displayed.  Fixing that will automatically fix your table of contents, *and*
page cross-references, etc.

It turns out to be a bit more complicated than that, because you also need
to make sure the page number counter is reset at the right times.  Here
is the solution I used recently:


\makeatletter

%%%%% Number pages in style chapter-page.
% This is invoked by \bychapterhack, rather than \pagenumbering{bychapter}.
% The command must be placed in the root file, not an include file.

\newif\if@bychapter \@bychapterfalse

\def\bychapterhack{\@bychaptertrue\def\thepage{\thechapter-\@arabic\c@page}}

\def\chapter{\cleardoublepage   % Start new right-hand page.
%  \thispagestyle{plain}     % Page style of chapter page is 'plain'
   \if@bychapter \setcounter{page}{1}\fi
   \global\@topnum\z@        % Prevents figures from going at top of page.
   \@afterindentfalse           % Suppress indent in first paragraph.  Change
   \secdef\@chapter\@schapter}  % to \@afterindenttrue to cause indent.

\def\appendix{\cleardoublepage	% Get to RH page before changing chapter!
 \setcounter{chapter}{0}
 \setcounter{section}{0}
 \count2=1                   % Mark DVI file pages
 \def\@chapapp{Appendix}
 \def\thechapter{\Alph{chapter}}}

\def\@pnumwidth{2.5em}          % page number width in table of contents

\countdef\c@chapter=1           % put chapter number into DVI file pages

\makeatother

(Omit the \makeatletter and \makeatother if you put this in a .sty file.)

The document that goes with this looks like so:

\pagenumbering{roman}

title page, \tableofcontents, etc.

\cleardoublepage

\bychapterhack

\chapter{the first}

etc. etc.

\appendix

\chapter{the first appendix}

etc. etc.


This was based on "book" style, but I think it would need no changes
for "article" style.

-- 
				tom lane
Internet: tgl@zog.cs.cmu.edu
UUCP: <your favorite internet/arpanet gateway>!zog.cs.cmu.edu!tgl
BITNET: tgl%zog.cs.cmu.edu@cmuccvma
Technical Details
Message-ID: <2399@pt.cs.cmu.edu>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!lll-winken!lll-tis!helios.ee.lbl.gov!nosc!ucsd!rutgers!rochester!pt.cs.cmu.edu!zog.cs.cmu.edu!tgl
References: <1369@aplcomm.jhuapl.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!lll-winken!lll-tis!helios.ee.lbl.gov!nosc!ucsd!rutgers!rochester!pt.cs.cmu.edu!zog.cs.cmu.edu!tgl
From: tgl@zog.cs.cmu.edu (Tom Lane)
Newsgroups: comp.text
Subject: Re: Page Numbers & Table of Contents in LaTeX
Summary: I did that just recently.
Message-ID: <2399@pt.cs.cmu.edu>
Date: 26 Jul 88 15:39:06 GMT
References: <1369@aplcomm.jhuapl.edu>
Sender: netnews@pt.cs.cmu.edu
Distribution: na
Organization: Carnegie-Mellon University, CS/RI
Lines: 81