[comp.text] Looking for style for numbering pages by chapter

khc@eecea.eece.ksu.edu (Ken Carpenter) (12/29/89)

I recall seeing some discussion earlier about ways to cause LaTeX to
number pages within chapters and still preserve this in the table
of contents.  (Page numbers like, e.g., 3-5, for the 5th in chpt.3.)
I can't locate the discussions in files saved here, could someone
please point me to a source of them.  Thanks.

Ken Carpenter:  khc@eecea.eece.ksu.edu
                ...!rutgers!ksuvax1!eecea!khc

chris@mimsy.umd.edu (Chris Torek) (12/29/89)

In article <915@eecea.eece.ksu.edu> khc@eecea.eece.ksu.edu
Ken Carpenter) writes:
>I recall seeing some discussion earlier about ways to cause LaTeX to
>number pages within chapters and still preserve this in the table
>of contents.  (Page numbers like, e.g., 3-5, for the 5th in chpt.3.)

At the least, you need to:
 a) tell LaTeX to how to write page numbers:
	\def\thepage{\arabic{chapter}--\arabic{\page}}

 b) make LaTeX reset \c@page on changing chapters:
	% \@addtoreset{page}{chapter}
	% the above does not work, since LaTeX wants the page number
	% to start at 1, not zero.  Instead, we redefine \cl@chapter
	% directly:
	{\let\@elt\relax\xdef\cl@chapter{\cl@chapter\global\c@page=1\relax}}

As a nicety, useful with dviselect, it helps to adjust the counter usage
as well:
	\countdef\c@chapter=0	% use \count0 for chapter ...
	\countdef\c@page=1	% and \count1 for page within chapter
	\c@chapter=0 \c@page=1	% accomodate LaTeX's counting peculiarities

Putting the above commands in a style file will suffice for simple tasks:

	% cat c-p.sty
	\countdef\c@chapter=0 \countdef\c@page=1 \c@chapter=0 \c@page=1
	{\let\@elt\relax\xdef\cl@chapter{\cl@chapter\global\c@page=1\relax}}
	\def\thepage{\arabic{chapter}--\arabic{page}}
	% 

Something fancier is probably needed if the LaTeX program uses
\pagestyle.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris@cs.umd.edu	Path:	uunet!mimsy!chris

khc@eecea.eece.ksu.edu (Ken Carpenter) (12/30/89)

The way to get page numbering by chapter, which also gets included
in the table of contents, is to put the following line just before
the first \chapter command:
\renewcommand{\thepage}{\thechapter-\arabic{page}}
and then place the following command before each succeeding \chapter:
\setcounter{page}{1}
Sorry to have bothered the net with such a simple question.