diff options
author | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
commit | e0c6872cf40896c7be36b11dcc744620f10adf1d (patch) | |
tree | 60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/selectp |
Initial commit
Diffstat (limited to 'macros/latex/contrib/selectp')
-rw-r--r-- | macros/latex/contrib/selectp/selectp-doc.pdf | bin | 0 -> 276547 bytes | |||
-rw-r--r-- | macros/latex/contrib/selectp/selectp-doc.tex | 197 | ||||
-rw-r--r-- | macros/latex/contrib/selectp/selectp.sty | 235 |
3 files changed, 432 insertions, 0 deletions
diff --git a/macros/latex/contrib/selectp/selectp-doc.pdf b/macros/latex/contrib/selectp/selectp-doc.pdf Binary files differnew file mode 100644 index 0000000000..bafae6dc58 --- /dev/null +++ b/macros/latex/contrib/selectp/selectp-doc.pdf diff --git a/macros/latex/contrib/selectp/selectp-doc.tex b/macros/latex/contrib/selectp/selectp-doc.tex new file mode 100644 index 0000000000..c85c430ceb --- /dev/null +++ b/macros/latex/contrib/selectp/selectp-doc.tex @@ -0,0 +1,197 @@ +\documentclass[pagesize=auto, fontsize=12pt]{scrartcl} + +\usepackage{fixltx2e} +\usepackage{etex} +\usepackage{lmodern} +\usepackage[T1]{fontenc} +\usepackage{textcomp} +\usepackage{hologo} +\usepackage{microtype} +\usepackage{hyperref} + +\newcommand*{\mail}[1]{\href{mailto:#1}{\texttt{#1}}} +\newcommand*{\pkg}[1]{\textsf{#1}} +\newcommand*{\cs}[1]{\texttt{\textbackslash#1}} +\makeatletter +\newcommand*{\cmd}[1]{\cs{\expandafter\@gobble\string#1}} +\makeatother +\newcommand*{\opt}[1]{\texttt{#1}} +\newcommand*{\meta}[1]{\textlangle\textsl{#1}\textrangle} +\newcommand*{\marg}[1]{\texttt{\{}\meta{#1}\texttt{\}}} +\newcommand*{\outputonly}[1]{\cmd{\outputonly}\texttt{\{#1\}}} + +\addtokomafont{title}{\rmfamily} + +\title{The \pkg{selectp} package\thanks{This manual corresponds to \pkg{selectp}~v1.0, dated~Sept 25, 1992.}} +\subtitle{Select pages for output} +\author{% + Donald Arseneau\thanks{\mail{asnd@triumf.ca}},% + \and based on macros in TUGBoat, 8:2 (1987), p.~217% + \and written by Don Knuth,% + \and and with suggestions from Hossein Saiedian.% +} +\date{Sept 25, 1992} + + +\begin{document} + +\maketitle + + +\section{Instructions} + +This style file defines the command \cmd{\outputonly} which selects specific +pages for output, much as \cmd{\includeonly} selects certain files for input. +To use \pkg{selectp.sty} in \LaTeX, specify \opt{selectp} as one of the document +style options and give the command \cmd{\outputonly}\marg{list of page numbers} +before \verb|\begin{document}|. Only pages given in the list will be output +to the DVI file. For example +% +\begin{verbatim} + \documentstyle[12pt,selectp,subeqn]{article} + \outputonly{1,3, 7-12 16 17} +\end{verbatim} +% +which will allow only pages 1, 3, 7, 8, 9, 10, 11, 12, 16, 17 to be output. +For \hologo{plainTeX}, use \verb|\input{selectp.sty}|. + +The number list should consist of numbers and number ranges (\verb|7-12|, e.\,g.)\ % +separated by commas or spaces. The order is not random but \emph{must be the +order that the pages are produced}; normally this means the numbers must +always increase. If an invalid page number appears on the list, no pages +will be output until the list is re-synchronized or the document ends. + +Any time the document's page number does not increment normally, +\pkg{selectp.sty} tries to re-synchronize the page number with the \cmd{\outputonly} +list of numbers. This is necessary when \cmd{\includeonly} is used. + +Pages that are labeled with roman numerals or letters should still be +listed with a normal arabic number; page~xi should be referred to as~6. + +In \LaTeX, unfortunately, pages~i and~1 are both number~1, so it is +tricky to skip over all the roman-numbered pages and then print +page~1. If there are 3 roman-numbered pages, +% +\begingroup +\addtokomafont{labelinglabel}{\ttfamily} +\begin{labeling}{1-3,8-12} +\item[1-3] + will print pages i, ii, iii; not pages 1, 2, 3 +\item[1-3,1-5] + will print pages i, ii, iii, 1, 2, 3, 4, 5 +\item[1-3,8-12] + will print pages i, ii, iii, 8, 9, 10, 11, 19 +\item[1,1-5] + will print i, 1, 2, 3, 4, 5 +\item[1-6] + prints pages i, ii, iii only, not pages 4, 5, 6 !!! +\item[0,2-6] + prints pages 2, 3, 4, 5, 6, since there is no page~0 and the + \verb|outputonly| page list is resynchronized when the actual page + number goes back to~1) +\end{labeling} +\endgroup +% +The last example is illuminating. \LaTeX\ looks for page~0, but can't find +it. It skips pages until the page number goes from~3~(iii) to~1, at which +point it resynchronizes by reading~\texttt{2} from the list, waiting for page~2 +to be produced, and then writing page~2. Selectp then reads~\texttt{-6}, and +\emph{Continues} outputting pages until it has done page~6. As long as the +numbers of the intervening pages are less than~6 (the end of the range), +those pages will be printed. + +If there are no roman numeral pages, the number list is simple, because +the numbers must increase monotonically. + +\LaTeX\ will not write auxilliary files while selecting output pages, so +the cross references and citations must be correct on the run \emph{before} +using \cmd{\outputonly}. Unfortunately, this means you must produce the +full-size DVI file at least once. + +If multuple \cmd{\outputonly} commands are given, the lists are concatenated. + +In \hologo{plainTeX}, specify roman numeral pages as negative numbers, but do not +use ranges until getting to the ordinary (arabic) page numbers (e.\,g.,\ % +\outputonly{-1,-2,-3,-4, 1-8}). In \hologo{plainTeX} specifying page~1 will \emph{not} +print page~i. + +If a page number in the list is not found, generally no more pages will be +printed. For example, suppose a document has 50~pages, the list \verb*|3 5 910 13| +(which perhaps should read \verb*|9 10|) causes \LaTeX\ to process silently +through the whole document looking for page~910. Only pages~3 and~5 will +be printed. + +\emph{Except} if the number terminating a \emph{range} is not found \verb*|{3 5-910 13}|, +\LaTeX\ continues outputting pages until the end. + +\emph{Except} if the actual page number changes discontinuously, then the number +list \emph{may} be scanned for the next number greater than the new page number. +(Jumps are usually due to the numbering being changed from roman to arabic +with the page reset to~1, or because an included file was skipped due to +an \cmd{\includeonly} command.) The list is scanned if the page number jumps +backward, or if it jumps forward \emph{past} the current target page. (``Target +page'' = the end of the current range or the next number to be printed out, +as appropriate.) + +Numbers must be integers: \texttt{4.3} is illegal, even if some other style file +is generating page numbers in that format. + +\pagebreak[1] + +Of course non-numbers are illegal. Some plausible mistakes: +% +\begin{quote} + \verb|page|, \verb|xvii|, \verb|IV|, \verb|12--16|, \verb|49ff|, \verb|49-|, \verb|5_7|. +\end{quote} +% +\verb|5_7| could be a typo for the range \verb|5-7|. +To specify page~49 and all following (\verb|49ff| or \verb|49-|), use a range +ending with a non-existent page: \verb|49-99999|. +The typo \verb|12--16| prints pages~12 and~16, not the range~12 through~16 as +intended. + + +\section{Examples of use} + +Suppose a document has pages i, ii, iii, iv, v, vi, 1, 2, 3,\dots, 33, but pages +22\dots28 are absent due to \cmd{\includeonly}; here are some examples of valid +uses of \cmd{\outputonly}. +% +\begin{labeling}[\enspace\textendash]{\outputonly{0,4,23-27,31-99}} +\item[\outputonly{15-20}] + prints only the 6 pages 15...20 +\item[\outputonly{1-3}] + prints pages i, ii, iii (in \LaTeX)\\ + \hologo{plainTeX} prints pages 1, 2, 3 +\item[\outputonly{1,1,2}] + prints pages i, 1, 2 +\item[\outputonly{0,1,2}] + prints pages 1, 2 +\item[\outputonly{1,3-6}] + prints pages i, iii, iv, v, vi +\item[\outputonly{4,3-6}] + prints pages iv, 3, 4, 5, 6 +\item[\outputonly{5,2}] + prints pages v, 2 +\item[\outputonly{5-2}] + prints only page v only! +\item[\outputonly{5-7}] + prints pages v, vi only! +\item[\outputonly{1-33}] + prints pages i, ii, iii, iv, v, vi only! +\item[\outputonly{29-99}] + prints pages 29, 30, 31, 32, 33 +\item[\outputonly{19-99}] + prints pages 19, 20, 21, 29, 30, 31, 32, 33 +\item[\outputonly{24-32}] + prints pages 29, 30, 31, 32 +\item[\outputonly{15-25,32}] + prints pages 15, 16, 17, 18, 19, 20, 21, 32 +\item[\outputonly{0,4,23-27,31-99}] + prints pages 4, 31, 32, 33 +\end{labeling} + +Version 0.9 (test), Sept 25, 1992: +Send problem reports to \mail{asnd@triumf.ca} + +\end{document} diff --git a/macros/latex/contrib/selectp/selectp.sty b/macros/latex/contrib/selectp/selectp.sty new file mode 100644 index 0000000000..7ded64bcb1 --- /dev/null +++ b/macros/latex/contrib/selectp/selectp.sty @@ -0,0 +1,235 @@ +% +% S E L E C T P . S T Y - Select pages for output +% +% Version 1.0 Sept 25, 1992 +% +% By Donald Arseneau, asnd@triumf.ca, based on macros in +% TUGBoat, 8:2 (1987), p. 217 written by Don Knuth, and with +% suggestions from Hossein Saiedian. +% +% Copyright 1992, Donald Arseneau +% This software is contributed freely to the public domain. +% +% This style allows selection of individual pages to be output by LaTeX +% or plain TeX by specifying, for example, +% +% \outputonly{1,3, 7-12 16 17} +% +% The list of numbers should be in the order that TeX generates the pages. +% The numbers should be separated by commas or spaces, and may include +% ranges (7-12). +% +% More complete instructions follow \endinput + + +% First, set catcode of @ in case it isn't a "letter" already +\expandafter\edef\csname SP@catcode\endcsname + {\catcode`\noexpand\@=\the\catcode`\@ + \let \csname SP@catcode\endcsname \noexpand\UnDefinedButNoAt} +\catcode`\@=11 + +% Allow plain TeX to use this style: + +\ifx\c@page\Und@Fynd + \let\c@page \pageno + \def\@empty{}% note: \ifx ignores the \global nature of macros for comparison + \let\nofiles\relax + \let\typeout\message +\fi + +% Read list of selected pages + +\def\outputonly{\begingroup \catcode`\,13 \SP@outonly} + +\begingroup \catcode`\,13 +\gdef\SP@outonly#1{\edef,{\string,}\typeout{Only pages #1 will be output.}% + \def,{ }\xdef\SP@geS{\SP@geS\space #1}% make commas be spaces + \endgroup + \nofiles % prevent writing partial .aux files + \let\shipout\SP@shipout% replace shipout command + \ifnum\SP@nextpage=-\maxdimen % if first \outputonly command... + \SP@getnextpage \fi % get first page number from list +}\endgroup + +\gdef\SP@geS{} + +% replace \shipout command with filter to select pages for output + +\let\plain@shipout=\shipout + +\newcount\SP@nextpage \global\SP@nextpage=-\maxdimen % flag as undefined +\newcount\SP@expectpage \global\SP@expectpage=-\maxdimen + +\def\SP@getnextpage{\ifx\SP@geS\@empty \global\SP@nextpage\maxdimen + \else % If more page numbers on list + \afterassignment\SP@updPS \global\SP@nextpage\SP@geS\relax + \fi} + +\def\SP@updPS#1\relax{\gdef\SP@geS{#1}} + +\def\SP@shipout{\relax %\showthe\c@page% + \ifnum\SP@expectpage=-\maxdimen \global\SP@expectpage\c@page + \else \global\advance\SP@expectpage\@ne + \fi + \ifnum\SP@expectpage=\c@page\else % page number has jumped, + \ifnum\SP@nextpage<\z@ % if in middle of a range -- + \ifnum \AbsVal\c@page >\AbsVal\SP@expectpage\else % and jumping backward -- + \SP@getnextpage % read next number for sure + \fi\fi + \SP@catchup % Resynchronize + \fi \global\SP@expectpage\c@page + \ifnum\SP@nextpage<\z@ % either a `negative' page, or end of range + \ifnum\c@page<\z@ % preamble pages in plain only match singly + \ifnum\c@page=\SP@nextpage\SP@getnextpage \let\SP@dopage\plain@shipout\fi + \else % look for range match + \ifnum\c@page>-\SP@nextpage \else \let\SP@dopage\plain@shipout \fi + \ifnum\c@page<-\SP@nextpage \else \SP@getnextpage \fi + \fi + \else % look for single match + \ifnum\c@page=\SP@nextpage \SP@getnextpage \let\SP@dopage\plain@shipout \fi + \fi \SP@dopage} + +\newbox\SP@garbage +\def\SP@dopage{\deadcycles\z@ \setbox\SP@garbage=} + +% read list of desired pages to get resynchronized with actual page numbers. +% \SP@catchup is called whenever the page number has a discontinuity. +% +\def\SP@catchup{% + \ifnum \AbsVal\c@page >\AbsVal\SP@nextpage + \ifx\SP@geS\@empty \def\SP@catchup{\global\SP@nextpage\maxdimen}\fi + \SP@getnextpage + \expandafter \SP@catchup + \fi} + +% take absolute value of TeX number or dimension +\def\AbsVal#1{\ifnum#1<\z@-\fi#1} + +\SP@catcode % restore @ catcode + +\endinput +% +% SELECTP.STY -- Select pages for output +% +% INSTRUCTIONS +% +% This style file defines the command \outputonly which selects specific +% pages for output, much as \includeonly selects certain files for input. +% To use selectp.sty in LaTeX, specify "selectp" as one of the document +% style options and give the command \outputonly{_list_of_page_numbers_} +% before \begin{document}. Only pages given in the list will be output +% to the DVI file. For example +% +% \documentstyle[12pt,selectp,subeqn]{article} +% \outputonly{1,3, 7-12 16 17} +% +% which will allow only pages 1,3,7,8,9,10,11,12,16,17 to be output. +% For plain TeX, use \input{selectp.sty}. +% +% The number list should consist of numbers and number ranges (7-12, e.g.) +% separated by commas or spaces. The order is not random but MUST BE THE +% ORDER THAT THE PAGES ARE PRODUCED; normally this means the numbers must +% always increase. If an invalid page number appears on the list, no pages +% will be output until the list is re-synchronized or the document ends. +% +% Any time the document's page number does not increment normally, +% selectp.sty tries to re-synchronize the page number with the \outputonly +% list of numbers. This is necessary when \includeonly is used. +% +% Pages that are labeled with roman numerals or letters should still be +% listed with a normal arabic number; page xi should be referred to as 6. +% +% In LaTeX, unfortunately, pages i and 1 are both number 1, so it is +% tricky to skip over all the roman-numbered pages and then print +% page 1. If there are 3 roman-numbered pages, +% 1-3 will print pages i,ii,iii; not pages 1,2,3 +% 1-3,1-5 will print pages i,ii,iii,1,2,3,4,5 +% 1-3,8-12 will print pages i,ii,iii,8,9,10,11,19 +% 1,1-5 will print i,1,2,3,4,5 +% 1-6 prints pages i,ii,iii only, not pages 4,5,6 !!! +% 0,2-6 prints pages 2,3,4,5,6, since there is no page 0 and the +% outputonly page list is resynchronized when the actual page +% number goes back to 1) +% +% The last example is illuminating. LaTeX looks for page 0, but can't find +% it. It skips pages until the page number goes from 3(iii) to 1, at which +% point it resynchronizes by reading "2" from the list, waiting for page 2 +% to be produced, and then writing page 2. Selectp then reads "-6", and +% CONTINUES outputting pages until it has done page 6. As long as the +% numbers of the intervening pages are less than 6 (the end of the range), +% those pages will be printed. +% +% If there are no roman numeral pages, the number list is simple, because +% the numbers must increase monotonically. +% +% LaTeX will not write auxilliary files while selecting output pages, so +% the cross references and citations must be correct on the run BEFORE +% using \outputonly. Unfortunately, this means you must produce the +% full-size DVI file at least once. +% +% If multuple \outputonly commands are given, the lists are concatenated. +% +% In plain TeX, specify roman numeral pages as negative numbers, but do not +% use ranges until getting to the ordinary (arabic) page numbers (e.g., +% \outputonly{-1,-2,-3,-4, 1-8}). In plain TeX specifying page 1 will NOT +% print page i. +% +% If a page number in the list is not found, generally no more pages will be +% printed. For example, suppose a document has 50 pages, the list 3 5 910 13 +% (which perhaps should read "9 10") causes LaTeX to process silently +% through the whole document looking for page 910. Only pages 3 and 5 will +% be printed. +% +% EXCEPT if the number terminating a RANGE is not found {3 5-910 13}, +% LaTeX continues outputting pages until the end. +% +% EXCEPT if the actual page number changes discontinuously, then the number +% list MAY be scanned for the next number greater than the new page number. +% (Jumps are usually due to the numbering being changed from roman to arabic +% with the page reset to 1, or because an included file was skipped due to +% an \includeonly command.) The list is scanned if the page number jumps +% backward, or if it jumps forward PAST the current target page. ("Target +% page" = the end of the current range or the next number to be printed out, +% as appropriate.) +% +% Numbers must be integers: 4.3 is illegal, even if some other style file +% is generating page numbers in that format. +% +% Of course non-numbers are illegal. Some plausible mistakes: +% page, xvii, IV, 12--16, 49ff, 49-, 5_7. +% 5_7 could be a typo for the range 5-7. +% To specify page 49 and all following ("49ff" or "49-"), use a range +% ending with a non-existent page: 49-99999. +% The typo 12--16 prints pages 12 and 16, not the range 12 through 16 as +% intended. +% +% EXAMPLES OF USE +% +% Suppose a document has pages i,ii,iii,iv,v,vi,1,2,3,...,33, but pages +% 22...28 are absent due to \includeonly; here are some examples of valid +% uses of \outputonly. +% +% \outputonly{15-20} -- prints only the 6 pages 15...20 +% \outputonly{1-3} -- prints pages i,ii,iii (in LaTeX) +% -- plain TeX prints pages 1,2,3 +% \outputonly{1,1,2} -- prints pages i,1,2 +% \outputonly{0,1,2} -- prints pages 1,2 +% \outputonly{1,3-6} -- prints pages i,iii,iv,v,vi +% \outputonly{4,3-6} -- prints pages iv,3,4,5,6 +% \outputonly{5,2} -- prints pages v,2 +% \outputonly{5-2} -- prints only page v only! +% \outputonly{5-7} -- prints pages v,vi only! +% \outputonly{1-33} -- prints pages i,ii,iii,iv,v,vi only! +% \outputonly{29-99} -- prints pages 29,30,31,32,33 +% \outputonly{19-99} -- prints pages 19,20,21,29,30,31,32,33 +% \outputonly{24-32} -- prints pages 29,30,31,32 +% \outputonly{15-25,32} -- prints pages 15,16,17,18,19,20,21,32 +% \outputonly{0,4,23-27,31-99} -- prints pages 4,31,32,33 +% +% Version 0.9 (test), Sept 25, 1992: +% +% Send problem reports to asnd@triumf.ca +% +% test integrity: +% brackets: round, square, curly, angle: () [] {} <> +% backslash, slash, vertical, hat, tilde: \ / | ^ ~ |