home *** CD-ROM | disk | FTP | other *** search
/ Education Sampler 1992 [NeXTSTEP] / Education_1992_Sampler.iso / Mathematics / TeX / TeXsis-2.15 / TXSmacs.tex (.txt) < prev    next >
LaTeX Document  |  1992-08-04  |  29KB  |  525 lines

  1. %% file: TXSmacs.tex                             TeXsis version 2.15
  2. %  $Revision: 15.20 $  :  $Date: 92/08/03 17:45:58 $  :  $Author: myers $
  3. %========================================================================*
  4. % TXSmacs - main macros for TeXsis
  5. %       This file mainly contains macros used in other macros, but the
  6. % following are useful in manuscripts:
  7. %       \draft          prints "draft" with the date and time at the 
  8. %                       bottom of the page
  9. %       \singlespaced   sets single spacing.
  10. %       \doublespaced   sets double (actually 1.5 times) spacing.
  11. %       \triplespaced   sets triple spacing for drafts.
  12. %       \widenspacing   increases spacing by 1.25.
  13. %                       All of these also set spacing in tables.
  14. %       \quoteon        Automatic opening and closing " by making " an
  15. %                       active character.
  16. %       \quoteoff       Turn \quoteon off
  17. %========================================================================*
  18. %  TeXsis -- Main Macros                : This file is a part ot TeXsis
  19. % (C) Copyright 1989, 1992 by Eric Myers and Frank E. Paige
  20. %======================================================================*
  21. \message{TeXsis main macros.}
  22. \catcode`@=11                           % @ is a letter here
  23. \let\XA=\expandafter                    % shorthand for \expandafter is \XA
  24. \let\NX=\noexpand                       % shorthand for \noexpand is \NX
  25. %--------------------------------------------------*
  26. % ERROR REPORTING:
  27. % \emsg writes the message "#1", ON A NEW LINE, on the terminal
  28. % and in the log.  Various \things are turned off.
  29. \def\emsg#1{% write an error/information message to the scren
  30.    \begingroup                                  % disable special characters
  31.      \def\@quote{"}%                            % to output "
  32.      \def\TeX{TeX}\def\label##1{}\def\use{\NX\use}%
  33.      \def\ { }\def~{ }%
  34.      \def\tt{\NX\tt}\def\bf{}\def\Tbf{}\def\tbf{}%
  35.      \def\break{}\def\n{\NX\n}%
  36.      \immediate\write16{#1}% 
  37.    \endgroup}
  38. % \@errmark writes a short error message in the right margin
  39. \newif\ifmarkerrors     \markerrorsfalse        % default is off
  40. \def\@errmark#1{\ifmarkerrors                   % only if \markerrorstrue
  41.    \vadjust{\vbox to 0pt{%                      % vbox with no height
  42.    \kern-\baselineskip                          % insert text next to line
  43.    \line{\hfil\rlap{{\tt\ <-#1}}}%              %  in right margin
  44.    \vss}}\fi}%                                  % end \vbox and \vadjust
  45. % \draft marks the bottom of the page with "Preliminary Draft", 
  46. % date and time, and turns on error marking.
  47.             
  48. \def\draft{%  puts DRAFT marks on footer lines of document
  49.    \def\draftline{{\tentt Preliminary Draft \hfill % DRAFT stamp at
  50.          -~\folio~- \hfill \runtime}}\footline={\draftline}%   bottom of page
  51.    \eqnotracetrue                               % equation tracing enabled
  52.    \markerrorstrue                              % DO mark errors in right margin
  53.    \overfullrule=1em}                           % marks overfull \hbox!
  54. % \runtime gets the current time and date in the form   hh:mm  mm/dd/yy
  55. \def\runtime{%                                  % current time of run
  56.     \count255=\time\divide\count255 by 60       % get hours
  57.     \the\count255:\relax                        % hours hh:
  58.     \multiply\count255 by -60 \advance\count255 by\time % get minutes
  59.     \ifnum 10 > \count255 {0}\fi                % leading zero for minutes < 10
  60.     \the\count255                               % minutes mm
  61.     \qquad\the\month/\the\day/\the\year}% and month, day, year
  62. %--------------------------------------------------*
  63. % \bye -- end of job processing
  64. % A slightly modified version of \bye will \checktags at end of job
  65. % \checktags comes from TXStags.tex.  Also, \endmode can be used
  66. % to close any outstanding mode, as in a \letter or \memo
  67. \outer\def\bye{% slightly revised version of \bye
  68.     \endmode                                    % ends any special modes
  69.     \par\vfill\supereject                       % as usual, from Plain TeX
  70.     \checktags                                  % How many undefined tags?
  71.     \end}
  72. \def\endmode{\relax}                            % default does nothing
  73. \def\checktags{\relax}                          % TXStags will define this...
  74. %--------------------------------------------------*
  75. % INTERLINE SPACING.
  76. \def\singlespaced{% sets interline spacing to \normalbaselineskip
  77.    \baselineskip=\normalbaselineskip            % reset interline
  78.    \setRuledStrut                               % set ruled table spacing
  79.    \setTableskip}                               % set table spacing
  80. \def\singlespace{\singlespaced}                 % synonym for \singlespaced
  81. \def\doublespaced{% sets interline spacing to 1.5 the \normalbaselineskip
  82.    \baselineskip=\normalbaselineskip            % increase interline
  83.    \multiply\baselineskip by 150                %  spacing by 1.50
  84.    \divide\baselineskip by 100                  %  of normal
  85.    \setRuledStrut                               % set ruled table spacing
  86.    \setTableskip}                               % set table spacing
  87. \def\doublespace{\doublespaced}                 % synonym for \doublespaced
  88. \def\TrueDoubleSpacing{% sets interline spacing to twice \normalbaselineskip
  89.    \baselineskip=\normalbaselineskip            % increase interline
  90.    \multiply\baselineskip by 2                  %  spacing by 2.0
  91.    \setRuledStrut                               % set ruled table spacing
  92.    \setTableskip}                               % set table spacing
  93. \def\truedoublespacing{\TrueDoubleSpacing} % synonym for \TrueDoubleSpacing
  94. \def\triplespaced{% sets interline spacing to 3.0 the \normalbaselineskip
  95.    \baselineskip=\normalbaselineskip            % increases interline
  96.    \multiply\baselineskip by 3                  %   spacing by 3.0
  97.    \setRuledStrut                               % set ruled table spacing
  98.    \setTableskip}                               % set table spacing
  99. \def\widenspacing{% increases the interline spacing by 1.25
  100.    \multiply\baselineskip by 125                % increase the interline
  101.    \divide\baselineskip by 100                  %   spacing by a factor of 1.25
  102.    \setRuledStrut                               % set ruled table spacing
  103.    \setTableskip}                               % set ``nice'' table spacing
  104. \def\whitespaced{\widenspacing}                 % synonym for \widenspacing
  105. \def\whitespace{\widenspacing}                  % synonym for \widenspacing
  106. % \Footnote is like \footnote, but the text is \singlespaced in \FootFont
  107. % and the reference mark is automatically put in a superscript.  The 
  108. % superscript is \smash'ed so it does not change the interline spacing.  
  109. % \Vfootnote is like \vfootnote, but singlespaced in \Footfont also.
  110. % How this works:  to use the same tricks with \vfootnote as used by
  111. % \footnote (see \vfootnote in Appendix B of the TeXbook) we begin a
  112. % group in which \FootFont and single spacing are invoked, then change
  113. % the definition of \@foot (which ends the \vfootnote) so that it also  
  114. % closes the extra group we've opened.
  115. \def\Footnote#1{%  singlespaced \footnote 
  116.    \let\@sf\empty                               % assume no scale factor
  117.    \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi % unless h-mode
  118.    ${}^{\hbox{\smash{#1}}}$\@sf                 % smashed superscript mark
  119.    \Vfootnote{#1}}                              % do it with \Vfootnote
  120. \def\Vfootnote#1{% singlespaced \vfootnote
  121.    \begingroup                                  % Following changes temporary
  122.      \def\@foot{\strut\egroup\endgroup}%        % change how to end \vfootnote
  123.      \tenpoint                                  % default to 10pt type
  124.      \baselineskip=\normalbaselineskip          % default single spaced
  125.      \parskip=0pt                               % no space between paragraphs
  126.      \FootFont                                  % change to ``footnote'' font
  127.      \vfootnote{${}^{\hbox{#1}}$}}              % superscript mark in footnote
  128. \def\FootFont{\rm}                              % default footnote typestyle
  129. % \setRuledStrut creates a vertical strut to hold the interline
  130. % spacing in ruled tables.  It is defined in ruled.tex, so we just
  131. % make an empty definition here.
  132. \def\setRuledStrut{\relax}              
  133. %-------------------------*
  134. % MISC. useful stuff:
  135. %  \undertext underscores any text
  136. \def\undertext#1{$\relax\underline{\hbox{#1}}$}
  137. \def\n{\hfil\break}                     % \n  is newline
  138. \def\nl{\hfil\break}                    % \nl is newline (alternate)
  139. \def\newpage{\vfill\eject}              % skip to next page
  140. %-------------------------*   (OLD TeXsis 2.13, \Tablebody)
  141. %  \Tableskipsize is the spacing for "nice" tables, using \Tablebody.
  142. %  It is 2pt for single spacing (as in TechRpt) and grows with \baselineskip.
  143. \newdimen\Tableskipsize \Tableskipsize=2pt              % for 10pt 
  144. \def\setTableskip{% sets table skips for \Tablebody (OLD)
  145.    \Tableskipsize=\baselineskip                 % current skip
  146.    \advance \Tableskipsize by -\normalbaselineskip % subtract normal
  147.    \advance \Tableskipsize by 2pt               % and add 2pt
  148. %-------------------------*
  149. % Un-TeX: how to undo things that only get turned on in plain TeX
  150. %  \unobeylines turns off \obeylines (if you didn't enclose it in {...} )
  151. \def\unobeylines{\catcode`\^^M=5}       % make ^^M just <return>
  152. % same idea for \unobeyspaces
  153. {\obeyspaces\gdef\unobeyspaces{\catcode`\ =10}}
  154. % same idea for \unraggedright
  155. \def\unraggedright{\rightskip=\z@\spaceskip=0pt\xspaceskip=0pt}
  156. %--------------------------------------------------*
  157. % EASY QUOTES.   Makes " an active character, which knows when to
  158. % be an open quote or a close quote
  159. \catcode`\"=\active
  160. \newcount\@quoteflag   \@quoteflag=\z@          % keep track of quotes
  161. \def"{\@quote}                                  % generic name for "
  162. \def\@quote{% gives `` for first quote, '' for second quote
  163.    \ifnum\@quoteflag=\z@                        %
  164.      \@quoteflag=\@ne {``}%                     %
  165.    \else                                        %
  166.      \@quoteflag=\z@ {''}%                      %
  167.    \fi}
  168. \def\quoteon{\catcode`\"=\active}               % turns on ``easy quotes''
  169. \def\quoteoff{\catcode`\"=12}                   % turns off ``easy quotes''
  170. \def\@checkquote#1{\ifnum\@quoteflag=\@ne\message{#1}\fi}
  171. % Default is \quoteoff. Turn quotes on only in \texsis
  172. % (so it won't interfer with any internal uses for ")
  173. \quoteoff               % Must turn quotes off while scanning the next def
  174. \def\checkquote{{\quoteoff\@checkquote{> Unbalanced "}}} % checks balanced "'s
  175. %--------------------------------------------------*
  176. % \@obsolete marks obsolete macros
  177. \def\@obsolete#1#2{%
  178.    \emsg{> =========================================================}%
  179.    \emsg{> \NX#1 is now obsolete! It may soon disappear!} 
  180.    \emsg{> Please use \NX#2 instead.}
  181.    \emsg{> =========================================================}%
  182. %--------------------------------------------------*
  183. % \DUMP  - \dump for VMS
  184. % VMS translates command line arguments to uppercase,
  185. % so ``initex texsis \dump'' won't work unless \DUMP is defined.
  186. \let\DUMP=\dump
  187. %--------------------------------------------------*
  188. % \setcnt\counter{value} sets the counter \counter
  189. % to the given value, but only temporarily in this group.
  190. % After you leave the group the counter is set back to it's
  191. % value before you call \setcnt.  Useful for figure captions
  192. % in the ``wrong'' group and other such wierd things.
  193. \def\setcnt#1#2{% set a counter to a value in a group
  194.   \edef\th@value{\the#1}%                       % evaluate counter
  195.   \aftergroup\global\aftergroup#1               % \global\counter=<old>
  196.   \aftergroup=\relax                            %
  197.   \XA\@ftergroup\th@value\endafter              % all tokens the in counter
  198.   \global#1=#2\relax}                           % set the value in this group
  199. %  \@ftergroup assigns \next the next token and 
  200. %  then calls \@ftertoken to put that token on the \aftergroup list
  201. \def\@ftergroup{\futurelet\next\@ftertoken} 
  202. \long\def\@ftertoken#1{
  203.    \ifx\next\endafter\relax                     % \endafter ends
  204.      \let\next=\relax                           % so just do nothing
  205.    \else\aftergroup#1\relax                     % put the token on the list
  206.      \let\next=\@ftergroup                      % and get next token
  207.    \fi\next}                                    % do what's \next
  208. %--------------------------------------------------*
  209. % \ATlock makes "@" a non-letter to protect internal control sequences
  210. % \ATunluck makes "@" a letter so you can get at them
  211. \def\ATlock{\catcode`@=12}                      % makes @ not a letter
  212. \def\ATunlock{\catcode`@=11}                    % makes @ a letter 
  213. \ATunlock
  214. % If someone tries to read a source or style file without having
  215. % said \ATunlock they will get all sorts of errors, most notably
  216. % that \@ is undefined.  So we make \@ produce an error message:
  217. \newhelp\AThelp{@: 
  218. You've apparantly tried to use a macro which begins with ``@''.^^J%
  219. These macros are usually for internal TeXsis functions and should^^J%
  220. not be used casually.  If you really want to use the macro try first^^J%
  221. saying \string\ATunlock.  If you got this message by pure accident^^J%
  222. then something else is wrong.} 
  223. \def\@{\begingroup
  224.     \errhelp=\AThelp                            % longer help message
  225.     \newlinechar=10                             % ^^J is line break
  226.     \errmessage{Are you tring to use an internal @-macro?}\relax
  227.    \endgroup}
  228. %--------------------------------------------------*
  229. % Alternate definition of ~ makes it the same as \0 in math mode.
  230. % You can use it as a space which is the width of a digit, and it
  231. % is a single character in the manuscript file. It behaves as usual
  232. % (a tie, or required space) in non-math mode.
  233. \def~{\ifmmode\phantom{0}\else\penalty10000\ \fi} % tie in math mode too
  234. \def\0{\phantom{0}}                             % \0 is phantom 0 in any font
  235. %%%-------------------------*  \setdigitwid (TO BE REMOVED!)
  236. %%\newdimen\digitwid                              % \digitwid is width of digit
  237. %%\def\setdigitwid{\setbox0=\hbox{0}\digitwid=\wd0}% sets \digitwid
  238. %%\setdigitwid                                    % do it now
  239. %%%-------------------------*
  240. % thinskip (hmode).  This def allows \, to be used in both math 
  241. % and nonmath mode
  242. \def\,{\relax\ifmmode\mskip\the\thinmuskip\else\thinspace\fi}
  243. % Use \topspace in place of \vskip to add space at top of a page 
  244. % (a \vskip by itself is discarded at the top of an empty page).
  245. \def\topspace{\hrule height \z@\vskip}
  246. %--------------------------------------------------*
  247. % COMMENTS:  How to ignore large pieces of text.
  248. % Use \comment to turn most anything into nothing (must have balanced {}!).
  249. % Usage:
  250. %   \comment/* <text to be ignored> */      % the /* and */ are required!
  251. \long\def\comment#1/*#2*/{\relax}               % just read args and do nothing
  252. % \Ignore and \endIgnore are almost the same, but an \endIgnore without
  253. % an \Ignore first is just ignored.  Got that?
  254. \long\def\Ignore#1\endIgnore{\relax}    % read arg to \endIgnore and do nothing
  255. \def\endIgnore{\relax}                  % if actually executed, just do nothing
  256. %  \@comment is for writing % to a file. It expands to '% '.
  257.      
  258. {\catcode`\%=11 \gdef\@comment{% }}
  259. % \REV is used for keeping track of revisions.  Usually it is just a
  260. % speciallized comment, but by changing the definition we print out
  261. % the revision record in the Appendix.
  262. \def\REV{\begingroup                            % Revisions
  263.    \def\endcomment{\endgroup}%                  % to close the \begingroup
  264.    \catcode`\|=12                               % turn off "TeX quotes"
  265.    \catcode`(=12 \catcode`)=12                  % make ( and ) 
  266.    \catcode`[=12 \catcode`]=12                  %  and [ and ] "other"
  267.    \comment}                                    % treat text like a comment
  268. %-------------------------*
  269. % Simple \begin .. \end support (like in LaTeX, yuk):  
  270. % There is a conspiracy to preserve job security for typists by making
  271. % sure one has to  type \begin{thing} and \end{thing} everywhere.  In
  272. % TeXsis it's just \thing and \endthing, but to make these people happy
  273. % we just make \begin{thing} become \thing and similarly for \end{thing}.  
  274. % The \begin starts a group, so that after the \end{thing} \end goes
  275. % back to it's normal definition.
  276. % Note: we don't check that you begin and end the same thing.  After all,
  277. % you might want to say \begin{midfigure} followed by \end{figure}.
  278. \def\begin#1{%          \begin{foo} just becomes \foo
  279.    \begingroup                  % changes to \end are temporary!
  280.      \let\end=\endbegin         % in this group \end will end the \begin
  281.      \expandafter\ifx\csname #1\endcsname\relax\relax % is \thing defined?
  282.         \def\next{\beginerror{#1}}% NO: flag an error
  283.      \else                      %
  284.         \def\next{\csname #1\endcsname}% YES: just invoke it
  285.      \fi\next}
  286. \def\endbegin#1{%  \end{foo} just becomes \endfoo
  287.    \endgroup                    % now \end goes back to normal
  288.    \expandafter\ifx\csname end#1\endcsname\relax\relax % is \endthing defined?
  289.       \def\next{\begingroup\beginerror{end#1}}% % NO: flag an error
  290.    \else                        %
  291.       \def\next{\csname end#1\endcsname}% YES: just invoke it
  292.    \fi\next}
  293. \newhelp\beginhelp{begin: 
  294.     The \string\begin\space or \string\end\space marked above is for a %
  295.     non-existant^^J%
  296.     environment.  Check for spelling errors and such.}
  297. \def\beginerror#1{% \begin{foo} or \end{foo} fail if no \foo or \endfoo
  298.    \endgroup                    % make sure \end is back to normal
  299.    \errhelp=\beginhelp                         % longer help message
  300.    \newlinechar=10                             % ^^J is line break
  301.    \errmessage{Undefined environment for \string\begin\space or \string\end}}
  302. %--------------------------------------------------*
  303. % \spine{text} makes a boxed label for the spine of a 3 ring binder
  304. % This is printed in \Landscape mode, 24pt type, and with a ruled box
  305. % around it.  The box will be at least 15cm long, but will extend
  306. % if the text requires more space.  Instructions for installing the
  307. % label in the spine of a binder are printed, but if more than one
  308. % label is created the instructions are only printed once.
  309. \def\spine#1{\spineSetup
  310.    \setbox0=\hbox{\twentyfourpoint\bf\quad #1\quad}%    
  311.    \dimen0=\wd0                                 % 
  312.    \ifdim\wd0<15cm \dimen0=15cm\fi              %  Minimum size 15cm
  313.    \vskip 1cm plus 2cm                          %
  314.    \tightboxit{\vbox to 1in{\vfill              %
  315.      \hbox to \dimen0{\hfil\box0\hfil}%         %
  316.      \vfill}}%                                  %
  317.    \vskip 1cm plus 2cm}                         %
  318. \def\spineSetup{%  once-only setup for \spine
  319.    \Landscape                                   % Landscape mode
  320.    \headline={\LandscapeSpecial}%               % and force it every page
  321.    \vbox{\hsize=15cm                            %
  322.      \bigskip\bigskip                           %
  323.      \tenpoint\parskip=\smallskipamount         %
  324.      \noindent                                  %
  325.      How to install the spine label on a binder:
  326.      \item{1.}
  327.      Cut out the label around the outside of the 
  328.      bounding ruled box.  Leave extra paper
  329.      (about 1.5cm or so) on the RIGHT side.
  330.      \item{2.}
  331.      Obtain a long thin plastic ruler or similar object which can 
  332.      slide down the pocket on the binder spine.
  333.      \item{3.}
  334.      Put the label along the ruler, face up, and fold the extra tab of paper
  335.      on the right of the label over the end of the ruler.
  336.      \item{4.}
  337.      Slide the ruler, with the label on it, down the spine of the binder.
  338.      When the label is in place remove the ruler.  The label will remain.
  339.      \bigskip\bigskip
  340.    \gdef\spineSetup{\relax}              % only show once
  341.    }}
  342. %--------------------------------------------------*
  343. %   Macros to do an unexpanded write. This is like \write except that
  344. % the second argument is not expanded -- \noexpand is put in front of 
  345. % every token in #2.  This works by using \aftergroup to add to a list 
  346. % of things on a stack, which are then dumped out together after the 
  347. % \endgroup.  This is slightly modified from TechRpt.  BE VERY CAREFUL
  348. % IF YOU MODIFY THIS IN ANY WAY, IT IS RATHER SENSITIVE.  -EAM
  349. \def\\{\global\let\@stoken= }\\ 
  350. \long\def\unexpandedwrite#1#2{% write tokens #2 to #1 but do not expand them
  351.    \def\@finwrite{\immediate\write#1}%  % to write to the file
  352.    \begingroup                          % begin collecting tokens on stack
  353.     \aftergroup\@finwrite               %
  354.     \aftergroup{\relax                  % put \write{ on the stack
  355.     \@sanitize#2\endsanity              % now process the argument list
  356.     \aftergroup}\relax                  % put closing } on the stack
  357.    \endgroup                            % now dump token list on stack!
  358. % \writeNX is the same as \unexpandedwrite but without the \immediate
  359. \long\def\writeNX#1#2{% write tokens #2 to #1 but do not expand them
  360.    \def\@finwrite{\write#1}%            % to write to the file
  361.    \begingroup                          % begin collecting tokens on stack
  362.     \aftergroup\@finwrite               %
  363.     \aftergroup{\relax                  % put \write{ on the stack
  364.     \@sanitize#2\endsanity              % puts \NX\token on stack from #2
  365.     \aftergroup}\relax                  % put closing } on the stack
  366.    \endgroup                            % now dump token list from stack!
  367. % Saying \@sanitize <stuff> \endsanity will take all the tokens
  368. % in <stuff> and put them on the stack, with control sequences
  369. % prefaced by \noexpand
  370. \def\@sanitize{\futurelet\next\@sanswitch} 
  371. \def\@sanswitch{%        decides what to do with various types of tokens
  372.     \ifx\next\endsanity\relax           % if \endsanity then we'll quit
  373.     \else\ifcat\noexpand\next\@stoken   % if token is a space,
  374.         \aftergroup\space\let\next=\@eat%   write \space and eat token
  375.     \else\ifcat\noexpand\next\bgroup    % if token is \bgroup
  376.         \aftergroup{\let\next=\@eat     %   write { and eat it
  377.     \else\ifcat\noexpand\next\egroup    % if token is \egroup
  378.         \aftergroup}\let\next=\@eat     %   write a } and eat it
  379.      \else                              % otherwize
  380.         \let\next=\@copytoken           %   just copy to the stack with \NX
  381.      \fi\fi\fi\fi 
  382.      \next}                             % do it to the token
  383. % \@eat ignores the \next token and goes on to the 
  384. % next one in the argument list
  385. \def\@eat{\afterassignment\@sanitize\let\next= } 
  386. % \@copytoken copies one token to the stack with \aftergroup,
  387. %  then calls \@sanitize to get the next one following.
  388. \long\def\@copytoken#1{% write token to stack, unexpanded    
  389.     \ifcat\noexpand#1\relax             % if token is a control sequence
  390.         \aftergroup\noexpand            %   preface with \noexpand
  391.     \else\ifcat\noexpand#1\noexpand~\relax % if token is an active character
  392.         \aftergroup\noexpand            %   preface with \noexpand
  393.     \fi\fi                              %
  394.     \aftergroup#1\relax                 % put the next token on the list
  395.     \@sanitize}                         % do next token from argument...
  396. \def\endsanity\endsanity{}              % just marks the end of token list
  397. %======================================================================*
  398. % CHECKPOINT / RESTART -                (C) copyright 1986 by Eric Myers
  399. % The \checkpoint and \restart macros allow you to save important information
  400. % like the page number, chapter number, equation number, etc...  and then
  401. % begin with those values on a new run.
  402. % Dependencies: TXSmacs.tex
  403. % ----------------------------
  404. \message{Checkpoint/Restart.}
  405. % I/O initialization:
  406. \newwrite\checkpointout                 % output for checkpoint/restart
  407. % ----------------------------
  408. % \checkpoint writes all restart info to the file #1.chk
  409. \def\checkpoint#1{\emsg{\@comment\NX\checkpoint --> #1.chk}%
  410.     \immediate\openout\checkpointout= #1.chk
  411.     \@checkwrite{\pageno}%
  412.     \@checkwrite{\chapternum}%
  413.     \@checkwrite{\corollarynum}%
  414.     \@checkwrite{\definitionnum}%
  415.     \@checkwrite{\eqnum}%
  416.     \@checkwrite{\fignum}%
  417.     \@checkwrite{\lemmanum}
  418.     \@checkwrite{\refnum}%
  419.     \@checkwrite{\sectionnum}%
  420.     \@checkwrite{\subsectionnum}%
  421.     \@checkwrite{\tabnum}%
  422.     \@checkwrite{\theoremnum}%
  423.     \immediate\closeout\checkpointout}%
  424. % \@checkwrite writes the value of #1 to the file, such that the value
  425. %  is restored when the file is read with \Input
  426. \def\@checkwrite#1{\edef\tnum{\the #1}%
  427.      \immediate\write\checkpointout{\NX #1 = \tnum}}%
  428. % ----------------------------
  429. % \restart{filename} reloads the checkpoint from the file #1.chk
  430. \def\restart#1{\relax
  431.     \immediate\closeout\checkpointout           % close file, just in case
  432.     \ATunlock                                   % make sure @ sign is a letter
  433.     \Input #1.chk \relax                        % read .CHK file in
  434.     \@firstrefnum=\refnum                       % get reference number and
  435.     \advance\@firstrefnum by \@ne               % set first ref counter
  436.     \ATlock}                                    % @ is protected again
  437. \let\restore=\restart                           % alternate name for \restart
  438. % ----------------------------
  439. % \endstat prints out pertinent restart info on the terminal and
  440. % in the .log file.  Useful at the end of a run.
  441. \def\endstat{%
  442.    \emsg{\@comment LAST PAGE      NUMBER IS \the\pageno.}%
  443.    \emsg{\@comment LAST CHAPTER   NUMBER IS \the\chapternum.}%
  444.    \emsg{\@comment LAST EQUATION  NUMBER IS \the\eqnum.}%
  445.    \emsg{\@comment LAST FIGURE    NUMBER IS \the\fignum.}%
  446.    \emsg{\@comment LAST REFERENCE NUMBER IS \the\refnum.}%
  447.    \emsg{\@comment LAST SECTION   NUMBER IS \the\sectionnum.}%
  448.    \emsg{\@comment LAST TABLE     NUMBER IS \the\tabnum.}%
  449.    \tracingstats=1}%
  450. %  \@comment is for writing % to a file.  It expands to '% '
  451.      
  452. {\catcode`\%=11 \gdef\@comment{% }}
  453. %======================================================================*
  454. % RANDOM USEFUL MACROS.  Most of these are useful only to hackers and are
  455. % used by macros in this package.  Some of them are just general little
  456. % goodies that don't seem to fit anywhere else.
  457. % \theBlank creates a blank line to fill in ``the blank''
  458. \def\theBlank#1{\nobreak\hbox{\vbox{\hrule width #1\relax}}}
  459. % \Romannumeral gives uppercase roman numerals, of course
  460. \def\Romannumeral#1{\uppercase\expandafter{\romannumeral #1}}
  461. % \monthname{n} gives the English name for month number n
  462. \def\monthname#1{\ifcase#1 \errmessage{0 is not a month}
  463.     \or January\or February\or March\or April\or May\or June\or 
  464.     July\or August\or September\or October\or November\or
  465.     December\else \errmessage{#1 is not a month}\fi}
  466. % \leftpar makes an argument into a raggedleft paragraph
  467. % uses the same technique as figure captions
  468. \def\leftpar#1{%
  469.     \setbox\@capbox=\vbox{\normalbaselines
  470.     \noindent #1\par
  471.         \global\@caplines=\prevgraf}%
  472.     \ifnum \@ne=\@caplines
  473.         \leftline{#1}\else
  474.         \hbox to\hsize{\hss\box\@capbox\hss}\fi}
  475. % We've added a few more active characters, so we have to modify \dospecials
  476. \def\dospecials{\do\ \do\\\do\{\do\}\do\$\do\&\do\"\do\(\do\)\do\[\do\]%
  477.   \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~}
  478. % \loosebox put a loose  box around a box.
  479. \def\loosebox#1{%
  480.     \vbox{\vskip\jot
  481.         \hbox{\hskip\jot #1\hskip\jot}%
  482.         \vskip\jot}}
  483. % \tightbox draws a rule box around the box #1 without any added space
  484. \def\tightbox#1{\vbox{\hrule\hbox{\vrule\vbox{#1}\vrule}\hrule}}
  485. \let\tightboxit=\tightbox               % synonym
  486. % global loop:
  487. \def\gloop#1\repeat{\gdef\body{#1}\iterate}
  488. % \apply a macro to a list of arguments
  489. % Usage:
  490. %   \apply\macro{list of arguments, separated by commas}
  491. % It is possible to determine whether your at the last argument with
  492. %   \iflastarg true text \else false text \fi
  493. % Since \apply uses global definitions, \apply's can't be nested
  494. % \empty is defined as {} in PLAIN
  495. \newif\iflastarg\lastargfalse
  496. \def\car#1,#2;{\gdef\@arg{#1}\gdef\@args{#2}}
  497. \def\@apply{%
  498.     \iflastarg
  499.     \else
  500.         \XA\car\@args;%                   get first argument
  501.         \islastarg
  502.         \XA\@fcn\XA{\@arg}%
  503.         \@apply
  504.     \fi}
  505. \def\apply#1#2{%
  506.     \gdef\@args{#2,}\let\@fcn#1%
  507.     \islastarg
  508.     \@apply
  509.     }
  510. \def\islastarg{\ifx \@args\empty\lastargtrue\else\lastargfalse\fi}%
  511. % miscelaneous stuff:
  512. \def\@seppuku{\errmessage{Interwoven alignment preambles are not allowed.}\end}
  513. \Ignore
  514. %---------------------------------
  515. % \uppercase takes place in TeX's stomach, so it can be difficult to
  516. % make the VALUE of a control sequence uppercase.  The following code
  517. % will do so, defining \tok to contain the uppercase value of the argument
  518. % which may be a control sequence.
  519. \def\@UC#1{\uppercase{\def\tok{#1}}}
  520. \def\UC#1{\XA\@UC\XA{#1}}
  521. \def\@LC#1{\lowercase{\def\tok{#1}}}
  522. \def\LC#1{\XA\@LC\XA{#1}}
  523. \endIgnore
  524. %>>> EOF TXSmacs.tex <<<
  525.