The count1to package^{∗}^{†}

Martin Schröder

Crüsemannallee 3 D-28213 Bremen Martin.Schroeder@ACM.org

                               PGP-Key:  2048 bit / KeyID 292814E5
                            7E86 6EC8 97FA 2995  82C3 FEA5 2719 090E

1999/06/08

Abstract

This package sets \count1 to \count8 with the values of page to subparagraph. \count9 is used to flag odd pages. The values of these counters are displayed and written in the .dvi file by TEX and can later be used to select the pages of certain parts of the document for printing if the device driver supports this.

It also gives access to the total number of pages of the document via the

     label TotalPages.

Contents

1 Introduction 1

2 Options 3 3 Required packages 3

4 Acknowledgements 3

1 Introduction

Most of the time users want to print only certain parts of a document; but these can only be selected by using the page numbers of these parts with most device drivers. This can be difficult or impossible if pages in different parts of the document have the same number—e. g. in the frontmatter and the first text pages (iii vs. 3).

TEX provides an easy solution to this problem: whenever a page is completed by the output routine and shipped out via \shipout, it displayes the values of \count0 to \count9 on the display (e. g. [1]) and writes them to the .dvi file.

“The first ten \count registers, \count0 to \count9, are reserved for a special purpose: TEX displays these ten counts on your terminal whenever ouputting a page, and it transmits them to the output file as an identification of that page. The counts are separated by decimal points on your terminal, with trailing ‘.0’ patterns suppressed. Thus, for example, if \count0=5 and \count2=7 when a page is shipped out to the dvi file, and if the other counters are zero, TEX will type ‘[5.0.7]’. Plain TEX uses \count0 for the page number, and it keeps \count1 through \count9 equal to zero; that is why you see ‘[1]’ when page 1 is being output. In more complex applications the page numbers can have further structure; ten counts are shipped out so that there will be plenty of identification.”[2, p. 119]

∗The version umber of this file is v1.22, last revised 1999/06/08.

The name count1to is a tribute to the 8+3 file-naming convention of certain “operating systems”; strictly speaking it should be count1to9.

†This document has 3 pages.

Surprinsingly, until recently there existed no package for L^{A}TEX that used these \counters although some drivers allow the selection of pages based on other \counts then \count0 (e. g. emTEX).

This package is the solution: It uses the everyshi package[3] to set \count1 to \count9 before each \shipout with these values:

         \count value

0  relative page number (set by L^{A}TEX)
1  absolute page number
2  number of current \part
3  number of current \chapter (0 with article class)
4  number of current \section
5  number of current \subsection
6  number of current \subsubsection
7  number of current \paragraph
8  number of current \subparagraph
9  1 on odd pages, 0 on even pages^{1}

count1to also works with classes that do not define some or all of the sectioning commands and their counters, like letter. Although it is of somewhat little use then :-).

A note for users of this package: When you select the pages of some part of your document with a lower structure than \chapter, remember that only \parts and \chapters start on a new page; if you want to print a complete \section, you should also select the first page of the next \section. Also note that TEX ships out the values of the counters instead of their visual representation (produced with \thecounter), so appendix A sets \count4 to 1 in the article class.

A note for developers of device drivers: Please add support for \count1 to 9 to your programs. It would also be nice if users could easily select the next page(s) after a certain count (something like “*.*.*.*.2+1.*” should be possible for selecting all pages with \count4 ↦ section = 2 plus the first page of section 3).

TotalPages The setting of \count1 with the absolute page number makes it possible to

New feature 1997/11/01

provide the total number of pages of the document (as opposed to the “number” on the last page provided by the lastpage package[1]). By referencing the label TotalPages (e. g. by \ref{TotalPages}) you get the total number of pages the document had at the last run of L^{A}TEX. If you want to use this feature, you should load count1to as the last package in your document because count1to executes some code at \end{document} and has to be sure that its code is the last code executed there.

1If you have a better application for \count9, let me know.

2 Options

The package has no options.

3 Required packages

The package requires the everyshi package[3].

4 Acknowledgements

As usual Rebecca Stiels improved the quality of this documentation. Rolf Niepraschk (niepraschk@ptb.de) provided the idea and the first implementation of the TotalPages label.

References

[1] Jeff Goldberg. The lastpage-package.

   CTAN:tex-archive/macros/latex/contrib/other/lastpage. L^{A}TEX 2ε

package.

[2] Donald E. Knuth. The TEXBook, volume A of Computers and Typesetting. Addison-Wesley, 1986. Eleventh printing, revised, May 1991.

[3] Martin Schröder. The everyshi package.

   CTAN:tex-archive/macros/latex/contrib/supported/ms/everyshi.dtx.

L^{A}TEX 2ε package.