% LATEX VERSION 0.9 - FOR USE WITH TEX VERSION 0.95 \immediate\write10{ LATEX Version 0.9 - for use with TeX version 0.95 } % THINGS TO BE DONE TO LATEX % % - make blank lines have no effect in tabbing, tabular and array environments % by setting \par = \relax % - add \clearpagestyle{STYLE} command to set the style % used by \clearpage when putting out left-hand page in % twoside style. % - rename and redefine \~ifundefined to be Knuth's \ifundefined % - rename \~leftbrace & \~rightbrace to \lb and \rb. % - change the hack in the array and tabular environments as per % message from DEK. % - name changes: % - change \theend so it looks for unended \begin's % - change \cite so you can type \cite{foo,bar} to get % [13,7]. Requires adding a document-style-defined macro to generate % the [ and ]. % **************************************** % * THE LATEX MACRO PACKAGE * % **************************************** % % % CONTENTS % ======== % % % USEFUL HACKS % FILE HANDLING % SPECIAL SYMBOLS % PROGRAM CONTROL STRUCTURE MACROS % SPACING AND BOXES % PAGE NUMBERING % ENVIRONMENT COUNTER MACROS % CROSS REFERENCING MACROS % NUMBERING MACROS % TABLE OF CONTENTS, ETC. % ENVIRONMENTS % MATH ENVIRONMENTS % \par and \everypar % THE LIST ENVIRONMENT % LIST-MAKING ENVIRONMENTS % THEOREM ENVIRONMENTS % THE TABBING ENVIRONMENT % THE PICTURE ENVIRONMENT % CENTER, FLUSHRIGHT, FLUSHLEFT % EXAMPLE % FOOTNOTES % PAGE AND LINE BREAKING % FIGURES AND TABLES % MISCELLANEOUS % INITIAL DECLARATION COMMANDS % ARRAY MACROS % INDEX COMMANDS % THE OUTPUT ROUTINE % BIBLIOGRAPHY % DEBUGGING % INITIALIZATIONS \catcode`\~=11 % ~ is defined to be a letter % **************************************** % * USEFUL HACKS * % **************************************** % % \namegdef{name}{definition} : the same as \gdef\name{definition}, except % that ``name'' can contain nonletters. % \namedef{name}{definition} : analogous % \pnamedef{name}{parms}{def} : the same as \def\name parms{def}, where % parms are the parameter specification -- % e.g., as in \pnamedef{foo}{#1}{\bar{#1}} % \backslash{name} : the same as \name. % % \warning{message} : produces a warning message on the terminal % % \typein : asks the user to type in a command, then % executes it \newwrite\~unused \def\typein#1{\warning{#1}\read0 \~typein\~typein\ifhmode \unskip\fi} \def\warning#1{\immediate\write\~unused{}\message{#1}} \def\namegdef#1#2{\expandafter\gdef\csname #1\endcsname{#2}} \def\namedef#1#2{\expandafter\def\csname #1\endcsname{#2}} \def\pnamedef#1#2#3{\expandafter\def\csname #1\endcsname #2{#3}} \def\backslash#1{\csname #1\endcsname} % **************************************** % * FILE HANDLING * % **************************************** % % \jobname = name of main file, minus extension -- e.g., it equals % foo when TeXing foo.tex. For TeX version 0.9, must be % defined by user at beginning of file. % \~mainaux = output file number for main .AUX file % \~partaux = output file number for current part's .AUX file. % \~auxout = either \~mainout or \~partout, depending on which .AUX % file output goes to. % \~input{foo} if file foo exists, then \input's it. % If not, types a warning message. % \~tfilesw : set to F if no .TOC, .IDX etc files are to be written. % \~afilesw : set to F if no .AUX files are to be written % \~partsw : set to T by a \doparts command % \~partlist : set to the argument of the \doparts command % % \~cp~FOO : the checkpoint for \included file FOO.TEX, written % by \~checkpoint at the end of file FOO.AUX % % \text == % BEGIN % \begingroup % \~input{\jobname.aux} % \endgroup % if \~afilesw = T % then open file \~mainaux for writing % write ``\relax''on file \~mainaux % fi % END % % \doparts{FILELIST} == % BEGIN % \~partsw := T % \~partlist := FILELIST % \~tfilesw := F % inhibit .TOC, etc. files % END % % \include{FILE} == % BEGIN % \clearpage % if \~afilesw = T % then \immediate\write\~mainaux{\string\~input{FILE.AUX}} % fi % if \~partsw = T % then \~x~inc := F % \~x~b == FILE % for \~x~a := \~partlist % do if eval(\~x~a) = eval(\~x~b) % then \~x~inc := T fi % od % fi % % if \~x~inc = T % then \~auxout := \~partaux % if \~afilesw = T % then \immediate\openout\~partaux{FILE.AUX} % \immediate\write\~partaux{\relax} % fi % \~input{FILE.TEX} % \clearpage % \~checkpoint{FILE} % \~auxout := \~mainaux % else \~cp~FILE % fi % END % % \~checkpoint{FILE} == % BEGIN % if \~afilesw = T % \immediate\write on file \~partaux: % \gdef\~cp~FILE{ %% } % for \~x~a := \~cl~~ckpt % do \immediate\write on file \~partaux: % \string\setcounter{eval(\~x~a)}{eval(\~c~eval(\~x~a))} % od % \immediate\write on file \~partaux: %% { % \setpagenumber{\the\count0}} % fi % END % % INITIALIZATION % \~x~inc := T \def\~tfilesw{T} \def\~afilesw{T} \def\~partsw{F} \def\~x~inc{T} \def\nofiles{\gdef\~tfilesw{F}\gdef\~afilesw{F}\warning {No auxiliary output files.}\warning{}} \newwrite\~mainaux \newwrite\~partaux \def\~input#1{\openin1 #1 \ifeof1 \warning{No file #1.}\else\closein1 \relax\input #1 \fi} \let\~auxout=\~mainaux \def\text{\begingroup\~input{\jobname.aux}\endgroup \if\~afilesw T\immediate\openout\~mainaux=\jobname.aux \immediate\write\~mainaux{\relax}\fi} \def\doparts#1{\def\~partsw{T}\def\~partlist{#1}\def\~tfilesw{F}} \def\include#1{\clearpage \if\~afilesw T\immediate\write\~mainaux{\string\~input{#1.AUX}}\fi \if\~partsw T\def\~x~inc{F}\def\~x~b{#1}\~for \~x~a:=\~partlist\do{\ifx\~x~a\~x~b\gdef\~x~inc{T}\fi}\fi \if\~x~inc T\if \~afilesw T\let\~auxout=\~partaux \immediate\openout\~partaux #1.AUX \immediate\write\~partaux{\relax}\fi\~input{#1.TEX}\clearpage \~checkpoint{#1}\let\~auxout=\~mainaux\else\backslash{~cp~#1}\fi} \def\~checkpoint#1{\if\~afilesw T \immediate\write\~partaux{\string\namegdef{~cp~#1}\~charlb}% \~for\~x~a:=\~cl~~ckpt\do {\immediate\write\~partaux{\string\setcounter{\~x~a}{\backslash{~c~\~x~a}}}}% \immediate\write\~partaux{\string\setpagenumber{\the\count0}\~charrb}\fi} {\catcode`[=1 \catcode`]=2 \catcode`{=11 \catcode`}=11 \gdef\~charlb[{] \gdef\~charrb[}] ]% }brace matching \newbox \~tmpbox % \~tmpbox = box for temporary calculations \newcount\~tmpcnt % \~tmpcnt = \count number for temporary calculations \newdimen\~tmpdim % \~tmpdim = \dimen number for temporary calculations % ********************************************** % * SPECIAL SYMBOLS * % ********************************************** % % DEFINES \\, \{ and \} \let\~slashleftbrace=\{ \let\~slashrightbrace=\} \def\{{\ifmmode\~slashleftbrace\else$\~slashleftbrace$\fi} \def\}{\ifmmode\~slashrightbrace\else$\~slashrightbrace$\fi} % ********************************************** % * PROGRAM CONTROL STRUCTURE MACROS * % ********************************************** % % \~while test \do {body} % \~whilenum test \do {body} % \~whiledim test \do {body} % these implement the loop % while test do body od % where test is a TeX \if, \ifnum or \ifdim test, respectively % \~for name := list \do {body} % assumes that expand(list) = a1,a2, ... ,an % executes body n times, with name = ai on the i-th iteration % % \~tfor name := list \do {body} % if list = t1 ... tn where each ti is a token or {...}, then % executes body n times, with name = ti on the i-th iteration % % NOTE: These macros do not work if the body contains anything that looks % syntactically to TeX like an improperly balanced \if \else \fi -- % e.g., if it has an \~ifundefined ... \fi in it. (This is just one % more example of the way TeX makes it virtually impossible to write general- % purpose macros.) However, you can get around this problem by % \def'ing \~foo to be the desired body and using \~foo in the loop. % % \~whilenum test \do {body} = % if test % then body % \~nextwhile = def(\~whilenum) % else \~nextwhile = def(\~whilenoop) % \def\~whilenoop#1\do#2{} \def\~while#1\do #2{\if #1#2\relax\let\~nextwhile=\~while \else\let\~nextwhile=\~whilenoop\fi\~nextwhile #1\do {#2}} \def\~whilenum#1\do #2{\ifnum #1 #2\relax\let\~nextwhile=\~whilenum \else\let\~nextwhile=\~whilenoop\fi\~nextwhile #1\do {#2}} % \~whiledim test \do {body} = % if test % then body % \~nextwhile = def(\~whiledim) % else \~nextwhile = def(\~whilenoop) % \def\~whiledim#1\do #2{\ifdim #1 #2\relax\let\~nextwhile=\~whiledim \else\let\~nextwhile=\~whilenoop\fi\~nextwhile #1\do {#2}} % \~for name := list \do {body} % = \~forloop expand(list),\nil,\nil =: name \do {body} % % \~forloop car, cdr =: name \do {body} = % name = car % if def(name) = def(\nnil) % then \~nextfor = def(\~whilenoop) % else body ; % \~nextfor = def(\~forloop) % fi % \~nextfor name cdr \do {body} % % \~tfor name := list \do {body} % = \~tforloop list\~nil =: name \do {body} % % \~tforloop car cdr =: name \do {body} = % name = car % if def(name) = def(\nnil) % then \~nextfor == \~whilenoop % else body ; % \~nextfor == \~forloop % fi % \~nextfor name cdr \do {body} % \def\~nnil{\~nil} \def\~empty{} \def\~for#1:=#2\do#3{\xdef\~x~for{#2}\ifx\~x~for\~empty \else \expandafter\~forloop#2,\~nil,\~nil=:#1\do{#3}\fi} \def\~forloop#1,#2=:#3\do#4{\def#3{#1}\ifx #3\~nnil \let\~nextfor=\~whilenoop \else #4\relax\let\~nextfor=\~forloop\fi\~nextfor#2=:#3\do{#4}} \def\~tfor#1:=#2\do#3{\xdef\~x~for{#2}\ifx\~x~for\~empty \else \~tforloop#2\~nil\~nil=:#1\do{#3}\fi} \def\~tforloop#1#2=:#3\do#4{\def#3{#1}\ifx #3\~nnil \let\~nextfor=\~whilenoop \else #4\relax\let\~nextfor=\~tforloop\fi\~nextfor#2=:#3\do{#4}} % ********************************************* % * SPACING AND BOXES * % ********************************************* % % \boxit{TEXT} : puts TEXT into a box, surrounded by a rectangle % with line width \~boxitrule separated from it on % all sides by a space \~boxitsep . % % \rule{WIDTH}{HEIGHT}{POS} : puts a WIDTH X HEIGHT rule POS distance % above the baseline. POS may be negative. % % \dimI : a variable unit setable by the user with the command % % \dimdefI{DIM} : makes 1\dimI = DIM % % \dimofdefI{TEXT} : makes 1\dimI = width of TEXT % % \lboxI{TEXT} : left-justifies TEXT in an \hbox of width 1\dimI % \rboxI{TEXT} : right-justifies TEXT in an \hbox of width 1\dimI % \cboxI{TEXT} : centers TEXT in an \hbox of width 1\dimI % % NOTE: all definitions made by \dimdef and \dimofdef are local to % the current group/environment. % % \~bsphack ... \~esphack % used by macros such as \index that want to be invisible -- i.e., % not leave any extra space when used in the middle of text. Such % a macro should begin with \~bsphack and end with \~esphack % The macro in question should not create any text, nor change the % mode. % % \~bsphack == % BEGIN % \dimen\~savsk := \the\lastskip % if hmode then \~savsf := \the\spacefactor fi % END % % \~esphack == % BEGIN % if hmode % then \spacefactor := \~savsf % if \dimen\~savsk > 0pt then \ignorespaces fi % fi % END % \newdimen\~savsk \def\~bsphack{\setdimen\~savsk=\the\lastskip \ifhmode\edef\~savsf{\the\spacefactor}\fi} \def\~esphack{\ifhmode\spacefactor=\~savsf {}\ifdim \dimen\~savsk > 0pt \ignorespaces \fi \fi} \def\boxit#1{\setbox\~tmpbox=\hbox{#1}\hbox{\lower \~boxitrule \hbox{\lower \~boxitsep\hbox{\lower 1dp\~tmpbox\hbox {\vbox{\hrule height \~boxitrule \hbox{\vrule width \~boxitrule \hskip\~boxitsep \vbox{\vskip\~boxitsep \box\~tmpbox\vskip\~boxitsep}\hskip \~boxitsep\vrule width \~boxitrule} \hrule height \~boxitrule}}}}}} \def\rule#1#2#3{\hbox{\raise #3\vbox{\hrule width #1 height #2 }}} \def\hspace#1{\hskip #1 } \def\hspacer#1{$ $\hbox{\hskip #1}} \def\vspace#1{\ifvmode\vskip #1 \else \vadjust{\vskip #1}\fi} \def\vspacer#1{\ifvmode\vbox{\vskip #1}\else \vadjust{\vbox{\vskip #1}}\fi} \expandafter\newbox\csname ~dim0\endcsname \expandafter\newbox\csname ~dim1\endcsname \expandafter\newbox\csname ~dim2\endcsname \expandafter\newbox\csname ~dim3\endcsname \expandafter\newbox\csname ~dim4\endcsname \expandafter\newbox\csname ~dim5\endcsname \expandafter\newbox\csname ~dim6\endcsname \expandafter\newbox\csname ~dim7\endcsname \expandafter\newbox\csname ~dim8\endcsname \expandafter\newbox\csname ~dim9\endcsname \def\dim#1{wd\backslash{~dim#1}} \def\dimdef#1#2{\setbox\backslash{~dim#1}=\hbox{\hskip #2}} \def\dimofdef#1#2{\setbox\backslash{~dim#1}=\hbox{#2}} \def\lbox#1#2{\hbox to 1\dim#1{#2\hss}} \def\rbox#1#2{\hbox to 1\dim#1{\hss#2}} \def\cbox#1#2{\hbox to 1\dim#1{\hss#2\hss}} % **************************************** % * PAGE NUMBERING * % **************************************** % % \count0 contains the number of the next page to be output (the one % currently being produced). Page numbers are produced by the following % two macros: % \~pagenum Generates the page number as printed on the output % page. % \~pagenumref Generates a page number entry for output to an .AUX % file or .TOC file, etc. Macros to be expanded when % that file is read are preceded by \string. % For example, if the number on page 3 is to be printed as -iii- on % the output page, and is to appear as iii in the table of contents, % then % \~pagenum = -\~roman{\the\count0}- % \~pagenumref = \string\~arabic{\the\count0} % % The user sets the pagenumber style with the command % \pagenumbering{foo} % which sets \count0 to 1 and executes the command \~pn~foo. For example, % the pagenumber style arabic, invoked by defining % \~pn~arabic = % \~pagenum = \~arabic{\the\count0} % \~pagenumref = \string\~arabic{\the\count0} % % The command \setpagenumber{foo} sets \count0 to foo \def\setpagenumber#1{\global\setcount0=#1\relax} \def\pagenumbering#1{\global\setcount0=1\relax\csname ~pn~#1\endcsname} \def\~pn~arabic{\gdef\~pagenum{\~arabic{\the\count0}}\gdef% \~pagenumref{\string\~arabic{\the\count0}}} \def\~pn~roman{\gdef\~pagenum{\~roman{\the\count0}}\gdef% \~pagenumref{\string\~roman{\the\count0}}} % **************************************** % * ENVIRONMENT COUNTER MACROS * % **************************************** % % \~resetcounter{foo} resets counter foo to zero % \setcounter{foo}{val} sets counter foo to eval(val) % \~stepcounter{foo} increments counter foo and resets all % subsidiary counters % \~refstepcounter{foo} same a \~stepcounter, but it also defines % \~currentreference so that a subsequent % \label{bar} command causes \ref{bar} to % generate the current value of counter foo. % \~definecounter{foo} initializes counter foo (with empty reset % list) % \~addtoreset{foo}{bar} adds counter foo to the list of counters % to be rest when counter bar is stepped % \~counter{foo} generates value of counter foo. This % macro should not be used, and will probably % disappear. You should use \~c~foo to obtain % the value of counter foo. (See below.) % % CONVENTIONS: % \~c~foo = value of counter foo % \~cl~foo = list of counters to be reset when foo stepped % (has format countera,counterb,counterc) % \~co~foo = macro to generate output indicating the current value of % counter foo, as it appears where the counter is used. % For example, if sections are numbered within % chapters, and section headings look like % Section II-3. The Nature of Counters % then \~co~foo might be % Section \~Roman{\~c~chapter}-\~arabic{\~c~section}. % \~ca~foo = macro to generate a list of numbers enclosed in braces % that cam be used to generate the counter number as output. % For example, \~ca~section == {\c~chapter}{\c~section}. % \~cr~foo = macro defined so that \~cr~foo\~ca~foo produces % the output for \ref{bar} when bar was defined by % a \label{bar} associating it with the value of % counter foo. E.g., for sections numbered within chapters, % \~cr~section #1#2 == \~cr~chapter{#1}-\~arabic{#2}. % \~cra~foo = same as \~cr~foo, except used for references that % occur inside an appendix. For example, if chapters % are numbered 1, 2, ... but appendix chapters are numbered % A, B, ... then % \~cr~chapter #1 == \~arabic{#1} % \~cr~section #1#2 == \~cr~chapter{#1}-\~arabic{#2}. % \~cra~chapter #1 == \~Alph{#1} % \~cra~section #1 == \~cra~chapter{#1}-\~arabic{#2} % \~cra~foo can be left undefined in references occurring % in the appendix are numbered the same as elsewhere. % Note: \~cra~foo is used only when reading in the .aux % to define labels. % % To illustrate how all these are used, the following is what a document % style definition should contain to define a counter for numbering theorems % within chapters, where the third theorem of the second chapter should % be numbered ``II-3'' where the theorem appears and in cross-references. % 1. Execute the macro \~definecounter{theorem} to initialize the % counter. % 2. Execute \~addtoreset{theorem}{chapter} to cause the stepping % of the chapter counter to reset the theorem counter. % 3. Define \~co~theorem, \~ca~theorem and \~cr~theorem as follows: % \def\~ca~theorem{{\~c~chapter}{\~c~theorem}} % \def\~cr~theorem #1#2{\~cr~chapter{#1}-\~arabic{#2}} % \def\~co~theorem % {Theorem {\~Roman{\~c~chapter}-\~arabic{\~c~theorem}.}} % If theorems can appear in the appendix, then also define % \def\~cra~theorem #1#2{\~cra~chapter{#1}-\~arabic{#2}} % 4. Define the theorem environment by % \def\~begintheorem{\~refstepcounter{theorem}\par \noindent % {\bf \~co~theorem} } % \def\~endtheorem{} % % Uses \count\~tmpcnt for temporary calculations % Uses \~x~a,\~x~b as temporaries % \def\~resetcounter#1{\expandafter\xdef\csname ~c~#1\endcsname{0}} \def\setcounter#1#2{\expandafter\xdef\csname ~c~#1\endcsname{#2}} \def\~stepcounter#1{\setcount\~tmpcnt=\~counter{#1} \advcount\~tmpcnt by1 \expandafter\xdef\csname ~c~#1\endcsname{\the\count\~tmpcnt}\xdef% \~x~a{\csname ~cl~#1\endcsname}\~for\~x~b:=\~x~a\do{\~resetcounter\~x~b}} \def\~counter#1{\csname ~c~#1\endcsname} \def\~definecounter#1{\expandafter\xdef\csname ~cl~#1\endcsname {}\~resetcounter{#1}\~addtoreset{#1}{~ckpt}} \def\~cl~~ckpt{} \def\~addtoreset#1#2{\expandafter\ifx\csname ~cl~#2\endcsname \~empty \expandafter\xdef\csname ~cl~#2\endcsname{#1}\else \expandafter\xdef\csname ~cl~#2\endcsname {\csname ~cl~#2\endcsname ,#1}\fi} % **************************************** % * CROSS REFERENCING MACROS * % **************************************** % % The user writes \label{foo} to define the following cross-references: % \ref{foo} = value of most recently incremented referencable counter. % in the current environment. % (Chapter, section, theorem and enumeration counters % counters are referencable, footnote counters are not.) % \pageref{foo} = page number at which \label{foo} command appeared. % where foo can be any string of characters not containing \, { or }. % % Note: The scope of the \label command is delimited by environments, so % \begin{theorem} \label{foo} ... \end{theorem} \label{bar} % defines \ref{foo} to be the theorem number and \ref{bar} to be % the current section number. % % Note: \label does the right thing in terms of spacing -- i.e., % leaving a space on both sides of it is equivalent to leaving % a space on either side. % % Note: a warning message will be typed for the first \~maxmsgs % undefined \ref, \pageref or \cite references. The number of such % references is kept in \count\~undefined. % % This is implemented as follows. A referencable counter CNT is % incremented by the command \~refstepcounter{CNT} , which sets % \~currentlabel == {CNT}{eval(\~ca~CNT)}. The command % \label{FOO} then writes the following on file \~auxout : % \~refdef{FOO}eval(\~currentlabel){eval(\~pagenumref)} % % Note: the macro \namegdef{name}{def} performs a \gdef\name{def}, except % it works if name has non-letters. The macro \name is called % by \backslash{name}. The macro \~rnamegdef is defined as follows % % \~refdef{NAME}{CTR}{ARGS}{PAGE} == % BEGIN % if \~r~NAME undefined % else message: ``Label NAME multiply defined'' fi % if \~appsw = F % then \~r~NAME == BEGIN % if \~ref = T then \backslash{~cr~CTR}ARGS % else PAGE fi % END % else if \~cra~CTR undefined % then \~r~NAME == BEGIN % if \~ref = T % then \backslash{~cr~CTR}ARGS % else PAGE fi % END % else \~r~NAME == BEGIN % if \~ref = T % then \backslash{~cra~CTR}ARGS % else PAGE fi % END % fi % fi % END % % Note that this assumes that when the \~refdef command is % executed, \~appsw will be F except when the definition is for % an appendix entry. % % Useful hack: \~ifundefined{foo} ... \else ... \fi tests if % \foo is undefined. % % % \ref{foo} = % if \~r~foo defined % then \~ref := T % \~r~foo % else ?? % if \count\~undefined < \~maxmsgs % then message: ``reference foo on page \count0 undefined'' % \count\~undefined := \count\~undefined + 1 % fi % fi % % \pageref{foo} = % if \~r~foo defined % then \~ref := F % \rp~foo % else ?? % if \count\~undefined < \~maxmsgs % then message: ``reference foo on page \count0 undefined'' % \count\~undefined := \count\~undefined + 1 % fi % fi % \newcount\~undefined \def\~maxmsgs{24} %temporary value for testing \def\~ifundefined#1{\def\~x~a{\expandafter\ifx \csname #1\endcsname}\expandafter\~x~a\csname ~~~undefined\endcsname} \def\~appsw{F} \def\~refdef#1#2#3#4{\~ifundefined{~r~#1}\else\warning {Warning: label #1 multiply defined.}\fi \if\~appsw F \namegdef {~r~#1}{\if\~ref T\backslash{~cr~#2}#3\else #4\fi}\else \expandafter\ifx\csname ~cra~#2\endcsname\relax \namegdef{~r~#1}{\if\~ref T\backslash{~cr~#2}#3\else #4\fi}\else \namegdef{~r~#1}{\if\~ref T\backslash{~cra~#2}#3\else #4\fi}\fi\fi} \def\ref#1{\~ifundefined{~r~#1}{\bf ??}\ifnum \count\~undefined<\~maxmsgs\relax\warning {Reference #1 on page \the\count0 \space undefined.}\advcount \~undefined by 1\fi \else \def\~ref{T}{\csname ~r~#1\endcsname}\fi} \def\pageref#1{\~ifundefined{~r~#1}{\bf ??}\ifnum \count\~undefined<\~maxmsgs\relax\warning {Reference #1 on page \the\count0 \space undefined.}\advcount \~undefined by 1\fi \else \def\~ref{F}\csname ~r~#1\endcsname\fi} \def\label#1{\~bsphack\if\~afilesw T{\let\~pagenumref=\relax \xdef\~x~a{\write\~auxout{\string\~refdef{#1}\~currentlabel{\~pagenumref}}}}% \~x~a\fi\~esphack} \def\~refstepcounter#1{\~stepcounter{#1}\~setcurrentlabel{#1}} \def\~setcurrentlabel#1{\edef\~currentlabel{{#1}{\csname ~ca~#1\endcsname}}} \~setcurrentlabel{page} % For \label commands that come before any environment % **************************************** % * NUMBERING MACROS * % **************************************** % % \~arabic{foo} = representation of eval(foo) as arabic numerals % \~roman{foo} = representation of eval(foo) as lower-case % Roman numerals % \~Roman{foo} = representation of eval(foo) as upper-case % Roman numerals % \~alph{foo} = representation of eval(foo) as a lower-case % letter: 1 = a, 2 = b, etc. % \~Alph{foo} = representation of eval(foo) as an upper-case % letter: 1 = a, 2 = b, etc. % \arabic = \~arabic{\the\count\~numberout} % \roman = \~roman{\the\count\~numberout} % etc. % % In all cases, a nonpositive number has the null representation, % and an error occurs when trying to represent a number > 26 as a letter. % % Uses \~tmpcnt and \~numberout \newcount\~numberout \def\arabic{\ifnum \count\~numberout > 0 \number\count\~numberout\fi} \def\roman{\ifnum \count\~numberout > 0 \setcount\~tmpcnt=-\count\~numberout \number\count\~tmpcnt\fi} \def\Roman{\ifnum \count\~numberout > 0 \setcount\~tmpcnt= -\count\~numberout\relax\xdef\~x~a{{\number\count\~tmpcnt}}\expandafter \uppercase\~x~a\fi} \def\Alph{\ifnum \count\~numberout > 0 \ifnum \count\~numberout < 27 \setcount\~tmpcnt=\count\~numberout \advcount\~tmpcnt by 64 \char\count\~tmpcnt\relax\else \errmessage{LATEX ERROR: Counter too big for Alph numbering}\fi\fi} \def\alph{\ifnum \count\~numberout > 0 \ifnum \count\~numberout < 27 \setcount\~tmpcnt=\count\~numberout \advcount\~tmpcnt by 96 \char\count\~tmpcnt\relax\else \errmessage{LATEX ERROR: Counter too big for alph numbering}\fi\fi} \def\~arabic#1{\ifnum #1 > 0 \setcount\~tmpcnt=#1 \number\count\~tmpcnt\fi} \def\~roman#1{\ifnum #1 > 0 \setcount\~tmpcnt=-#1 \number\count\~tmpcnt\fi} \def\~Roman#1{\ifnum #1 > 0 \setcount\~tmpcnt= -#1\relax\xdef\~x~a{{\number\count\~tmpcnt}}\expandafter \uppercase\~x~a\fi} \def\~Alph#1{\ifnum #1 > 0 \ifnum #1 < 27 \setcount\~tmpcnt=#1 \advcount\~tmpcnt by 64 \char\count\~tmpcnt\relax\else \errmessage{LATEX ERROR: Counter too big for Alph numbering}\fi\fi} \def\~alph#1{\ifnum #1 > 0 \ifnum #1 < 27 \setcount\~tmpcnt=#1 \advcount\~tmpcnt by 96 \char\count\~tmpcnt\relax\else \errmessage{LATEX ERROR: Counter too big for alph numbering}\fi\fi} %\def\~arabic#1{\setcount\~numberout=#1 \arabic} %\def\~roman#1{\setcount\~numberout=#1 \roman} %\def\~Roman#1{\setcount\~numberout=#1 \Roman} %\def\~Alph#1{\setcount\~numberout=#1 \Alph} %\def\~alph#1{\setcount\~numberout=#1 \alph} % ***************************************** % * TABLE OF CONTENTS, ETC. * % ***************************************** % % CONVENTIONS: % \~t~foo = T if and only if table foo should be produced. % It should be set to true only if \~tfilesw = T. % \~tf~foo = file number for output. % % Note: When producing the table, the .foo file should be read inside % a \begingroup ... \endgroup because it may redefine counter % macros, and those definitions should be local. % % \~tabentry{ENTRY}{PAGE} % Macro to be defined by document style that makes an entry % in a table of contents, etc. % % \tableentry{TABLE}{ENTRY} % User command for adding his own entry to a table of contents, etc. % It is defined to be % \~addtableentry{TABLE}{\string\~tabentry{ENTRY}} % % \tablemainentry{TABLE}{ENTRY} % User command for adding his own mainentry to a table of contents, etc. % It is defined to be % \~addtableentry{TABLE}{\string\~tabmainentry{ENTRY}} % % \~addtableentry{TABLE}{ENTRY} % If \~t~table = T , then writes on file \~tf~table the line % {eval(entry)}{page number}. Does nothing if \~t~foo = false. % Macros in ENTRY that are to be expanded when the table is % produced, rather than when the auxiliary file is written, should % be proceded by \string instead. A typical use would be % \~addtableentry{lof}{\string\figentry\~ca~figure}, % which would write % \figentry{3}{2}{\~arabic{17}} % on the .LOF file if Figure III-2 appears on page 17. The % \figentry macro would generate the List of Figures entry for % this figure. % % \~addtableentry{TABLE}{ENTRY} == % BEGIN % if \~t~TABLE = T % then \tokens = \~pagenumref % \~x~ate == write eval(ENTRY{\the\tokens}) on file \~tf~TABLE % \~x~ate fi % END \def\tableentry#1#2{\~addtableentry{#1}{\string\~tabentry{#2}}} \def\tablemainentry#1#2{\~addtableentry{#1}{\string\~tabmainentry{#2}}} \def\~addtableentry#1#2{\expandafter\if \csname ~t~#1\endcsname T\tokens% {\~pagenumref}\xdef\~x~ate{\expandafter% \write\csname ~tf~#1\endcsname{#2{\the\tokens}}}\~x~ate\fi} % **************************************** % * ENVIRONMENTS * % **************************************** % % \begin{foo} and \end{foo} are used to delimit environment foo. % \begin{foo} starts a group and calls \~beginfoo if it is defined, % otherwise it does nothing. \end{foo} checks to see that it matches % the corresponding \begin and if so, it calls \~beginfoo and then % ends a group. % % If \end{foo} needs to ignore blanks after it, then % \~endfoo should \gdef\~ignore{T}. % % \~currenvir = the name of the current environment % % NOTE: \~end is defined to be the \end command of TeX82. % \def\~currenvir{~initial~} \let\~end=\end \def\theend{\clearpage\~end} \def\begin#1{\~ifundefined{~begin#1}\def\~x~a{}\errmessage% {LATEX ERROR: Environment #1 undefined}\else \begingroup \def\~currenvir{#1}\def% \~x~a{\csname ~begin#1\endcsname}\fi\~x~a} \def\end#1{\gdef\~ignore{F}\def\~x~a{#1}\ifx \~x~a\~currenvir \csname ~end#1\endcsname \endgroup \if\~ignore T\ignorespaces\fi\else \errmessage{LATEX ERROR: \string\begin{\~currenvir} ended by \string\end{#1}}\fi} % ********************************************** % * MATH ENVIRONMENTS * % ********************************************** % % \( == BEGIN if math mode % then error: ``\( inside math environment'' % else $ % fi % END % % \) == BEGIN if math mode % then if inner mode % then $ % else error ``\[ closed with \)'' % else error ``unmatched \)'' % fi % END % % \[ == BEGIN if math mode % then error: ``\[ inside math environment'' % else $$ % fi % END % % \] == BEGIN if math mode % then if inner mode % then error ``\( closed with \]'' % else $$ % else error ``unmatched \]'' % fi % END % % \~beginequation == BEGIN \~refstepcounter{equation} $$ END % % \~endequation == BEGIN \eqno{\~co~equation} $$\ignorespaces END % % NOTE: The document style must define \~co~equation etc., and do % the appropriate \~addtoreset . % \def\({\ifmmode\errmessage{LATEX ERROR: \string\(\space inside math environment}\else$ %%$BRACE MATCH HACK \fi} \def\){\ifmmode\ifinner$\else\errmessage %%$ BRACE MATCH HACK {LATEX ERROR: \string\[\space closed with \string\)}\fi\else \errmessage {LATEX ERROR: Unmatched \string\)}\fi{}} \def\[{\ifmmode\errmessage{LATEX ERROR: \string\[\space inside math environment}\else$$ %%$$ BRACE MATCH HACK \fi} \def\]{\ifmmode\ifinner\errmessage{LATEX ERROR: \string\(\space closed with \string\]}\else$$\fi%%$$ BRACE MATCH HACK \else \errmessage {LATEX ERROR: Unmatched \string\]}\fi} \let\~beginmath=\( \let\~endmath=\) \let\~begindisplaymath=\[ \def\~enddisplaymath{\]\gdef\~ignore{T}} \~definecounter{equation} \def\~beginequation{$$ % $$ BRACE MATCHING HACK \~refstepcounter{equation}} \def\~endequation{\eqno{{\~co~equation}}% $$ BRACE MATCHING HACK $$\gdef\~ignore{T}} % **************************************** % * \par and \everypar * % **************************************** % % \~par is defined to be the standard TeX \par, so \par % can be redefined. \par == \~par except when leaving a % paragraph environment, as explained below. % % \everypar == BEGIN \~everypar END % % \~everypar is usually null except inside a list environment. % % A PARAGRAPH ENVIRONMENT is one such that it is left in vertical mode -- % i.e., after a \par. The list environment is the prime example. % The LATEX convention is that, from the user's viewpoint, the continuation % starts a new paragraph if and only if he leaves a blank line after % the end of the paragraph environment. This is accomplished by % putting the command \~parhack at the end of the \~endlist command, % where \~parhack is defined as follows. % % \~parhack == % BEGIN % \~par % \endgroup %% ends the \begin commands \begingroup % \par == BEGIN % \par == \~par % \everypar == \~everypar % \~par % END % \everypar == BEGIN \hskip \minusthe\parindent \~everypar END % \begingroup %% to match the \end commands \endgroup % END \def\~parhack{\~par\endgroup\def\par{\let\par=\~par\everypar{\~everypar}\~par}% \everypar{\hskip \minusthe\parindent \~everypar}\begingroup} \let\~par=\par \def\~everypar{} \everypar{\~everypar} % **************************************** % * THE LIST ENVIRONMENT * % **************************************** % % The generic commands for creating an indented environment -- enumerate, % itemize, quote, etc -- are % \~beginlist{LABELING}{COMMANDS} ... \~endlist % which can be invoked by the user as the list environment. The LABELING % argument specifies item labeling. The COMMANDS argument contains commands % to set the horizonatal and vertical spacing parameters of the environment. % Each item of the environment is begun by one of the following commands: % \item : produces a label specified by the \~beginlist's LABELING % argument. The \arabic, \roman, etc. commands can be used % to number the item. For example, if LABELING = (\alph), % then an \item command for the third item of the list % produces the label (c) . % \labelitem{LABEL} : Produces an item labeled by LABEL. The commands % \arabic, etc. work the same way here as for \item. % \noparitem : like item, except used for the first item of a sublist % which comes at the beginning of an item of an enclosing % list. For example, if the second item of an enumeration % begins with an itemized list, so the result should look % like: % 2. - Gnus. % - Gnats. % - Gnomes. % then you type % \item \begin{itemize} % \noparitem Gnus. % \item Gnats. % \item Gnomes. % \end{itemize} % \noparlabelitem{LABEL} : is to \labelitem as \noparitem is to \item. % % Note: The \labelitem command has an additional feature for macro writing. % If you write \gdef\~labelcounter{foo} in its argument, then % a \label command in the item will refer to counter foo. % % The list environments (list, enumerate, itemize, etc.) are quite % forgiving about allowing you to leave or omit blank lines. There's % only one rule that you must follow: % Never leave a blank line between any of the above four \item % commands and the text of the item. % As long as you don't violate that rule, you are free to add or % omit blank lines before and after the \begin command, % and before the \item and \end commands. Blank lines within an item cause % the start of a new paragraph in the same item. % % When you leave a list environment, returning either to an enclosing % list or normal text mode, LaTeX begins a new paragraph if and only if % you leave a blank line after the \end command. What really happens, % in TeX terms, is that a new paragraph is started in any case. % However, if no blank line (or, more precisely, no additional \par % command) occurs, then an \hskip \minusthe\parindent is inserted % at the beginning of the new paragraph. % % For an environment like quotation, in which items are not labeled, % the entire environment is a single item. It is defined by % letting \~beginquotation == \~beginlist{}{...} \item . The spacing % parameters provide a great deal of flexability in designing the % format, including the ability to let the indentation of the first % paragraph be different from that of the subsequent ones. % % NOTE: Environments that may appear inside a list environment and do % not want to use another list environment for paragraphing will % find \~totalleftmargin equal to the distance that the prevailing % left margin is indented from the outermost left margin. As usual, % \the\hsize is the width of the current line, measured from the % outermost left margin. % % Here are the parameters of a list that can be set by commands in % the \~beginlist's COMMANDS argument. The commands are used in the % obvious way -- for example, the \topsep parameter is set by the % command \topsep{13em}. (In all cases, the argument must be % a dimension.) % % VERTICAL SPACING: % \topsep : space between first item and preceding paragraph. % \itemsep : space between successive items. % \parsep : space between paragraphs within an item. % HORIZONTAL SPACING % \leftmargin : space between left margin of enclosing environment % (or of page if top level list) and left margin of % this list. Must be nonnegative. % Note: the command \leftmarginof{FOO} sets the left % margin to be the width of FOO. % \rightmargin : analogous. % \listparindent : extra indentation at beginning of every paragraph % of a list. May be negative! It is added BEFORE % the label. Usually, labeled lists have \listparindent % equal to zero. % \labelwidth : width of box that contains the label. Must be non- % negative. Note: the command \labelwidthof{FOO} sets % \labelwidth to the width of FOO. % \labelsep : space between end of label box and text of % first item. May be negative! % % DEFAULT VALUES: % % \topsep : if outermost list then \parskip % else \itemsep of enclosing list. % \itemsep : same as \topsep. % \parsep : if outermost list then \parskip % else \parsep of enclosing list. % \leftmargin : \~d~leftmargin % \rightmargin : 0 pt % \listparindent : 0 pt % \labelwidth : \~d~labelwidth % \labelsep : \~d~labelsep % % \~beginlist{LABEL}{COMMANDS} == % BEGIN % \~listdepth := \~listdepth + 1 % if \~listdepth = 1 % then \~topsep :=L \the\parskip % \~itemsep :=L \the\parskip % \~parsep :=L \the\parskip % \noindent ==L BEGIN enter hmode \hskip -\parindent END % else \~topsep :=L \~itemsep % fi % \count\~itemnumber := 0 % \~leftmargin :=L \~d~leftmargin %Set default value % \~rightmargin :=L 0 pt %Set default value % \~listparindent :=L 0 pt %Set default value % \dimen\~labelwidth :=L \~d~labelwidth %Set default value % \dimen\~labelsep :=L \~d~labelsep %Set default value % \~itemlabel :=L LABEL % COMMANDS % \~newlist :=L T % \dimen\~newhsize :=L \the\hsize - \~rightmargin % \~totalleftmargin :=L \~totalleftmargin + \~leftmargin % \parindent :=L \~listparindent % \ignorespaces % gobble space up to \[label]item % END % % \~endlist == % BEGIN % \~listdepth := \~listdepth - 1 % \~parhack % \goodpagebreak % END % % \labelitem{LAB} == % BEGIN % \gdef\~labelcounter{} % \~everypar == BEGIN \hsize :=L \dimen\~newhsize % END % % if \~newlist = T % then % \~newlist :=L F % \parskip :=L \~topsep % else % \parskip :=L \~itemsep % \goodpagebreak % Good to break between items. % fi % if hmode then 2 \unskip's fi % To remove any dangling space at end of % \par \indent % previous paragraph that could cause a % \parskip := \~parsep % blank line. % \hangindent \~totalleftmargin % \hskip \~totalleftmargin - \dimen\~labelwidth % - \dimen\~labelsep % \count\~itemnumber := \count\~itemnumber + 1 % set up \count\~numberout % \count\~numberout := \count\~itemnumber % for use by \arabic, etc. % \hbox to \dimen\~labelwidth{LAB} % if \~labelcounter = {} % else \~setcurrentlabel{\~labelcounter} fi % \hskip \dim\~labelsep % \~everypar ==L BEGIN % \parskip := \~parsep % \hangindent \~totalleftmargin % \hskip \~totalleftmargin % END % \ignorespaces %gobble space up to text % END % % \item == \labelitem{\~itemlabel} % % \noparlabelitem{LAB} == % BEGIN % if \~newlist = T % then % \~newlist :=L F % else % print message ``Warning: \string\nopar[label]item used in middle % of list.'' % fi % \parskip := \~parsep % \hangindent \~totalleftmargin % \hskip \~leftmargin +\~listparindent - \dimen\~labelwidth % - \dimen\~labelsep % \hbox to \dimen\~labelwidth{\~label} % \hskip \dim\~labelsep % \~everypar ==L BEGIN % \parskip := \~parsep % \hangindent \~totalleftmargin % \hskip \~totalleftmargin % END % \ignorespaces % END % % \noparitem == \noparlabelitem{\~itemlabel} % \newdimen\~newhsize \def\~listdepth{0} \def\~totalleftmargin{0pt} \def\~beginlist#1#2{\setcount\~tmpcnt=\~listdepth \advcount\~tmpcnt by 1 \xdef\~listdepth{\the\count\~tmpcnt}\ifnum \~listdepth = 1 \edef\~topsep{\the\parskip}\edef\~itemsep{\the\parskip}\edef\~parsep {\the\parskip}\else\edef\~topsep{\~itemsep}\fi \setcount\~itemnumber = 0 \edef\~leftmargin{\~d~leftmargin}\edef\~rightmargin{0pt}\edef% \~listparindent{0pt}\setdimen\~labelwidth=\~d~labelwidth \setdimen\~labelsep=\~d~labelsep\def\~itemlabel{#1}#2\def\~newlist {T}\setdimen\~newhsize=\the\hsize\advdimen \~newhsize by -\~rightmargin \setdimen\~tmpdim=\~totalleftmargin \advdimen\~tmpdim by \~leftmargin\edef\~totalleftmargin{\the \dimen\~tmpdim}\parindent\~listparindent\ignorespaces} \def\~endlist{\setcount\~tmpcnt=\~listdepth \advcount\~tmpcnt by -1 \xdef\~listdepth{\the\count\~tmpcnt}\~parhack\goodpagebreak } \def\labelitem#1{\gdef\~labelcounter{}\def\~everypar{\hsize\dimen\~newhsize }\if\~newlist T \def\~newlist{F}\parskip\~topsep \else\parskip\~itemsep \goodpagebreak \fi \ifhmode\unskip\unskip\fi \par\indent \parskip\~parsep\hangindent\~totalleftmargin \hskip \~totalleftmargin \hskip \minusthe\dimen\~labelwidth \hskip \minusthe\dimen\~labelsep \advcount\~itemnumber by 1 \setcount\~numberout = \count\~itemnumber \hbox to \dimen\~labelwidth{#1\hfil}\hskip\dimen\~labelsep \ifx\~labelcounter\~empty\else\~setcurrentlabel{\~labelcounter}\fi \def\~everypar{\parskip\~parsep\hangindent\~totalleftmargin\hskip \~totalleftmargin}\ignorespaces} \def\item{\labelitem{\hfill \~itemlabel}} \def\noparlabelitem#1{\if \~newlist T \def\~newlist{F}\else \warning{Warning: \string\nopar[label]item in middle of list.}\fi \parskip\~parsep\hangindent\~totalleftmargin \hskip \~leftmargin \hskip \~listparindent \hskip \minusthe\dimen\~labelwidth \hskip \minusthe\dimen\~labelsep \hbox to \dimen\~labelwidth{#1\hfil}\hskip\dimen\~labelsep \def\~everypar{\parskip\~parsep\hangindent\~totalleftmargin\hskip \~totalleftmargin}\ignorespaces} \def\noparitem{\noparlabelitem{\hfill \~itemlabel}} \def\topsep#1{\edef\~topsep{#1}} \def\itemsep#1{\edef\~itemsep{#1}} \def\parsep#1{\edef\~parsep{#1}} \def\leftmargin#1{\edef\~leftmargin{#1}} \def\leftmarginof#1{\setbox\~tmpbox=\hbox{#1}\setdimen\~tmpdim=1wd\~tmpbox \edef\~leftmargin{\the\dimen\~tmpdim}} \def\rightmargin#1{\edef\~rightmargin{#1}} \def\listparindent#1{\edef\~listparindent{#1}} \def\labelwidth#1{\setdimen\~labelwidth = #1} \def\labelwidthof#1{\setbox\~tmpbox=\hbox{#1}\setdimen\~labelwidth=1wd\~tmpbox} \def\labelsep#1{\setdimen\~labelsep = #1} % DEFINE \dimen's and \count \newdimen\~labelwidth \newdimen\~labelsep \newcount\~itemnumber % **************************************** % * LIST-MAKING ENVIRONMENTS * % **************************************** % % Enumeration is done with four counters: enum1, enum2, enum3 % and enum4, where enumi controls the numbering of the ith level % enumeration. To change the way items are numbered and referenced, % you just change the appropriate counter definitions -- e.g., % defining \~co~enum2 to be \~roman{(\backslash{~c~enum2})} makes % the numbering of the second-level list look like (i), (ii), etc. % The control sequences \~enum1margin, \~enum2margin, etc. determine the % left margins of the enumeration levels -- i.e., \~enum3margin % is the amount by which the left margin of the level-3 enumeration % is indented with respect to the level-2 enumeration's left margin. % They should be dimensions specified in em's, so they'll work right % with arbitrary font sizes. Remember that since the counter names have % numbers in them, you have to use \namedef, \pnamedef and \backslash % to define and use them. % % Itemization is controlled by four commands: ~item1, ~item2, ~item3 % and ~item4. To cause the second-level list to be bulleted, you % just define \~item2 to be $\bullet$. (Remember to use \namedef.) % The control sequences \~item1indent, etc. are analogous to the corresponding % ones for enumeration. % % \count\~enumdepth holds the current enumeration nesting depth. % \count\~itemdepth holds the current itemization nesting depth. % % \~beginenumerate == % BEGIN % if \count\~enumdepth > 3 % then errormessage: ``only 4 levels of enumeration allowed'' % else \count\~enumdepth := \count\~enumdepth + 1 % \~enumctr =L eval(~enum\the\count\~enumdepth) % \~resetcounter{\~enumctr} % \~beginlist{\~stepcounter{\~enumctr} % \~labelcounter :=G \~enumctr % \hss %don't worry about big label % \backslash{~co~\~enumctr}} % {\leftmargin{\backslash{~[\~enumctr]margin}}} % fi % END % % \~endenumerate == % BEGIN % \count\~enumdepth := \count\~enumdepth - 1 % \~endlist % END % \newcount\~enumdepth \setcount\~enumdepth = 0 \def\~beginenumerate{\ifnum \count\~enumdepth > 3 \errmessage {LATEX ERROR: Only four levels of enumeration allowed}\else \advcount\~enumdepth by 1 \edef\~enumctr {enum\the\count\~enumdepth}\~resetcounter{\~enumctr}\~beginlist {\~stepcounter{\~enumctr}\gdef\~labelcounter{\~enumctr }\hss\backslash{~co~\~enumctr}}{\leftmargin {\backslash{~\~enumctr margin}}}\fi} \def\~endenumerate{\advcount\~enumdepth by -1 \~endlist} % \~beginitemize == % BEGIN % if \count\~itemdepth > 3 % then errormessage: ``only 4 levels of itemization allowed'' % else \count\~itemdepth := \count\~itemdepth + 1 % \~itemizelabel =L eval(~item\the\count\~itemdepth) % \~beginlist{\hss\backslash{~itemlabel}} % {\leftmargin{\backslash{[\~itemizelabel]margin}}} % fi % END % % \~enditemize == % BEGIN % \count\~itemdepth := \count\~itemdepth - 1 % \~endlist % END % \newcount\~itemdepth \setcount\~itemdepth = 0 \def\~beginitemize{\ifnum \count\~itemdepth > 3 \errmessage {LATEX ERROR: Only four levels of itemization allowed}\else \advcount\~itemdepth by 1 \edef\~itemizelabel {~item\the\count\~itemdepth}\~beginlist {\hss\backslash{\~itemizelabel}}{\leftmargin{\backslash{\~itemizelabel margin}}}\fi} \def\~enditemize{\advcount\~itemdepth by -1 \~endlist} % \~begindescription{LABEL} == \~beginlist{}{\labelwidthof{LABEL} % \leftmarginof{LABEL\hbox to \~d~labelsep{} % \hbox to \~d~leftmargin{}}} % \def\~begindescription#1{\~beginlist{}{\labelwidthof{#1}\leftmarginof {\hbox to \~d~labelsep{}\hbox to \~d~leftmargin{}#1}}} \let\~enddescription=\~endlist % **************************************** % * THEOREM ENVIRONMENTS * % **************************************** % % The user creates his own theorem-like environments % by using the command % \theoremdef{NAME}{TEXT} % This defines the environment NAME to be just as one would % expect a theorem environment to be, except that it prints % ``TEXT'' instead of ``Theorem''. The command % \localtheoremdef % is similar, except that numbering is local to a chapter. % To define another environment NEWNAME which is to be numbered % by the same counter as NAME, except labeled by ``NEWTEXT'', % one uses the command % \sametheoremdef{NAME}{NEWNAME}{NEWTEXT}. % (This works for both globally and locally numbered environments. % % DOCUMENT STYLE PARAMETERS % % \~thmnumber : A command with a single argument. % \~thmnumber{\~c~theorem} should produce the theorem % number for globally numbered theorems. % \~localthmnumber : A command with two arguments. % \~localthmnumber{\~c~chapter}{\~c~theorem} should % produce the theorem number for locally numbered theorems. % \~applocalthmnumber : Same as \~localthmnumber, except for theorems % that appear in the appendix. % \~~beginthmenv, \~~endthmenv : Commands to delimit a theorem-like % environment. \beginthmenv{NAME}{TEXT} should begin % the environment numbered by counter NAME and labeled ``TEXT''. % Note: \~~endthmenv should use \~parhack to implement the convention % that a blank line after the \end{...} starts a new paragraph. % % \theoremdef{NAME}{TEXT} == % BEGIN % \~definecounter{NAME} % \~co~NAME == {\~thmnumber{\~c~NAME}} %% note: extra braces needed % %% to keep TeX from looking for more digits of number % %% during expansion. % \~ca~NAME == {\~c~NAME} % \~cr~NAME == \~thmnumber % \~beginNAME == \~~beginthmenv{NAME}{TEXT} % \~endNAME == \~~endthmenv % END % % \localtheoremdef{NAME}{TEXT} == % BEGIN % \~definecounter{NAME} % \~addtoreset{NAME}{chapter} % \~co~NAME == {\~localthmnumber{\~c~chapter}{\~c~NAME}} % \~ca~NAME == {\~c~chapter}{\~c~NAME} % \~cr~NAME == \~localthmnumber % \~cra~NAME == \~applocalthmnumber % \~beginNAME == \~~beginthmenv{NAME}{TEXT} % \~endNAME == \~~endthmenv % END % % \sametheoremdef{NAME}{NEWNAME}{TEXT} == % BEGIN % \~beginNAME == \~~beginthmenv{NAME}{TEXT} % \~endNAME == \~~endthmenv % END % \def\theoremdef#1#2{\~definecounter{#1}\namegdef% {~co~#1}{{\~thmnumber{\backslash{~c~#1}}}}\namegdef% {~ca~#1}{{\backslash{~c~#1}}}\namegdef{~cr~#1}{\~thmnumber }\namegdef{~begin#1}{\~~beginthmenv{#1}{#2}}\namegdef% {~end#1}{\~~endthmenv}} \def\localtheoremdef#1#2{\~definecounter{#1}\~addtoreset {#1}{chapter}\namegdef% {~co~#1}{{\~localthmnumber{\~c~chapter}{\backslash% {~c~#1}}}}\namegdef% {~ca~#1}{{\~c~chapter}{\backslash{~c~#1}}}\namegdef% {~cr~#1}{\~localthmnumber}\namegdef{~cra~#1}{\~applocalthmnumber }\namegdef{~begin#1}{\~~beginthmenv{#1}{#2}}\namegdef% {~end#1}{\~~endthmenv}} \def\sametheoremdef#1#2#3{\namegdef{~begin#2}{\~~beginthmenv {#1}{#3}}\namegdef{~end#2}{\~~endthmenv}} % **************************************** % * THE TABBING ENVIRONMENT * % **************************************** % % \dimen(\~firsttab + i) = distance of tab stop i from left margin % 0 <= i <= 15 (?). % % \dimen\~firsttab is initialized to \~totalleftmargin, so it starts % at the prevailing left margin. % % \~maxtab = number of highest defined tab register % probably = \~firsttab + 12 % \count\~nxttabmar = tab stop number of next line's left margin % \count\~curtabmar = tab stop number of current line's left margin % \count\~curtab = number of the current tab. At start of line, % it equals \~curtabmar % \count\~hightab = largest tab number currently defined. % \count\~tabpush = depth of \pushtab's % % \box\~curline = contents of current line, excluding left margin skip, % and excluding contents of current field % \box\~curfield = contents of current field % % \~rjfield = T iff the last field of the line should be % right-justified at the right margin. % % \~pgmsep = distance left by the \' command between the current % position and the field that is ``left-shifted''. % Default definition = \~d~labelsep % % UTILITY MACROS % \~stopfield : closes the current field % \~addfield : adds the current field to the current line. % \~contfield : continues the current field % \~startfield : begins the next field % \~stopline : closes the current line and outputs it % \~startline : starts the next line % \~ifatmargin : an \if that is true iff the current line. % has width zero % % \~startline == % BEGIN % \count\~curtabmar :=G \count\~nxttabmar % \count\~curtab :=G \count\~curtabmar % \box\~curline :=G null % \~startfield % \strut % END % % \~stopline == % BEGIN % \unskip % \~stopfield % if \~rjfield = T % then \~rjfield :=G F % \hbox to \the\hsize{\hskip \the\dimen\count\~curtabmar % \box\~curline % \hfil % \box\~curfield} % else \~addfield % \hbox {\hskip \the\dimen\count\~curtabmar % \box\~curline} % fi % END % % \~startfield == % BEGIN % \box\~curfield :=G \hbox { % END % % \~stopfield == % BEGIN % } % END % % \~contfield == % BEGIN % \box\~curfield :=G \hbox { \unhbox\~currfield %%} brace matching % END % \~addfield == % BEGIN % \box\~curline :=G \unbox\~curline * \unbox\~curfield % END % % \~ifatmargin == % BEGIN % if dim of box\~curline = 0pt then % END % % % \~begintabbing == % BEGIN % \lineskip :=L 0pt % \> == \~rtab % \< == \~ltab % \= == \~settab % \+ == \~tabplus % \- == \~tabminus % \` == \~tabrj % \' == \~tablab % \CR == BEGIN \~stopline \~startline END % \CRSP{DIST} == BEGIN \~stopline \vskip DIST \~startline\ignorespaces END % \XCR == BEGIN \~stopfield\~startline END % \count\~hightab :=G \count\~nxttabmar :=G \~firsttab % \count\~tabpush :=G 0 % \dimen\~firsttab := \~totalleftmargin % \~rjfield :=G F % \par % \vskip \the\parskip % \~startline % \ignorespaces % END % % \~endtabbing == % BEGIN % \~stopline % if \count\~tabpush > 0 then error message: ''unmatched \poptabs'' fi % \~parhack % END % % \~rtab == % BEGIN % \~stopfield % \~addfield % if \count\~curtab < \count\~hightab % then \~curtab :=G \~curtab + 1 % else error message ``Undefined Tab'' fi % \dimen\~tmpdim := \dimen\count\~curtab - \dimen\count\~curtabmar % - width of box \~curline % \box\~curline :=G \hbox{\unhbox\~curline + \hskip\dimen\~tmpdim} % \~startfield % END % % \~settab == % BEGIN % \~stopfield % \~addfield % if \count\~curtab < \~maxtab % then \count\~curtab :=G \count\~curtab+1 % else error message: ``Too many tabs'' fi % if \count\~curtab > \count\~hightab % then \count\~hightab :=L \count\~curtab fi % \dimen\count\~curtab :=L \dimen\count\~curtabmar + width of \box\~curline % \~startfield % END % % \~ltab == % BEGIN % \~ifatmargin % then if \count\~curtabmar > \~firsttab % then \count\~curtab :=G \count\~curtab - 1 % \count\~curtabmar :=G \count\~curtabmar - 1 % else error message ``Too many untabs'' fi % else error message ``Left tab in middle of line'' % fi % END % % \~tabplus == % BEGIN % if \count\~nxttabmar < \~maxtab % then \count\~nxttabmar :=G \count\~nxttabmar+1 % else error message ``Too many tabs'' % fi % END % % \~tabminus == % BEGIN % if \count\~nxttabmar > \~firsttab % then \count\~nxttabmar :=G \count\~nxttabmar-1 % else error message ``Too many untabs'' % fi % END % % \~tabrj == % BEGIN \~stopfield % \~rjfield :=G T % \~startfield % END % % \~tablab == % BEGIN \~stopfield % \box\~curline := \hbox{ \box\~curline % \hskip - width of \box\~curfield % \hskip -\~pgmsep % \box\~curfield % \hskip \~pgmsep } % \~startfield % END % % \pushtabs == % BEGIN % \~stopfield % \count\~tabpush :=G \count\~tabpush + 1 % \begingroup % \~contfield % END % % \poptabs == % BEGIN % \~stopfield % if \count\~tabpush > 0 % then \endgroup % \count\~tabpush :=G \count\~tabpush - 1 % else error message: ``Too many \poptabs'' % fi % \~contfield % END % \newdimen\~firsttab \newdimen\~x~a\newdimen\~x~a\newdimen\~x~a\newdimen\~x~a\newdimen\~x~a \newdimen\~x~a\newdimen\~x~a\newdimen\~x~a\newdimen\~x~a\newdimen\~x~a \newdimen\~x~a\newdimen\~x~a \newdimen\~maxtab \setdimen\~firsttab=0pt \newcount\~nxttabmar \newcount\~curtabmar \newcount\~curtab \newcount\~hightab \newcount\~tabpush \newbox\~curline \newbox\~curfield \def\~startline{\global\setcount\~curtabmar=\count\~nxttabmar\relax \global\setcount\~curtab=\count\~curtabmar\relax\setbox\~curline=\hbox {}\~startfield\strut} \def\~stopline{\unskip\~stopfield\if\~rjfield T\gdef\~rjfield{F}\hbox to \the\hsize{\hskip\the\dimen\count\~curtabmar\relax \box\~curline\relax\hfil\box\~curfield}\else\~addfield \hbox{\hskip\the\dimen\count\~curtabmar\relax\box\~curline}\fi} \def\~startfield{\global\setbox\~curfield=\hbox\~leftbrace}%{ BRACE MATCH HACK \let\~stopfield=} \def\~contfield{\global\setbox\~curfield=\hbox\~leftbrace\unhbox\~curfield} \def\~addfield{\global\setbox\~curline=\hbox{\unhbox \~curline\unhbox\~curfield}} \def\~ifatmargin{\ifdim 1wd\count\~curline = 0pt} \def\~begintabbing{\lineskip 0pt\let\>=\~rtab\let\<=\~ltab\let\==\~settab \let\+=\~tabplus\let\-=\~tabminus\let\`=\~tabrj\let\'=\~tablab \def\CR{\~stopline\~startline}\def\CRSP##1{\~stopline\vskip ##1\~startline \ignorespaces}\def\XCR{\~stopfield\~startline}\global\setcount\~hightab =\~firsttab\relax\global\setcount\~nxttabmar =\~firsttab\setdimen\~firsttab=\~totalleftmargin \global\setcount\~tabpush=0 \gdef\~rjfield{F}\par \vskip\the\parskip\~startline\ignorespaces} \def\~endtabbing{\~stopline\ifnum\count\~tabpush > 0 \errmessage {LATEX ERROR: Unmatched \string\poptabs}\fi\~parhack} \def\~rtab{\~stopfield\~addfield\ifnum \count\~curtab<\count\~hightab\relax \global\advcount\~curtab by 1 \else\errmessage{LATEX ERROR: Undefined tab}\fi \setdimen\~tmpdim=\dimen\count\~curtab\relax \advdimen\~tmpdim by \minusthe\dimen\count\~curtabmar\relax \advdimen\~tmpdim by -1wd\~curline \setbox\~curline=\hbox{\unhbox\~curline\hskip\dimen\~tmpdim} \~startfield} \def\~settab{\~stopfield\~addfield\ifnum \count\~curtab < \~maxtab\relax \global\advcount\~curtab by 1 \else\errmessage{LATEX ERROR: Too many tabs}\fi \ifnum\count\~curtab > \count\~hightab\relax \setcount\~hightab=\count\~curtab\fi \setdimen\count\~curtab=\dimen\count\~curtabmar\relax \advdimen\count\~curtab by 1wd\~curline\~startfield} \def\~ltab{\~ifatmargin\ifnum\count\~curtabmar > \~firsttab\relax \global\advcount\~curtab by -1 \global\advcount\~curtabmar by -1 \else \errmessage{LATEX ERROR: Too many untabs}\fi\else \errmessage{LATEX ERROR: Left tab in middle of line}\fi} \def\~tabplus{\ifnum \count\~nxttabmar < \~maxtab\relax \global\advcount\~nxttabmar by 1 \else \errmessage{LATEX ERROR: Too many tabs}\fi} \def\~tabminus{\ifnum\count\~nxttabmar > \~firsttab\relax \global\advcount\~nxttabmar by -1 \else \errmessage{LATEX ERROR: Too many untabs}\fi} \def\~tabrj{\~stopfield\gdef\~rjfield{T}\~startfield} \def\~tablab{\~stopfield\setbox\~curline=\hbox{\box\~curline \hskip -1wd\~curfield \hskip -\~pgmsep \box\~curfield \hskip \~pgmsep}\~startfield} \def\pushtabs{\~stopfield\~addfield\global\advcount\~tabpush by 1 \begingroup \~contfield} \def\poptabs{\~stopfield\~addfield\ifnum\count\~tabpush > 0 \endgroup \global\advcount\~tabpush by -1 \else \errmessage{LATEX ERROR: Too many \string\poptabs}\fi\~contfield} %INITIALIZATION: \def\~pgmsep{\~d~labelsep} % **************************************** % * THE PICTURE ENVIRONMENT * % **************************************** % % \dim0 = value of dimension argument % \dimen\~xorg = origin's x-coordinate % \dimen\~yorg = origin's y-coordinate % \~wholewidth = current line width % \~halfwidth = half of current line width % \~linefnt = font for drawing lines % % \~beginpicture(XSIZE,YSIZE)(XORG,YORG) % BEGIN % \vbox to YSIZE * \dim0 {\vss % \hbox to XSIZE * \dim0 { % \dimen\~xorg := XORG * \dim0 % \dimen\~yorg := YORG * \dim0 % END % % \~endpicture == % BEGIN % \hss } } % END % % \put(X, Y){OBJ} == % BEGIN % \~killglue % \dimen\~xdim := X * \dim0 - \dimen\~xorg % \dimen\~ydim := Y * \dim0 - \dimen\~yorg % \raise \dimen\~xdim \hbox to 0pt { \hskip \dimen\~ydim % OBJ \hss } % \ignorespaces % END % % \multiput(X,Y)(DELX,DELY){N}{OBJ} == % BEGIN % \~killglue % \count\~multicnt := N % \dimen\~xdim := X * \dim0 - \dimen\~xorg % \dimen\~ydim := Y * \dim0 - \dimen\~yorg % while \count\~multicnt > 0 % do \raise \dimen\~xdim \hbox to 0pt { \hskip \dimen\~ydim % OBJ \hss } % \count\~multicnt := \count\~multicnt - 1 % \dimen\~xdim := \dimen\~x + DELX * \dim0 % \dimen\~ydim := \dimen\~y + DELY * \dim0 % od % \ignorespaces % END % % INITIALIZATION % \~mb~l :=L \~mb~r :=L \hss % \~mb~t :=L \~mb~b :=L \hss % % \makebox(X,Y){POS}{OBJ} == % BEGIN % \begingroup % \dimen\~xorg := \dimen\~yorg := 0pt % tfor \~x~a := POS % one iteration for each token in POS % do \~mb~eval(\~x~a) :=L null od % \vbox to Y * \dim0 % {\~mb~t % \hbox to X * \dim0 % {\~mb~l \hbox{OBJ} \~mb~r } % \~mb~b} % \endgroup % END \def\~beginpicture(#1,#2)(#3,#4){\vbox to #2\dim0\lb\vss\hbox to #1\dim0\lb \setdimen\~xorg=#3\dim0\setdimen\~yorg=#4\dim0} \def\~endpicture{\hss\rb\rb} \def\put(#1,#2)#3{\~killglue\setdimen\~xdim=#1\dim0\advdimen\~xdim by \minusthe\dimen\~xorg \setdimen\~ydim=#2\dim0\advdimen\~ydim by \minusthe\dimen\~yorg\raise\dimen\~ydim\hbox to 0pt{\hskip \dimen\~xdim #3\hss}\ignorespaces} \def\multiput(#1,#2)(#3,#4)#5#6{\~killglue\setcount\~multicnt=#5\relax \setdimen\~xdim=#1\dim0\advdimen\~xdim by \minusthe\dimen\~xorg \setdimen\~ydim=#2\dim0\advdimen\~ydim by \minusthe\dimen\~yorg\~whilenum \count\~multicnt > 0\do {\raise\dimen\~ydim\hbox to 0pt{\hskip \dimen\~xdim #6\hss}\advcount\~multicnt by -1\advdimen\~xdim by #3\dim0\advdimen\~ydim by #4\dim0}\ignorespaces} \def\~killglue{\unskip\unskip\unskip\unskip} \let\~mb~b=\vss \let\~mb~l=\hss \let\~mb~r=\hss \let\~mb~t=\vss \def\makebox(#1,#2)#3#4{\begingroup\setdimen\~xorg=0pt\setdimen\~yorg=0pt% \~tfor\~x~a :=#3\do{\namedef{~mb~\~x~a}{}}\vbox to #2\dim0{\~mb~t\hbox to #1\dim0{\~mb~l\hbox{#4}\~mb~r}\~mb~b}\endgroup} \def\savebox#1(#2,#3)#4#5{\setcount\~tmpcnt=\~picbox \advcount\~tmpcnt by #1\relax\setbox\count\~tmpcnt=\hbox {\makebox(#2,#3){#4}{#5}}} \def\usebox#1{\setcount\~tmpcnt=\~picbox\advcount\~tmpcnt by #1\relax \copy\count\~tmpcnt\relax} \newbox{\~picbox} \newbox{\~x~a} \newbox{\~x~a} \newbox{\~x~a} \newbox{\~x~a} \newbox{\~x~a} \newbox{\~x~a} \newbox{\~x~a} \newbox{\~x~a} \newbox{\~x~a} % FaCSL FRAME DEFINITION STILL GOOD \def\frame#1{\vbox{\vskip-\~halfwidth\hrule height\~halfwidth depth \~halfwidth \vskip-\~halfwidth\hbox{\hskip-\~halfwidth \vrule width\~wholewidth \hskip-\~halfwidth #1\hskip-\~halfwidth \vrule width \~wholewidth \hskip -\~halfwidth}\vskip -\~halfwidth\hrule height \~halfwidth depth \~halfwidth\vskip -\~halfwidth}} % TEMPORARY DEFINITIONS \def\thinlines{\ifhmode\~killglue\fi \def\~linefnt{\tenln}\def\~halfwidth{.2pt}\def\~wholewidth{.4pt}} \def\thicklines{\ifhmode\~killglue\fi \def\~linefnt{\tenlnw}\def\~halfwidth{.5pt}\def\~wholewidth{1.0pt}} \def\stack#1{\vbox{\baselineskip-1pt\lineskip 3pt\halign {\hss ##\hss\cr #1\cr}}} \def\lstack#1{\vbox{\baselineskip-1pt\lineskip 3pt\halign {##\hss\cr #1\cr}}} \def\spec{\hskip-0.3pt \vrule height0.3pt depth0.3pt width0.6pt} %\def\cross{\hbox to 0pt{\hskip-0.2pt\vrule % depth 5pt width .4pt height 5pt}\hbox to 0pt{\hskip -5pt\vrule % depth 0.2pt width 10 pt height 0.2pt}} % \line(X,Y){LEN} == % BEGIN % if X > 0 % then % \count\~tmpcnt := |Y| % if \count\~tmpcnt > 6 % then error: ``LATEX ERROR: Illegal argument of \line.'' % \count\~tmpcnt := 0 % fi % if \count\~tmpcnt > 0 % then % if Y > 0 then \~upordown = \raise % \~initupordown = 0 % else \~upordown = \lower % \~initupordown = 1 % fi % \box\~linechar := \hbox{\~linefnt \~getlinechar(X,Y) } % \dimen\~totallinelen := LEN * \dim0 % \dimen\~currlinelen := width of \box\~linechar % \dimen\~currlineht := \~initupordown * height of \box\~linechar % % %% Put out integral number of line segments % while \dimen\~currlinelen < \dimen\~totallinelen % do \~upordown \dimen\~currlineht \copy\~linechar % \dim\~currlineht := \dim\~currlineht + ht of \box\~linechar % \dimen\~currlinelen := \dimen\~currlinelen % + width of \box\~linechar % od % % %% Put out last segment % \dimen\~currlineht := \dimen\~currlineht - height of \box\~linechar % \dimen\~currlinelen := \dimen\~currlinelen - width of \box\~linechar % \dimen\~tmpdim := (\dimen\~totallinelen - \dimen\~currlinelen) % \hskip - width of \box\~linechar % \hskip\dimen\~tmpdim % \dimen\~tmpdim := 1000 * \dimen\~tmpdim % \count\~tmpcnt := \dimen\~tmpdim / width of \box\~linechar % \dimen\~tmpdim := (\count\~tmpcnt * ht of \box\~linechar)/1000 % \dimen\~currlineht := \dimen\~currlineht + \dimen\~tmpdim % \hbox{\~upordown \dimen\~currlineht \copy\~linechar} % % else % horizontal line % \hbox{\vrule height \~halfwidth depth \~halfwidth width LEN * \dim0} % fi % else error: ``LATEX ERROR: Illegal argument of \line.'' % fi % END % % \~getlinechar(X,Y) == % BEGIN % \count\~tmpcnt := 8*X - 9 % if Y > 0 % then \count\~tmpcnt := \count\~tmpcnt + Y % else \count\~tmpcnt := \count\~tmpcnt - Y + 64 % fi % \char\count\~tmpcnt % END % % \larrowline(X,Y){LEN} == % BEGIN % \box\~tmpbox := \hbox to 0pt{\~linefnt \~getlarrow(X,Y) \hss} % \count\~tmpcnt := |Y| % if \count\~tmpcnt < 5 % then if Y < 0 % then \lower height of \box\~tmpbox \copy\~tmpbox % else \copy\~tmpbox % fi % \line(X,Y){LEN} % else error: ``LATEX ERROR: Illegal argument of \larrowline.'' % fi % END % % \~getlarrow(X,Y) == % BEGIN % if Y = 0 % then \count\~tmpcnt := '33 % else \count\~tmpcnt := 16 * X - 9 % \count\~tmpcnta := 2 * Y % if \count\~tmpcnta > 0 % then \count\~tmpcnt := \count\~tmpcnt + \count\~tmpcnta % else \count\~tmpcnt := \count\~tmpcnt - \count\~tmpcnta + 64 % fi % fi % \char\count\~tmpcnt % END % % \rarrowline(X,Y){LEN} == % BEGIN % \line(X,Y){LEN} % \count\~tmpcnt := |Y| % if \count\~tmpcnt < 5 % then \box\~tmpbox := \hbox{\~linefnt \~getrarrow(X,Y) \hss} % \hskip - width of \box\~tmpbox % \~upordown \dimen\~currlineht \box\~tmpbox % else error: ``LATEX ERROR: Illegal argument of \rarrowline.'' % fi % END % % \~getrarrow(X,Y) == % BEGIN % \count\~tmpcnta := |Y| % case of \count\~tmpcnta % 0 : \count\~tmpcnt := '55 % 1 : if X < 3 % then \count\~tmpcnt := 24*X - 6 % else if X = 3 % then \count\~tmpcnt := 49 % else \count\~tmpcnt := 58 fi % fi % 2 : if X < 3 % then \count\~tmpcnt := 24*X - 3 % else \count\~tmpcnt := 51 % X must = 3 % fi % 3 : \count\~tmpcnt := 16*X - 2 % 4 : \count\~tmpcnt := 16*X + 7 % endcase % if Y < 0 % then \count\~tmpcnt := \count\~tmpcnt + 64 % fi % \char\count\~tmpcnt % END \def\line(#1,#2)#3{\ifnum #1 > 0 \setcount\~tmpcnt=#2 \ifnum\count\~tmpcnt < 0\setcount\~tmpcnt=\minusthe\count\~tmpcnt\fi\ifnum\count\~tmpcnt >6 \errmessage{LATEX ERROR: Illegal argument of \string\line}\setcount\~tmpcnt =0 \fi\ifnum\count\~tmpcnt > 0 \ifnum #2 > 0 \let\~upordown=\raise \def\~initupordown{0 }\else\let\~upordown=\lower\def\~initupordown{1 }\fi \setbox\~linechar=\hbox{\~linefnt\~getlinechar(#1,#2)}\setdimen% \~totallinelen=#3\dim0\setdimen\~currlinelen=1wd\~linechar\setdimen% \~currlineht=1ht\~linechar\multdimen\~currlineht by \~initupordown \~whiledim \dimen\~currlinelen < \dimen\~totallinelen \do {\~upordown\dimen\~currlineht\copy\~linechar\relax\advdimen\~currlineht by 1ht\~linechar\relax \advdimen\~currlinelen by 1wd\~linechar}% \advdimen\~currlineht by -1ht\~linechar\advdimen\~currlinelen by -1wd\~linechar\setdimen\~tmpdim=\dimen\~totallinelen\advdimen\~tmpdim by \minusthe\dimen\~currlinelen\hskip -1wd\~linechar\hskip\dimen\~tmpdim \multdimen\~tmpdim by 1000 \setcount\~tmpcnt=\dimen\~tmpdim \setdimen\~tmpdim=1wd\~linechar \divcount\~tmpcnt by \dimen\~tmpdim \setdimen\~tmpdim=1ht\~linechar \multdimen\~tmpdim by \count\~tmpcnt \divdimen\~tmpdim by 1000 \advdimen\~currlineht by \dimen\~tmpdim \~upordown\dimen\~currlineht\copy\~linechar\else \hbox{\vrule height \~halfwidth depth \~halfwidth width #3\dim0}\fi \else\errmessage{LATEX ERROR: Illegal argument of \string\line} \fi} \def\~getlinechar(#1,#2){\setcount\~tmpcnt=#1\multcount\~tmpcnt by 8 \advcount\~tmpcnt by -9 \ifnum #2>0 \advcount\~tmpcnt by #2 \else \advcount\~tmpcnt by -#2 \advcount\~tmpcnt by 64 \fi \char\count\~tmpcnt} \def\larrowline(#1,#2)#3{\setbox\~tmpbox=\hbox to 0pt{\~linefnt \~getlarrow(#1,#2)\hss}\setcount\~tmpcnt=#2\relax\ifnum\count\~tmpcnt < 0 \setcount\~tmpcnt=\minusthe\count\~tmpcnt\fi\ifnum\count\~tmpcnt < 5 \ifnum #2 <0 \lower 1ht\~tmpbox\copy\~tmpbox\else\copy\~tmpbox\fi \line(#1,#2){#3}\else\errmessage{LATEX ERROR: Illegal argument of \string\larrowine}\fi} \def\~getlarrow(#1,#2){\ifnum #2 =0 \setcount\~tmpcnt='33\else \setcount\~tmpcnt=#1\relax\multcount\~tmpcnt by 16 \advcount\~tmpcnt by -9 \setcount\~tmpcnta=#2\relax\multcount\~tmpcnta by 2 \ifnum \count\~tmpcnta >0 \advcount\~tmpcnt by \count\~tmpcnta\relax \else\advcount\~tmpcnt by \minusthe\count\~tmpcnta\advcount\~tmpcnt by 64 \fi\fi\char\count\~tmpcnt} \def\rarrowline(#1,#2)#3{\line(#1,#2){#3}\setcount\~tmpcnt=#2\relax \ifnum\count\~tmpcnt < 0 \setcount\~tmpcnt=\minusthe\count\~tmpcnt\relax\fi \ifnum\count\~tmpcnt < 5 \setbox\~tmpbox=\hbox{\~linefnt \~getrarrow(#1,#2)\hss}\hskip -1wd\~tmpbox\relax\~upordown\dimen\~currlineht \box\~tmpbox\relax \else\errmessage{LATEX ERROR: Illegal argument of \string\rarrowline}\fi} \def\~getrarrow(#1,#2){\setcount\~tmpcnta=#2\relax \ifnum\count\~tmpcnta < 0 \setcount\~tmpcnta=\minusthe\count\~tmpcnta\relax\fi \ifcase \count\~tmpcnta\relax \setcount\~tmpcnt='55 \or \ifnum #1<3 \setcount\~tmpcnt=#1\relax\multcount\~tmpcnt by 24 \advcount\~tmpcnt by -6 \else \ifnum #1=3 \setcount\~tmpcnt=49 \else\setcount\~tmpcnt=58 \fi\fi\or \ifnum #1<3 \setcount\~tmpcnt=#1\relax\multcount\~tmpcnt by 24 \advcount\~tmpcnt by -3 \else \setcount\~tmpcnt=51\fi\or \setcount\~tmpcnt=#1\relax\multcount\~tmpcnt by 16 \advcount\~tmpcnt by -2 \else \setcount\~tmpcnt=#1\relax\multcount\~tmpcnt by 16 \advcount\~tmpcnt by 7 \fi\ifnum #2<0 \advcount\~tmpcnt by 64 \fi \char\count\~tmpcnt} % INITIALIZATION IN CASE \rarrowline called first \def\~upordown{\raise} \def\upline#1{\hbox to 0pt{\hskip -\~halfwidth \vrule width \~wholewidth height #1\dim0 depth 0pt\hss}} \def\uparrow#1{\upline{#1}\setbox\~tmpbox=\hbox{\~linefnt\char'66}\raise #1\dim0\hbox to 0pt{\lower 1ht\~tmpbox\box\~tmpbox\hss}} \def\downarrow#1{\upline{#1}\hbox to 0pt{\~linefnt\char'77\hss}} % \dashbox(X,Y){D} = % \makebox(X,Y){bl} % { \baselineskip := 0pt % %% HORIZONTAL DASHES % \dimen\~dashdim := X * \dim0 % \count\~dashcnt := \dimen\~dashdim + 200 % to prevent roundoff error % \dimen\~dashdim := D * \dim0 % \count\~dashcnt := \count\~dashcnt / \dimen\~dashdim % if \count\~dashcnt is even % then \dimen\~dashdim := \dimen\~dashdim / 2 % \count\~dashcnt := \count\~dashcnt / 2 - 1 % \box\~dashbox := \hbox{\vrule height \~halfwidth % depth \~halfwidth width \dimen\~dashdim} % \put(0,0){\copy\~dashbox} % \put(0,Y){\copy\~dashbox} % \put(X,0){\hskip -\dimen\~dashdim\copy\~dashbox} % \put(X,Y){\hskip -\dimen\~dashdim\box\~dashbox} % \dimen\~dashdim := 3 * \dimen\~dashdim % else \dimen\~dashdim := 0pt % \count\~dashcnt := (\count\~dashcnt + 1) / 2 % fi % \box\~dashbox := \hbox{\vrule height \~halfwidth % depth \~halfwidth width D * \dim0 % \hskip D * \dim0} % \count\~tmpcnt := 0 % put(0,0){\hskip \dimen\~dashdim % while \count\~tmpcnt < \count\~dascnt % do \copy\~dashbox % \count\~tmpcnt := \count\~tmpcnt + 1 % od % } % \count\~tmpcnt := 0 % put(0,Y){\hskip \dimen\~dashdim % while \count\~tmpcnt < \count\~dascnt % do \copy\~dashbox % \count\~tmpcnt := \count\~tmpcnt + 1 % od % } % % %% vertical dashes % \dimen\~dashdim := Y * \dim0 % \count\~dashcnt := \dimen\~dashdim + 200 % to prevent roundoff error % \dimen\~dashdim := D * \dim0 % \count\~dashcnt := \count\~dashcnt / \dimen\~dashdim % if \count\~dashcnt is even % then \dimen\~dashdim := \dimen\~dashdim / 2 % \count\~dashcnt := \count\~dashcnt / 2 - 1 % \box\~dashbox := \hbox{\hskip -\~halfwidth % \vrule width \~wholewidth % height \dimen\~dashdim } % \put(0,0){\copy\~dashbox} % \put(X,0){\copy\~dashbox} % \put(0,Y){\lower\dimen\~dashdim\copy\~dashbox} % \put(X,Y){\lower\dimen\~dashdim\copy\~dashbox} % \dimen\~dashdim := 3 * \dimen\~dashdim % else \dimen\~dashdim := 0pt % \count\~dashcnt := (\count\~dashcnt + 1) / 2 % fi % \box\~dashbox := \hbox{\vrule width \~wholewidth % height D * \dim0 } % \count\~tmpcnt := 0 % put(0,0){\hskip -\halfwidth % \vbox{while \count\~tmpcnt < \count\~dashcnt % do \vskip D*\dim0 % \copy\~dashbox % \count\~tmpcnt := \count\~tmpcnt + 1 % od % \vskip \~dashdim % } } % \count\~tmpcnt := 0 % put(X,0){\hskip -\halfwidth % \vbox{while \count\~tmpcnt < \count\~dashcnt % do \vskip D*\dim0 % \copy\~dashbox % \count\~tmpcnt := \count\~tmpcnt + 1 % od % \vskip \~dashdim % } % } % } % END MAKEBOX % END \def\dashbox(#1,#2)#3{\makebox(#1,#2){bl}{\baselineskip 0pt% \setdimen\~dashdim=#1\dim0% \setcount\~dashcnt=\dimen\~dashdim \advcount\~dashcnt by 200 \setdimen\~dashdim=#3\dim0\divcount\~dashcnt by \dimen\~dashdim \ifeven\~dashcnt \divdimen\~dashdim by 2 \divcount\~dashcnt by 2 \advcount\~dashcnt by -1 \setbox\~dashbox=\hbox{\vrule height \~halfwidth depth \~halfwidth width \dimen\~dashdim\relax}\put(0,0){\copy\~dashbox}% \put(0,#2){\copy\~dashbox}% \put(#1,0){\hskip\minusthe\dimen\~dashdim\copy\~dashbox}% \put(#1,#2){\hskip\minusthe\dimen\~dashdim\box\~dashbox}% \multdimen\~dashdim by 3 \else\setdimen\~dashdim=0pt% \advcount\~dashcnt by 1 \divcount\~dashcnt by 2 \fi \setbox\~dashbox=\hbox{\vrule height \~halfwidth depth \~halfwidth width #3\dim0\hskip #3\dim0}\setcount\~tmpcnt=0 \put(0,0){\hskip\dimen\~dashdim \~whilenum \count\~tmpcnt < \count\~dashcnt \relax\do{\unskip\copy\~dashbox\advcount\~tmpcnt by 1 }}\setcount\~tmpcnt=0 \put(0,#2){\hskip\dimen\~dashdim \~whilenum \count\~tmpcnt < \count\~dashcnt \relax\do{\unskip\copy\~dashbox\advcount\~tmpcnt by 1 }}% \setdimen\~dashdim=#2\dim0% \setcount\~dashcnt=\dimen\~dashdim \advcount\~dashcnt by 200 \setdimen\~dashdim=#3\dim0\divcount\~dashcnt by \dimen\~dashdim \ifeven\~dashcnt \divdimen\~dashdim by 2 \divcount\~dashcnt by 2 \advcount\~dashcnt by -1 \setbox\~dashbox=\hbox{\hskip -\~halfwidth \vrule width \~wholewidth height \dimen\~dashdim\relax}\put(0,0){\copy\~dashbox}% \put(#1,0){\copy\~dashbox}% \put(0,#2){\lower\dimen\~dashdim\copy\~dashbox}% \put(#1,#2){\lower\dimen\~dashdim\copy\~dashbox}% \multdimen\~dashdim by 3 \else\setdimen\~dashdim=0pt% \advcount\~dashcnt by 1 \divcount\~dashcnt by 2 \fi \setbox\~dashbox=\hbox{\vrule width \~wholewidth height #3\dim0}\setcount\~tmpcnt=0 \put(0,0){\hskip -\~halfwidth \vbox{\~whilenum \count\~tmpcnt < \count\~dashcnt \relax\do{\vskip #3\dim0\copy\~dashbox\advcount\~tmpcnt by 1 }% \vskip\dimen\~dashdim}}\setcount\~tmpcnt=0 \put(#1,0){\hskip -\~halfwidth \vbox{\~whilenum \count\~tmpcnt< \count\~dashcnt \relax\do{\vskip #3\dim0\copy\~dashbox\advcount\~tmpcnt by 1 }% \vskip\dimen\~dashdim }}}} %INITIALIZATION \thinlines \newdimen\~xorg \newdimen\~yorg \newcount\~multicnt \newcount\~tmpcnta \newdimen\~xdim \newdimen\~ydim \newbox\~linechar \newdimen\~totallinelen \newdimen\~currlinelen \newdimen\~currlineht \newdimen\~dashdim \newbox\~dashbox \newcount\~dashcnt % **************************************** % * CENTER, FLUSHRIGHT, FLUSHLEFT * % **************************************** % % % center sets \leftskip to \parfillskip and flushright sets % \leftskip to 0pt + 1fil and \parfillskip to 0. % % flushleft creates a \vbox in which each line is an \hbox to % its natural size. This means that a flushleft can be used inside % another environment in a nice way. However, it means that other % paragraphing environments can't be nested inside flushleft. % \def\~begincenter{\def\CR{\unskip\par\parskip 0pt$ $}% \def\CRSP##1{\unskip\vspace{##1}\par\parskip 0pt$ $\ignorespaces}% \def\~everypar{}% \par\leftskip\the\parfillskip\parindent\~totalleftmargin$ $\ignorespaces} \let\~endcenter=\~parhack \def\~beginflushright{\def\CR{\unskip\par\parskip 0pt$ $}\def\CRSP##1{% \unskip\vspace{##1}\par\parskip 0pt$ $\ignorespaces}\def\~everypar{}% \par\leftskip 0pt plus 1fil\parfillskip 0pt% \parindent\~totalleftmargin$ $\ignorespaces} \let\~endflushright=\~parhack \def\~beginflushleft{\def\CR{\unskip\hss\~rightbrace\hbox\~leftbrace}\def% \CRSP##1{\unskip\hss\~rightbrace\vspace{##1}\hbox% \~leftbrace\ignorespaces}$ $\vbox\~leftbrace\hbox \~leftbrace\ignorespaces} \def\~endflushleft{\hss\~rightbrace\~rightbrace} % **************************************** % * EXAMPLE * % **************************************** % % This environment uses the fixed-width \tt font, turns blanks into spaces % and starts a new line for each CR. A blank line leaves a \baselineskip % space % % CR redefined to \par, where \par redefined to \~par$ $ % No indentation % Space redefined to \space % {\obeylines\gdef\~ex~a{$ $\parskip 0pt\let =\~ex~b}} \def\~ex~b{\par$ $} {\obeylines\gdef\~beginexample{\def\~everypar{}\par\tt\frenchspace% \setdimen\~tmpdim=\~totalleftmargin\advdimen\~tmpdim by \~d~leftmargin% \parindent\dimen\~tmpdim% \obeyspaces\catcode`\^^M=13 \let^^M=\~ex~a\ignorespaces}} \def\~endexample{\baselineskip0pt\lineskip0pt\~par\~parhack} % **************************************** % * FOOTNOTES * % **************************************** % % \footnote{NOTE} : User command to insert a footnote. % \nfootnote{NUM}{NOTE} : User command to insert the NUM-th footnote % on the page, where NUM is a number -- 1, 2, % etc. It is needed because, in a style in % which footnotes are numbered within a page, % TeX will sometimes foul up the numbering. % This happens because at the time the footnote % number is generated by the \footnote command, % TeX has not yet decided where to break the % page. % \~makefootnote{MARK}{NOTE} : % Must produce the actual footnote, where MARK is the ``number'' % of the footnote and NOTE is the text. For example, might be % as simple as \par\noindent$^{MARK}$NOTE. However, it should use % struts to make sure that the footnote line has the right height % \~footruleheight : height of rule separating footnotes from text. % \~footruleshift : amount that the rule is shifted up from its ``natural'' % position just below the last line of the main text. % It must be a nonnegative dimension. % % The counter footnote must be defined like an ordinary counter. If % footnotes are numbered within pages, then the \~addtoreset command % must be used to get the footnote counter to be reset when the page % counter is stepped. \~cr~footnote and must be defined % so that \~cr~footnote{\~c~footnote} produces exactly the same output % as \~co~footnote. (It is used to generate the footnotes in the % \nfootnote command.) % \footnote{NOTE} == % BEGIN % \~stepcounter{footnote} % \~footnote{\~co~footnote}{NOTE} % END % % \nfootnote{NUM}{NOTE} == \~footnote{\~cr~footnote{NUM}}{NOTE} % % \~footnote{MARK}{NOTE} == % BEGIN % if horizontal mode % then if inner mode % then print error message ``Footnotes not allowed here, sorry'' % else \~x~sf := \the\spacefactor % $^{MARK}$ % put number in main text % \begingroup % \hsize :=L \columnwidth % needed in case % \~everypar :=L null % footnote % \everypar ==L BEGIN \~everypar END % inside list % \leftskip :=L 0pt % in case footnote inside % \rightskip :=L 0pt % center or flushright % \parfillskip :=L 0pt + 1fil % % \insert into \~footinsert % {\interlinepenalty :=L 100 % Stolen from Knuth % \~makefootnote{MARK}{NOTE} } % \endgroup % \spacefactor := \~x~sf % fi % else error message ``Please use \footnote only within a paragraph.'' % fi % END \def\footnote#1{\~stepcounter{footnote}\~footnote{\~co~footnote}{#1}} \def\nfootnote#1#2{\~footnote{\~cr~footnote{#1}}{#2}} \def\~footnote#1#2{\ifhmode\ifinner \errmessage{LATEX ERROR: Footnotes are not allowed here, sorry} \else\edef\~x~sf{\the\spacefactor}$^{#1}$\begingroup \hsize\columnwidth\def\~everypar{}\everypar {\~everypar}\leftskip 0pt\rightskip 0pt\parfillskip 0pt plus 1fil% \insert\~footinsert {\interlinepenalty100\~makefootnote{#1}{#2}}\endgroup\spacefactor =\~x~sf\fi\else\errmessage{LATEX ERROR: Footnotes are not allowed here, sorry}\fi{}} % **************************************** % * PAGE AND LINE BREAKING * % **************************************** % \def\pagebreak{\ifvmode \penalty -10000\else\~bsphack\vadjust{\penalty -10000}\~esphack\fi} \def\goodpagebreak{\ifvmode \penalty -400\else\~bsphack\vadjust{\penalty -400}\~esphack\fi} \def\verygoodpagebreak{\ifvmode \penalty -500\else\~bsphack \vadjust{\penalty -500}\~esphack\fi} \def\nopagebreak{\ifvmode \penalty 10000\else\~bsphack \vadjust{\penalty 10000}\~esphack\fi} \def\badpagebreak{\ifvmode \penalty 400\else\~bsphack\vadjust{\penalty 400}\~esphack\fi} \def\verybadpagebreak{\ifvmode \penalty 500\else\~bsphack \vadjust{\penalty 500}\~esphack\fi} \def\newline{\ifvmode \errmessage{LATEX ERROR: There's no line here to break}\else\hfil\penalty -10000\fi} \def\linebreak{\ifvmode \errmessage{LATEX ERROR: There's no line here to break}\else\unskip\penalty -10000\fi} \def\goodlinebreak{\ifvmode \errmessage{LATEX ERROR: There's no line here to break}\else\unskip\penalty -400\fi\ } \def\badlinebreak{\ifvmode \errmessage{LATEX ERROR: There's no line here to break}\else\unskip\penalty 400\fi\ } % **************************************** % * FIGURES AND TABLES * % **************************************** % % Figures are made with the following environments. They each have a single % argument, which is the text of the figure caption. The body of the % environment -- the material between the \begin and \end -- is assembled % in a vbox, using the current values of \parskip, \parindent, etc. % and the appropriate hsize for a full page or column wide figure. % figure : puts a full \textwidth wide figure at the top of the % next page where it fits, but not on the current one. % Puts a space of height \~figsep between multiple % figures on the same page, and a space \~topinsertskip % between the figures and the text. % % fullpagefigure : same as figure, but produces a figure that is a % full \~pageheight high, and goes on its own page. % intextfigure : starts a new paragraph and puts a \columnwidth wide % figure at the current position in the text. Puts an % extra space of \~textfigsep around the figure (in % addition to \parskip). Since TeX will not split a % vbox when forming pages, you had better know where % the figure will appear on the page when using this. % These environments are implemented using \~begininsert, % \~beginfullpageinsert, \~beginintextinsert, \~endfigure and % \~endintextfigure. These same macros will be used to implement floating % tables and any other similar environment. % % Two arguments to the \~begininsert, etc. macros are a table name TAB % and a counter COUNTER. If TAB has a non-empty value, then the % \~addtableentry macro is used to add the entry % \~tr~TAB eval[\~ca~COUNTER] {caption}{\~pagenumref} % to table TAB. % % LaTeX does figure placement by itself, without using TeX's \insert command. % Figures waiting to be placed on a page are stored in a ring of boxes, with % the following pointers: % \~nextfig : number of box into which the next figure should be inserted. % \~lastfig : number of box after the last one to be put on the current % page. % \~oldfig : number of box holding the next figure to be output on a page. % If \~lastfig = \~oldfig, then no figures are to be put on the current page. % If \~nextfig = \~oldfig, then there are no figures waiting to be output. % % PARAMETERS % \~figsep : The separation between figures if more than one is % inserted onto the same page. (A dimension.) % \~textfigsep : Extra space to be left above and below a figure % or table inserted in the middle of the text. % (A dimension.) % \~captionskip : Space between a figure or table and its caption. % \~topinsertskip : Space between top inserted figures and text. (A skip.) % \~topinsertskipdim : Dimension part of \~topinsertskip -- i.e., without % the plus and minus. % \~caption{LABEL}{CAP} : % Macro to generate a caption -- e.g., \~caption{Figure 3}{...}. % Note that it must handle the case in which caption won't fit on a % single line. % % VARIABLES % \~f~fullpage : T if making fullpagefigure or table. % \~f~caption : saves argument of \~beginfigure % \box\~figsav - \box\~endfigsav : % a sequence of boxes used to hold figures. % \~oldfig : number of box holding the oldest figure not yet inserted % onto a page. % \~nextfig : number of box into which next figure is to be inserted. % \~nextfig = \~oldfig if there are no figures waiting to % be inserted. % % \~beginfigure{CAPTION} == \~begininsert{figure}{Figure}{CAPTION} % % \~begininsert{COUNTER}{NAME}{CAPTION}{TAB} == % BEGIN % if horizontal mode % then \unskip % fi % \hsize :=L \textwidth % \~f~fullpage := F % \~refstepcounter{COUNTER} % \~f~caption == \~caption{Figure \~co~figure}{CAPTION} % \box\~nextfig := \vbox{ % } to balance braces % \~addtableentry{TAB}{\string\~tr~TAB % \~ca~COUNTER{CAPTION}} % \hbox to \textwidth % { \hss \vbox{ % } } to balance braces % END % % \~beginfullpagefigure{CAPTION} == % \~beginfullpageinsert{figure}{Figure}{CAPTION} % % % \~beginfullpageinsert{COUNTER}{NAME}{CAPTION}{TAB} == % BEGIN % if horizontal mode % then \unskip % fi % \hsize :=L \textwidth % \~f~fullpage := T % \~refstepcounter{COUNTER} % \~f~caption == \~caption{NAME \~co~COUNTER}{CAPTION} % \box\~nextfig := \vbox to \textheight{\vss % % \~addtableentry{TAB}{\string\~tr~TAB % \~ca~COUNTER{CAPTION}} % \hbox to \textwidth % { \hss \vbox{ % % END % % \~endfigure == % BEGIN % } \hss % } % \vskip \~captionskip % \hbox to \textwidth{\hss % \~f~caption % \hss} % if \~f~fullpage = T then \vss fi % } % % if height of \box\~nextfig > \textheight % then \box\~nextfig := \vbox to \textheight{\box\~nextfig} % error message: ``figure too big'' % else % \~stepfig{\~nextfig} % if \~nextfig = \~oldfig % then error message ``Too many figures on a page'' fi % fi % ignore following space % END % % \~beginintextfigure{CAPTION} == \~beginintextinsert{figure}{Figure}{CAPTION} % % \~beginintextinsert{COUNTER}{NAME}{CAPTION}{TAB} == % BEGIN % \par % \hsize :=L \columnwidth % \~refstepcounter{COUNTER} % if TAB = null % else \~addtableentry{TAB}{\string\~tr~TAB \~ca~COUNTER{CAPTION}} % \~f~caption == \~caption{NAME \~co~COUNTER}{CAPTION} % \par % \lineskip :=L 0pt % \vskip\the\parskip % \vskip\~textfigsep % \vbox{\hbox to \columnwidth % { \hss \vbox{ % END % % \~endintextfigure == % BEGIN % } \hss % } % \vskip \~captionskip % \hbox to \columnwidth{\hss % \~f~caption % \hss} % } % \vskip\~textfigsep % \~parhack % END % % \~endfullpagefigure == \~endfigure % % \~stepfig{FIG} == % BEGIN % if FIG < \~endfigsave % then FIG := FIG + 1 % else FIG := \~savfig fi % END \let\~leftbrace={ \let\~rightbrace=} \def\~beginfigure#1{\~begininsert{figure}{Figure}{#1}{lof}} \def\~begininsert#1#2#3#4{\ifhmode\unskip\fi \hsize\textwidth \def\~f~fullpage{F}\~refstepcounter{#1}\def% \~f~caption{\~caption{#2 \backslash{~co~#1}}{#3}}\global\setbox \~nextfig=\vbox\~leftbrace \~addtableentry{#4}{\string\~tr~ #4\backslash{~ca~#1}{#3}}\hbox to \textwidth\~leftbrace\hss \vbox\~leftbrace} \def\~endfigure{\~rightbrace\hss\~rightbrace\vskip\~captionskip \hbox to \textwidth{\hss\~f~caption\hss}\if\~f~fullpage T\vss \fi\~rightbrace \ifdim 1ht\~nextfig > \textheight \global\setbox\~nextfig=\vbox to \textheight{\box\~nextfig\relax} \errmessage{LATEX ERROR: Figure too big} \else \~stepfig\~nextfig \ifnum \~nextfig = \~oldfig\relax \errmessage{LATEX ERROR: Too many figures on one page}\fi \fi\ignorespaces} \def\~stepfig#1{\ifnum #1<\~endsavfig\relax \setcount\~tmpcnt=#1\relax\advcount\~tmpcnt by 1 \xdef#1{\the\count\~tmpcnt}\else \xdef#1{\~savfig}\fi} \def\~beginfullpagefigure#1{\~beginfullpageinsert{figure}{Figure}{#1}{lof}} \def\~beginfullpageinsert#1#2#3#4{\ifhmode\unskip\fi \hsize\textwidth \def\~f~fullpage{T}\~refstepcounter{#1}\def% \~f~caption{\~caption{#2 \backslash{~co~#1}}{#3}}\global\setbox \~nextfig=\vbox to \textheight \~leftbrace \~addtableentry{#4}{\string\~tr~ #4\backslash{~ca~#1}{#3}}% \vss \hbox to \textwidth\~leftbrace\hss \vbox\~leftbrace} \def\~beginintextfigure#1{\~beginintextinsert{figure}{Figure}{#1}{lof}} \def\~beginintextinsert#1#2#3#4{\par\hsize\columnwidth \def\~f~where{0}\~refstepcounter{#1}\~addtableentry {#4}{\string\~tr~ #4\backslash{~ca~#1}{#3}}\def% \~f~caption{\~caption{#2 \backslash{~co~#1}}{#3}}\vbox \~leftbrace \vss \hbox to \columnwidth\~leftbrace\hss \vbox\~leftbrace} \def\~endintextfigure{\~rightbrace\hss\~rightbrace\vskip\~captionskip \hbox to \columnwidth{\hss\~f~caption\hss}\~rightbrace \vskip\~textfigsep\~parhack} \let\~endfullpagefigure=\~endfigure % ANALOGOUS DEFINITIONS FOR tables % \def\~begintable#1{\~begininsert{table}{Table}{#1}{lot}} \def\~beginfullpagetable#1{\~beginfullpageinsert{table}{Table}{#1}{lot}} \def\~beginintexttable#1{\~beginintextinsert{table}{Table}{#1}{lot}} \let\~endtable=\~endfigure \let\~endfullpagetable=\~endfigure \let\~endintexttable=\~endintextfigure % INITIALIZATION \newbox\~savfig %boxes for saving figures \newbox\~x~a \newbox\~x~a \newbox\~x~a \newbox\~x~a \newbox\~endsavfig \xdef\~nextfig{\~savfig} \xdef\~oldfig{\~savfig} \xdef\~lastfig{\~savfig} \def\~figplacement{1} % **************************************** % * MISCELLANEOUS * % **************************************** % % \~topnewpage{BOX} starts a new page and puts BOX centered % in a box across the top. Useful for full-width titles for % double-column pages % % \~topnewpage{BOX} == % \clearpage % \box\~nextfig := \hbox to \textwidth {\hss \vbox{BoX}\hss} % \dimen\~vsize := \textheight - height of box\~nextfig % - depth of box\~nextfig - \~topinsertskipdim % \vsize := \dimen\~vsize % \~nextfig := \~stepfig{\~nextfig} % \~lastfig := \~stepfig{\~lastfig} % \def\~topnewpage#1{\clearpage\setbox\~nextfig=\hbox to \textwidth {\hss\vbox{#1}\hss}\setdimen\~vsize =\textheight\advdimen\~vsize by -1ht\~nextfig\advdimen\~vsize by -1dp\~nextfig \advdimen\~vsize by -\~topinsertskipdim\vsize\dimen\~vsize\~stepfig\~nextfig \~stepfig\~lastfig} % **************************************** % * INITIAL DECLARATION COMMANDS * % **************************************** % % DOCUMENT STYLE AND PAGE LAYOUT % ------------------------------ % % The user specifies a page layout style with a command % \pagelayout{ARG1,ARG2,...,ARGn}. For each i: if there is a predefined % page layout macro \~pl~ARGi, then that macro is executed. Otherwise, % the file ARGi.PLO is \input. % % The \documentstyle command is similar, except that the macro name is % \~ds~ARGi and the file name is ARGi.STY . % % \pagelayout{ARGLIST} == % BEGIN % for \~x~sty := ARGLIST % do if \~pl~[eval(\~x~sty)] undefined % then \input [eval(\~x~sty)].PLO % else \~pl~[eval(\~x~sty)] % od % END % % \documentstyle{ARGLIST} == % BEGIN % for \~x~sty := ARGLIST % do if \~ds~[eval(\~x~sty)] undefined % then \input [eval(\~x~sty)].STY % else \~ds~[eval(\~x~sty)] % od % END % \def\pagelayout#1{\def\~x~body{\~ifundefined{~pl~\~x~sty}\input \~x~sty.PLO\else\backslash{~pl~\~x~sty}\fi}\~for\~x~sty:=#1\do {\~x~body}} \def\documentstyle#1{\def\~x~body{\~ifundefined{~ds~\~x~sty}\input \~x~sty.STY\else\backslash{~ds~\~x~sty}\fi}\~for\~x~sty:=#1\do {\~x~body}} % PAGE STYLE COMMANDS % ------------------- % \pagestyle{STYLE} : sets the page style of the current and succeeding % pages to STYLE % % \thispagestyle{STYLE} : sets the page style of the current page only % to STYLE % % To define a page style STYLE, you must define \~ps~STYLE % to set the page style parameters. % \def\pagestyle#1{\backslash{~ps~#1}} \def\thispagestyle#1{\gdef\~specialpage{T}\gdef\~specialstyle{#1}} % ********************************************** % * ARRAY MACROS * % ********************************************** % % STYLE PARAMETERS FOR array ENVIRONMENTS % % \~ar~spacer : default spacer to go between columns of an array % \~ar~rule : rule plus space to go between columns of array. Should % be same total width as \~ar~spacer % % \~startarray{FORMAT} == % BEGIN % \begingroup % \lineskip :=L 0pt % \baselineskip := L 0pt % \~ar~lb == \relax % \~ar~lb = placeholder for # % \~ar~pream := {\strut} % holds the preamble for \halign % \~ar~next := 0 % \~ar~first := T % tfor \~ar~index := FORMAT % do \~ar~prev := \~ar~next % % %NOTE: \~ar~prev: code of last read FORMAT character % % 0 = l, r, or c % % 1 = | or {...} [s-group] % % 2 = s % % if \~ar~prev = 2 % then \~ar~pream := \~ar~pream * $ eval[\~ar~index]$ % \~ar~next := 1 % else \~ar~next := 0 % \~ar~fval := % if \~ar~index = l % then $ \~ar~lb$\hss % else if \~ar~index = c % then \hss$ \~ar~lb$\hss % else if \~ar~index = r % then \hss$ \~ar~lb$ % else null % fi fi fi % case of \~ar~prev: % 0 -> if \~ar~fval = null % then if \~ar~index = | % then \~ar~pream := \~ar~pream * \~ar~rule % \~ar~next := 1 % else \~ar~next := 2 % fi % else \~ar~pream := \~ar~pream * % if \~ar~first = T % else \~ar~spacer * & % fi * \~ar~fval % \~ar~first :=L F % fi % 1 -> if \~ar~fval = null % then if \~ar~index = | % then \~ar~pream := \~ar~pream * \~ar~rule % \~ar~next := 1 % else \~ar~next := 2 % fi % else \~ar~pream := \~ar~pream * % if \~ar~first = T % else & % fi * \~ar~fval % \~ar~first :=L F % fi % end case % fi % od % %% NOTE: THE ACTUAL TEX CODE TO EFFECT THE NEXT THREE % %% LINES IS THE BIGGEST PIECE OF KLUDGERY I HAVE EVER SEEN. % %% IT IS BASED UPON A HACK OBTAINED FROM KNUTH THAT I DON'T % %% UNDERSTAND IN THE LEAST. % % \~ar~align == \halign{ eval[\~ar~pream]\cr % \~ar~lb == # % \~ar~align % END % % \~finisharray == BEGIN \cr } \endgroup END % % \~beginarray{FORMAT} == BEGIN \vcenter { \~startarray{FORMAT} END % % \~endarray{FORMAT} == BEGIN \~finisharray } END % % \~beginbarray{FORMAT} == BEGIN \vbox { \~startarray{FORMAT} END %%} % % \~endbarray == \~endarray % % \~begintarray{FORMAT} == BEGIN \vtop { \~startarray{FORMAT} END %%} % % \~endtarray == \~endarray \def\~beginarray#1{\vcenter\~leftbrace\~startarray{#1}} \def\~endarray{\~finisharray\~rightbrace} \def\~beginbarray#1{\vbox\~leftbrace\~startarray{#1}} \let\~endbarray=\~endarray \def\~begintarray#1{\vtop\~leftbrace\~startarray{#1}} \let\~endtarray=\~endarray \def\~finisharray{\cr\if01{\fi}\endgroup} \def\~unbalanced{\halign{\span\if01}\fi} %% Knuth's hack \def\~startarray#1{\begingroup\lineskip0pt\baselineskip0pt\let% \~ar~lb=\relax\def\~ar~pream{\strut}\def% \~ar~next{0}\def\~ar~first{T}\~tfor\~ar~index:=#1\do {\xdef\~ar~prev{\~ar~next}\if \~ar~prev2\edef\~ar~pream{\~ar~pream$ \~ar~index$}\def% \~ar~next{1}\else \def\~ar~next{0}\edef\~ar~fval {\if\~ar~index l$ \~ar~lb$\hss\else \if\~ar~index c\hss$ \~ar~lb$\hss\else \if\~ar~index r\hss$ \~ar~lb$\fi\fi\fi}\ifcase \~ar~prev\relax \ifx\~ar~fval\~empty \if\~ar~index |\edef\~ar~pream{\~ar~pream \~ar~rule}\def\~ar~next{1}\else \def\~ar~next{2}\fi \else\edef\~ar~pream{\~ar~pream \if\~ar~first T\else \~ar~spacer &\fi\~ar~fval}\def\~ar~first{F}\fi \or \ifx\~ar~fval\~empty \if\~ar~index |\edef\~ar~pream{\~ar~pream \~ar~rule}\def\~ar~next{1}\else \def\~ar~next{2}\fi \else \edef\~ar~pream{\~ar~pream \if\~ar~first T\else&\fi\~ar~fval}\def% \~ar~first{F}\fi \fi\fi}\tokens{\~unbalanced}\let\~if=\relax\let\~fi=\relax \let\~ifnum=\relax\xdef\~ar~align{\the\tokens% \relax\~ifnum0=`{\~fi\~ar~pream\cr\~if01}\~fi}\let% \~ar~lb=##\let\~if=\if\let\~fi=\fi\let\~ifnum=\ifnum\~ar~align} % STYLE PARAMETERS FOR tabular ENVIRONMENT % % \~tb~spacer : analogous to \~ar~spacer % \~tb~rule : analogous to \~ar~rule % \~tb~lrule : to create [ rule. Should be same as \~tb~rule except % without the space to left of the rule % \~tb~rrule : to create ] rule. Same as \~tb~rule without % space on left % % \~begintabular{FORMAT} == BEGIN \vbox { \~starttabular{FORMAT} END % % \~endtabular == BEGIN \~finishtabular } END % % \~starttabular{FORMAT} == % Identical to \~startarray except items not put in math mode, % \unskip added to remove effects of spaces, and the extra % format items [ and ] put in for leftmost and rightmost vert rules. % It is terminated by \~finisharray % % % \multispan{NUM}{FORMAT}{ELEMENT} == % % % When used in a tabular environment, combines NUM columns % % into one, replacing the environment's format for those columns % % with FORMAT, putting ELEMENT in that wider column. There's % % an additional format character: - generates an \~tb~spacer % % space (the default inter-column space). This command will % % produce a completely null row (of zero height) if used % % with an empty format. % % % Note: In determining the ``columns'' of the tabular environent, % % the column break is right before a c,l or r. % % BEGIN % \omit % \count\~tmpcnt := NUM % \~spanloop % \~x~s := F % \~x~s = true if the next format element % % is an s-expression % % tfor \~x~a := FORMAT % do if \~x~s = T % then \~x~a % \~x~s := F % else % if \~x~a = c % then \strut\hss ELEMENT \unskip\hss % else % if \~x~a = l % then \strut\ignorespaces ELEMENT \unskip\hss % else % if \~x~a = r % then \strut\hss ELEMENT \unskip % else % if \~x~a = - % then \~tb~spacer % else % if \~x~a = | % then \~tb~rule % else % if \~x~a = [ % then \~tb~lrule % else \~x~s := T % if \~x~a = ] % then \~tb~rrule % else \~x~s := T % od fi fi fi fi fi fi fi fi % \ignorespaces % END % % \~spanloop == % BEGIN % while \count\~tmpcnt <> 1 % do \count\~tmpcnt := \count\~tmpcnt - 1 % \span\omit % od % END % %%{ % \~finishtabular == BEGIN \cr } END \def\~begintabular#1{\vbox\~leftbrace\~starttabular{#1}} \let\~endtabular=\~endarray \def\~starttabular#1{\begingroup\lineskip0pt\baselineskip0pt\let% \~ar~lb=\relax\def\~ar~pream{\strut}\def% \~ar~next{0}\def\~ar~first{T}\~tfor\~ar~index:=#1\do {\edef\~ar~prev{\~ar~next}\if \~ar~prev2\edef\~ar~pream{\~ar~pream\~ar~index}\def% \~ar~next{1}\else \def\~ar~next{0}\edef\~ar~fval {\if\~ar~index l\~ar~lb\unskip\hss\else \if\~ar~index c\hss\~ar~lb\unskip\hss\else \if\~ar~index r\hss\~ar~lb\unskip\fi\fi\fi}\ifcase \~ar~prev\relax \ifx\~ar~fval\~empty \if\~ar~index |\edef\~ar~pream{\~ar~pream \~tb~rule}\def\~ar~next{1}\else\if\~ar~index [\edef% \~ar~pream{\~ar~pream\~tb~lrule}\else \if\~ar~index ]\edef\~ar~pream{\~ar~pream\~tb~rrule}\else \def\~ar~next{2}\fi\fi\fi \else\edef\~ar~pream{\~ar~pream \if\~ar~first T\else \~tb~spacer &\fi\~ar~fval}\def\~ar~first{F}\fi \or \ifx\~ar~fval\~empty \if\~ar~index |\edef\~ar~pream{\~ar~pream \~tb~rule}\def\~ar~next{1}\else\if\~ar~index [\edef% \~ar~pream{\~ar~pream\~tb~lrule}\else \if\~ar~index ]\edef\~ar~pream{\~ar~pream\~tb~rrule}\else \def\~ar~next{2}\fi\fi\fi \else \edef\~ar~pream{\~ar~pream \if\~ar~first T\else&\fi\~ar~fval}\def% \~ar~first{F}\fi \fi\fi}\tokens{\~unbalanced}\let\~if=\relax\let\~fi=\relax \let\~ifnum=\relax\xdef\~ar~align{\the\tokens% \relax\~ifnum0=`{\~fi\~ar~pream\cr\~if01}\~fi}\let% \~ar~lb=##\let\~if=\if\let\~fi=\fi\let\~ifnum=\ifnum \let\~fi=\fi\~ar~align} \def\~spanloop{\ifnum \count\~tmpcnt = 1 \let\~x~a=\relax\else\advcount\~tmpcnt by-1\def\~x~a{\span\omit\~spanloop}\fi\~x~a} \def\multispan#1#2#3{\omit \setcount\~tmpcnt=#1 \~spanloop \def\~x~s{F}\~tfor\~x~a:=#2\do {\if\~x~s T\~x~a\def\~x~s{F}\else \if\~x~a c\strut\hss #3\unskip\hss\else \if\~x~a l\strut\ignorespaces #3\unskip\hss\else \if\~x~a r\strut\hss #3\unskip\else \if\~x~a -\~tb~spacer\else \if\~x~a |\~tb~rule\else \if\~x~a [\~tb~lrule\else \if\~x~a ]\~tb~rrule \else \def\~x~s{T}\fi\fi\fi\fi\fi\fi\fi\fi }\ignorespaces} % **************************************** % * INDEX COMMANDS * % **************************************** % % \makeindex == % BEGIN % if \~tfilesw = T % then open file \jobname.IDX as \~indexfile % \index{ITEM} == % BEGIN % \~bsphack % write of {\indexentry{ITEM}{page number}} % \~esphack % END % fi % END % % INITIALIZATION: % % \index{ITEM} == BEGIN \~bsphack \~esphack END % \def\makeindex{\if\~tfilesw T\newwrite\~indexfile \immediate\openout\~indexfile=\jobname.IDX \def\index##1{\~bsphack\write\~indexfile{\string \indexentry{##1}{\~pagenumref}}\~esphack}\warning {Index file \jobname.IDX }\fi} \def\index#1{\~bsphack\~esphack} \def\makeglossary{\if\~tfilesw T\newwrite\~glossaryfile \immediate\openout\~glossaryfile=\jobname.GLO \def\glossary##1{\~bsphack\write\~glossaryfile{\string \glossaryentry{##1}{\~pagenumref}}\~esphack}\warning {Glossary file \jobname.GLO }\fi} \def\glossary#1{\~bsphack\~esphack} % **************************************** % * THE OUTPUT ROUTINE * % **************************************** % % The following user commands are used to control page breaking. % \newpage : normal way to end a page. It \vfil's the unfinished % page or column to the top of the page, and can leave % a blank column in double column format. % \newcolumn : \vfil's the current column and moves to the next % one, going to the next page if it was the right % column. % \clearpage : does a \newpage, then if there are figures waiting % to be put on a page, it puts them out on a page % with no text. % PAGE LAYOUT PARAMETERS: % Note: booleans have value T or F % % \~topmargin : Extra space added to top of page. % \~twoside : boolean. T if two-sided printing % \~oddsidemargin : IF \~twoside = T % THEN extra space added to left of odd-numbered % pages. % ELSE extra space added to left of all pages. % \~evensidemargin : IF \~twoside = T % THEN extra space added to left of even-numbered % pages. % \~headheight : height of head % \~headsep : separation between head and text % \~footheight : height of foot % \~footsep : separation between text and foot % \textheight : height of text on page, excluding head and foot % \textwidth : width of printing on page % % PAGE STYLE PARAMETERS: % % \~doublecolumn : boolean. T if two columns per page. % \~columnsep : IF \~doublecolumn = T % THEN width of space between columns % \~columnseprule : IF \~doublecolumn = T % THEN width of rule between columns (0 if none). % \columnwidth : IF \~doublecolumn = T % THEN (\textwidth - \~columnsep)/2 % ELSE \textwidth % (SET BY THE \~makedoublecolumn AND % \~makesinglecolumn COMMANDS) % \~oddhead : IF \~twoside = T % THEN macro to generate head of odd-numbered pages. % ELSE macro to generate head of all pages. % \~evenhead : IF \~twoside = T % THEN macro to generate head of even-numbered pages. % \~oddfoot : IF \~twoside = T % THEN macro to generate foot of odd-numbered pages. % ELSE macro to generate foot of all pages. % \~evenfoot : IF \~twoside = T % THEN macro to generate foot of even-numbered pages. % \~footnoteenvir : sets up the environment within which a footnote is % composed -- for example, might == \eightpoint. % \~footruleheight : height of rule separating footnotes from text. % \~footruleshift : amount that the rule is shifted up from its ``natural'' % position just below the last line of the main text. % It must be a nonnegative dimension. % \~footinsertskip : space between main text and footnotes. The rule % separating footnotes from text occurs in this space. % \~specialpage : boolean. T if current page is to have a special format. % \~specialstyle : If its value is foo then % IF \~specialpage = T % THEN the command \~ps~foo is executed to temporarily % reset the page style parameters before composing % the current page. This command should execute % only \def's and \edef's, making only local % definitions. % % INSERTION BOXES: % \~footinsert : Contains accumulated footnotes. % % MACROS: % % \clearpage == % BEGIN % \~x~ecp := F % if \~twoside T % then if \count0 even % then \thispagestyle{endchapter} % \~x~ecp := T % fi % fi % \newpage % \~x~cdone := F % \begingroup % avoids a rule on a blank double % \~doublecolumn := F % column page % while \~x~cdone = F % do if \~oldfig = \nextfig % then \~x~cdone := T % else \hbox{} % if \~twoside T % then if \count0 even % then \~x~ecp := T % fi % fi % if \~x~ecp = T % then \thispagestyle{endchapter} % fi % \newpage % fi % od % \endgroup % END % % \newpage == % BEGIN % if \~doublecolumn = T % then \newcolumn % if \~firstcolumn = F % then \hbox{} % \newcolumn % fi % else \par \vfil \eject % fi % END % % \newcolumn == \par \vfil \eject % % \~makesinglecolumn == % BEGIN % \clearpage % \columnwidth := \textwidth % \hsize := \textwidth % \~doublecolumn := F % END % % \~makedoublecolumn == % BEGIN % \clearpage % \columnwidth := (\textwidth - \~columnsep)/2 % \hsize := \columnwidth % \~doublecolumn := T % \~firstcolumn := T % END % % \output == % BEGIN % \catcode`\ := 10 %%make sure space is really a space % \~produceoutput := T % if \~doublecolumn = T % then if \~firstcolumn = T % \~produceoutput := F % then \~firstcolumn := F % \box\~leftcolumn := % \hbox to \columnwidth % {\vbox % {\unvbox255 % ifabsent \insert\~footinsert % else \vskip\~footinsertskip % \vskip -\~footruleshift % \hrule height \~footruleheight % width \columnwidth % \vskip - \~footruleheight % \vskip \~footruleshift % \unvbox\~footinsert % }} % fi % fi % % if \~produceoutput = T % then % \begingroup % if \~specialpage = T % then \~specialpage := F % execute \~ps~[eval(\~specialstyle)] fi % \~x~done := F % \~x~sep := 0pt % \box\~topbox := \vbox to 0pt{} % \~topsep := 0pt % while \~x~done = F % do if \~lastfig = \~oldfig % then \~x~done := T % else \~topsep := \~topinsertskip % \box\~topbox := \vbox{\unvbox\~topbox % \vskip\~x~sep % \box\~oldfig} % \~oldfig := \~stepfig{\~oldfig} % \~x~sep := \~figsep % fi % od % if \~doublecolumn = T % then \box\~rightcolumn := % \hbox to \columnwidth % {\vbox % {\unvbox255 % ifabsent \insert\~footinsert % else \vskip\~footinsertskip % \vskip -\~footruleshift % \hrule height \~footruleheight % width \columnwidth % \vskip - \~footruleheight % \vskip \~footruleshift % \unvbox\~footinsert % }} % \dimen\~maxcolumnheight := maximum(height(\box\~leftcolumn), % height(\box\~rightcolumn)) % \~makepage{ \box\~topbox % \vskip\~topsep % \hbox to \textwidth % {\vbox to \dimen\~maxcolumnheight % {\box\~leftcolumn \vss} % \hbox to \~columnsep % {\hss % \vrule height \dimen\~maxcolumnheight % width \~columnseprule % \hss} % \vbox to \dimen\~maxcolumnheight % {\box\~rightcolumn \vss}} % \vss %% suppress over(under)full box messages % } % else % \~makepage{ \box\~topbox % \vskip\~topsep % \unvbox255 % if \box\~footinsert empty % then % else \vskip\~footinsertskip %stolen from Knuth % \vskip -\~footruleshift % \hrule height \~footruleheight % width \textwidth % \vskip - \~footruleheight % \vskip \~footruleshift % \unvbox \~footinsert % %%%%%%% add \vss here to suppress over(under)full box messages % } % fi % PUT OUT FULL PAGE FIGURES, IF ANY % \~x~done := 0 % while \~x~done = F % do if \~nextfig = \~oldfig % then \~x~done := T % else if height of box \~oldfig = \textheight % then begingroup % \~makepage{\box\~oldfig} % endgroup % \~oldfig := \~stepfig{\~oldfig} % else \~x~done := T % fi % fi % od % % COMPUTE NEXT \vsize % FIGURES \~oldfig UP TO BUT NOT INCLUDING \~lastfig TO GO ON % NEXT PAGE % \dimen\~vsize := \textheight % \~x~done := F % \~x~sep := \~topinsertskip % \~lastfig := \~oldfig % while \~xdone = F % do if \~nextfig = \~lastfig % then \~x~done := T % else \dimen\~tmpdim := \dimen\~vsize - height of box \~lastfig % - depth of box \~lastfig - \~x~sep % if \dimen\~tmpdim > 0pt % then \dimen\~vsize := \dimen\~tmpdim % \~lastfig := \~stepfig{\~lastfig} % \~x~sep := \~figsep % else \~x~done := T % fi % fi % od % \vsize := \dimen\~vsize % \endgroup % \~firstcolumn := T % % else \~firstcolumn := F % fi % END % % \~makepage{TEXT} == % BEGIN % if \~twoside = T % then if \count0 even % then \~oddhead ==L \~evenhead % \~oddfoot ==L \~evenfoot % \~oddsidemargin ==L \~evensidemargin fi fi % \shipout\vbox % {\~mainsize % set fonts size for head and foot % \baselineskip :=L \lineskip :=L 0pt %cribbed from Knuth % \vbox to \~topmargin{} % \moveright\~oddsidemargin\vbox % { \vbox to \~headheight{\vfil % \hbox to \textwidth % {\~beginnormal \~oddhead}} % \vskip \~headsep % \vbox to \textheight {TEXT} % \vskip \~footsep % \vbox to \~footheight % { \vfil % \hbox to \textwidth{\~beginnormal \~oddfoot} % } % } % } % \count0 := \count0 + 1 % \~stepcounter{page} %Primary purpose is to reset counters % % that should start fresh with each page. % END % % NOTE: This output routine has the property that the height of % a page (distance between top of head and bottom of foot) equals % \textheight + \~footheight + \~footsep + \~headheight + \~headsep % + THE DEPTH OF THE MAIN TEXT BOX. This extra term can be eliminated % by assembling the text part of the page (the \vbox to \textheight) % in a separate box before shipping it out, then adding a \vskip % to minus the depth of that box. Since this extra term typically % amounts to less than two points, it doesn't seem worth the effort. \~definecounter{page} \newdimen\~vsize \newdimen\~maxcolumnheight \newbox\~leftcolumn \newbox\~rightcolumn \newbox\~topbox \newinsert\~footinsert \setcount\~footinsert = 1000 \def\clearpage{\def\~x~ecp{F}\if\~twoside T\ifeven0\thispagestyle% {endchapter}\def\~x~ecp{T}\fi\fi\newpage\def\~x~cdone{F}\begingroup \def\~doublecolumn{F}\~while \~x~cdone F\do {\ifnum \~oldfig = \~nextfig\relax\xdef\~x~cdone{T}\else \hbox{}\if\~twoside T\ifeven0\def\~x~ecp{T}\fi\fi \if\~x~ecp T\thispagestyle{endchapter}\fi \newpage\fi}\endgroup} \def\newpage{\if\~doublecolumn T\newcolumn \if\~firstcolumn F\hbox{}\newcolumn\fi \else\par\vfil\eject\fi} \def\newcolumn{\par\vfil\eject} \def\~makesinglecolumn{\clearpage\xdef\columnwidth{\textwidth} \hsize\textwidth \gdef\~doublecolumn{F}} \def\~makedoublecolumn{\clearpage\setdimen\~tmpdim=\textwidth \advdimen\~tmpdim by -\~columnsep\divdimen\~tmpdim by 2 \xdef\columnwidth{\the\dimen\~tmpdim}\hsize\columnwidth \gdef\~doublecolumn{T}\gdef\~firstcolumn{T}} \output{\catcode`\ =10\relax\def\~produceoutput{T}\if \~doublecolumn T\if \~firstcolumn T\gdef% \~firstcolumn{F}\def\~produceoutput{F}\global% \setbox\~leftcolumn=\hbox to \columnwidth {\vbox{\unvbox255\ifabsent\~footinsert\else \vskip\~footinsertskip\vskip -\~footruleshift \hrule height \~footruleheight width \columnwidth \vskip - \~footruleheight\vskip \~footruleshift \unvbox\~footinsert\fi}}\fi\fi \if\~produceoutput T\begingroup \if\~specialpage T\gdef\~specialpage{F}\csname ~ps~\~specialstyle\endcsname\fi \def\~x~done{F}\def\~x~sep{0pt}\setbox\~topbox =\vbox to 0pt{}\def\~topsep{0pt}\~while \~x~done F\do {\ifnum \~lastfig=\~oldfig \relax\gdef\~x~done{T}\else \gdef\~topsep{\~topinsertskip}\global\setbox\~topbox =\vbox{\unvbox\~topbox \vskip\~x~sep\box\~oldfig}\~stepfig \~oldfig\gdef\~x~sep{\~figsep}\fi}\if \~doublecolumn T\setbox\~rightcolumn =\hbox to \columnwidth {\vbox{\unvbox255 \ifabsent\~footinsert\else \vskip\~footinsertskip\vskip -\~footruleshift \hrule height \~footruleheight width \columnwidth \vskip - \~footruleheight\vskip \~footruleshift \unvbox\~footinsert\fi }}\ifdim 1ht\~leftcolumn > 1ht\~rightcolumn \setdimen\~maxcolumnheight=1ht\~leftcolumn \else\setdimen\~maxcolumnheight=1ht\~rightcolumn\fi \~makepage{\box\~topbox\vskip\~topsep \hbox to \textwidth {\vbox to \dimen\~maxcolumnheight {\box\~leftcolumn\vss}\hbox to \~columnsep {\hss \vrule height \dimen\~maxcolumnheight width \~columnseprule \hss}\vbox to \dimen\~maxcolumnheight{\box\~rightcolumn\vss}}\vss }\else %singlecolumn \~makepage{\box\~topbox\vskip\~topsep \unvbox255 \ifabsent\~footinsert\else \vss \vskip\~footinsertskip \vskip -\~footruleshift \hrule height \~footruleheight width \textwidth \vskip -\~footruleheight \vskip\~footruleshift \unvbox\~footinsert\fi}\fi \def\~x~done{F}\~while\~x~done F\do {\ifnum\~nextfig=\~oldfig\relax \def\~x~done{T}\else \ifdim 1ht\~oldfig = \textheight {\~makepage {\box\~oldfig}}\~stepfig{\~oldfig}\else \def\~x~done{T}\fi \fi}\global\setdimen\~vsize=\textheight \def\~x~done{F} \xdef\~x~sep{\~topinsertskipdim} \xdef\~lastfig{\~oldfig} \~while\~x~done F\do {\ifnum\~nextfig=\~lastfig\relax \def\~x~done{T}\else \setdimen\~tmpdim=\dimen\~vsize \advdimen\~tmpdim by -1ht\~lastfig \advdimen\~tmpdim by -1dp\~lastfig \advdimen\~tmpdim by -\~x~sep \ifdim \dimen\~tmpdim >0pt \global\setdimen\~vsize=\dimen\~tmpdim \~stepfig\~lastfig \xdef\~x~sep{\~figsep}\else \def\~x~done{T}\fi \fi }\global\vsize\dimen\~vsize \endgroup\gdef\~firstcolumn{T}\else \gdef\~firstcolumn{F}\fi} \def\~makepage#1{\if\~twoside T\ifeven 0 \let\~oddhead=\~evenhead\let\~oddfoot=\~evenfoot\let% \~oddsidemargin=\~evensidemargin\fi\fi\shipout\vbox {\~mainsize \baselineskip 0pt\lineskip 0pt\vbox to \~topmargin{}\moveright \~oddsidemargin\vbox{\vbox to \~headheight{\vfil\hbox to \textwidth {\~beginnormal\~oddhead}}\vskip \~headsep\vbox to \textheight{#1}\vskip \~footsep\vbox to \~footheight {\vfil\hbox to \textwidth{\~beginnormal\~oddfoot}}}}\global \advcount0 by 1 \~stepcounter{page}} % **************************************** % * BIBLIOGRAPHY * % **************************************** % % A bibliography is created by the bibliography environment, which % generates a title such as ``References'', and a list of entries. % The PRETEX program will create a file containing such an environment, % which will be read in by the \bibliography command. % % The bibliography environment is a list environment. Instead % of using \item and \labelitem, items in the bibliography are % produced by the following commands: % \bibitem{NAME} : Produces a numbered entry cited as NAME. % \biblabelitem{LABEL}{NAME} : Produces an entry labeled by LABEL and % cited by NAME. % \bibitem is used for bibliographies with citations like [1], [2], etc., % and \biblabelitem is used for citations like [Knuth82]. % % The \begin{bibliography} command has a single argument, which specifies % the label width -- it is used as the argument for a \labelwidthof % command. % % The \~beginbibliography command needs to be defined for separately for each % document style. % % Entries are cited by the command \cite{NAME}. % % PARAMETERS % \~bibtitle : The Title of the bibliography % \~bibnumcite : A macro such that \~bibnumcite produces the output % for \cite{FOO} when entry FOO is defined by % \bibitem{FOO}. It is written as if it were % the first argument for a list environment -- % e.g., \~bibnumcite == [\arabic] to produce % citations like [1], [2], etc. % \~biblabelcite : A macro such that \~biblabelcite{LABEL} produces the % output for the \cite{FOO} command, where entry FOO is % defined by \biblabelitem{LABEL}{FOO}. % \~bibitems : The bibliography macro is a list environment. % \~bibitems is the first (LABELING) argument for that % list environment, so it controls how \bibitem entries % are numbered. % \~biblabel : A macro to produce the label in the bibliography % entry. For \biblabelitem{LABEL}{NAME}, the label is % generated by \~biblabel{NAME}. % % CONVENTION % % The output for \cite{foo} is saved as \~bc~foo. % \def\bibitem#1{\item\if\~afilesw T\immediate\write\~auxout {\string\namegdef{~bc~#1}{\~bibnumcite}}\fi\ignorespaces} \def\biblabelitem#1#2{\labelitem{\~biblabel{#1}}\if \~afilesw T\immediate\write\~auxout {\string\namegdef{~bc~#2}{\~biblabelcite{#1}}}\fi\ignorespaces} \def\cite#1{\~ifundefined{~bc~#1}{\bf \~biblabelcite{?}}\ifnum \count\~undefined<\~maxmsgs\relax\warning {Citation #1 on page \the\count0 \space undefined.}\advcount \~undefined by 1\fi \else \csname ~bc~#1\endcsname\fi{}} \let\~endbibliography=\~endlist % **************************************** % * DEBUGGING * % **************************************** % % \~showoutput causes the output to appear on the screen and % in the .LOG file. % \def\~showoutput{\tracingonline1\tracingoutput1 \showboxbreadth99999\showboxdepth99999\errorstopmode} % **************************************** % * INITIALIZATIONS * % **************************************** % \def\~specialpage{F} \def\~specialstyle{\errmessage{LATEX ERROR: There's something wrong with this document style}} \def\~doublecolumn{F} \tracingstats1 % Show how much stuff TeX has used % The following obscure code is needed because some environments % (the ``nofill'' environments) locally \catcode space to 13 and % define it to be \space. Any nonimmediate \write that was issued in such % an environment with a space will cause a space with \catcode % 13 to be processed at some later time. This insures that it % will have the correct definition at that time. {\catcode`\ =13\global\let =\space}