Path: utzoo!dciem!nrcaer!sce!holtz From: holtz@sce.carleton.ca (Neal Holtz) Newsgroups: comp.text Subject: Re: Page numbering by chapter in LaTeX Keywords: LaTeX Message-ID: <640@sce.carleton.ca> Date: 17 Jul 89 14:05:15 GMT References: <31495@ccicpg.UUCP> Reply-To: holtz@sce.UUCP (Neal Holtz) Organization: Systems Eng., Carleton Univ., Ottawa, Canada Lines: 76 In article <31495@ccicpg.UUCP> swonk@ccicpg.UUCP (Glen Swonk) writes: >I would like to write a large document in pieces, >so that each chapter can be compiled/debugged separately. > >What I would like is a page numbering scheme that the page number >would restart at the beginning of each chapter ... [stuff deleted] The way I did it was to redefine the LaTeX \chapter command to execute a user-defined "hook" at the right place for each new chapter (i.e., after the double page has been flushed, but before the title is set), as shown in this fragment from my style file (which modifies the "book" style): %%%%%%%%%%%%%%%% begin "mybook.sty" %%%%%%%%%%%%%%%% \input book.sty % add "\everychapter" hook for use at every \chapter command \def\everychapter#1{\gdef\@everychapter{#1}} \def\@everychapter{} % redefine the \chapter command to include the "hook" \def\chapter{\cleardoublepage \thispagestyle{plain} \global\@topnum\z@ \@afterindentfalse \@everychapter \secdef\@chapter\@schapter} %%%%%%%%%%%%%%%% end "mybook.sty" %%%%%%%%%%%%%%%% Then I can use that hook to automatically reset the page counter at the beginning of every chapter. In the following example, note that the preface section uses lower cases roman numerals for page numbers (as set by the first "\renewcommand"), while the main body uses chapter--page numbers (as set by the second "\renewcommand"): %%%%%%%%%%%%%%%% begin "thebook.tex" %%%%%%%%%%%%%%%% \documentstyle{mybook} \begin{document} % preface section - roman numeral page nums \renewcommand{\thepage}{\roman{page}} \include{titlepage} \include{contents} \include{preface} % main body - number pages within chapters \renewcommand{\thepage}{\thechapter--\arabic{page}} \everychapter{\setcounter{page}{1}} \include{introduction} % ch1 \include{structural} % ch2 \include{surveying} % ch3 %% ... etc. %%%%%%%%%%%%%%%% end "thebook.tex" %%%%%%%%%%%%%%%% The "\include"ed files simply start the "\chapter" commands -- there is nothing special in them. And the table of contents is correct, automatically. By the way, I have a modified version of an old version of an index sort/merge program distributed by the Free Software Foundation that works with page numbers of this type. Source available, of course. -- ------------------------------------------ Prof. Neal Holtz Dept. of Civil Engineering / Carleton University / Ottawa