[comp.text] page selection in dvi files

chris@mimsy.UUCP (Chris Torek) (08/05/89)

[This refers to TeX .dvi files, not ditroff output files]

In article <66475@yale-celray.yale.UUCP> leichter@CS.YALE.EDU
(Jerry Leichter) writes:
>Page ranges [in dvijep] are selected with the -o option, whose syntax is:
>
>	-o<first>:<last>:<step>
>
>where <first> is the PHYSICAL page number of the first page to print, <last>
>is the corresponding last page, and <step> is the inter-page increment.
>... (In case you are wondering why <step> is there: If foo is two-sided,
>then you do dvijep -o1:9999:2 to print the "odd pages", stick the paper
>back into the printer, and do dvijep -o2:9999:2 to print the corresponding
>even pages.) ... By a "physical page number", I mean just that:  Count
>pages, don't look at TeX's page numbers.

I might as well post this now. . . :

Last night (or rather, this morning, around 2 or 3 AM) I added `even'
and `odd' selection to dviselect.  The syntax for dviselect is now

	dviselect list-of-pages [ infile [ outfile ] ]

(Unix redirection is normally used for the in and out files).  A list
of pages is a whitespace-separated list of selectors.  An individual
selector has one of the following forms:

	=range
	range
	range.range
	range.range.range

(etc., up to ten ranges).  Each range is one of the forms

	first:last		(the numbers first through last, inclusive)
	first:			(first through infinity)
	:last			(-infinity through last)
	*			(-infinity through +infinity, i.e., any value)
	even			(all even values)
	odd			(all odd values)

A bare colon or an empty string (between two periods) is the same as a
range of `*'.  All numbers are 32 bit integers, and may be negative, but
negative numbers must be given with `_' instead of `-' (this is a historic
artifact).

Each <range> value is applied to the corresponding \count register,
except that a range in an `=' selector applies to the physical page
number.  A page is selected if all of its \count registers (or its
physical page number) matches at least one selector.  Thus, if you add

	\makeatletter \countdef\c@chapter=1 \makeatother

to a LaTeX file that uses the `book' or `report' styles,

	dviselect .1:3

selects everything in chapters 1 through 3 (since \count1 holds the
chapter number).  To get the *physically* even-numbered pages, use

	dviselect =even

If you want the pages whose \count0 value is even, use

	dviselect even

Since `even' is just another range, you can get the odd numbered
chapters with

	dviselect .odd

given the \countdef above.

I have never actually come across a need for selecting every n'th page
(other than even/odd, for two-sided printing), but if enough people
want it, I will add it to dviselect before the next release.  Note that
it would fit into any <range> slot (to be matched against any of the
ten \count registers or against the physical page number).  The likely
syntax is an optional third `:number'.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris@mimsy.umd.edu	Path:	uunet!mimsy!chris