diff options
Diffstat (limited to 'obsolete/macros/latex209/contrib/multido')
-rw-r--r-- | obsolete/macros/latex209/contrib/multido/md-doc.dvi | bin | 0 -> 30332 bytes | |||
-rw-r--r-- | obsolete/macros/latex209/contrib/multido/md-doc.tex | 459 | ||||
-rw-r--r-- | obsolete/macros/latex209/contrib/multido/md-make.tex | 83 | ||||
-rw-r--r-- | obsolete/macros/latex209/contrib/multido/md-read.me | 60 | ||||
-rw-r--r-- | obsolete/macros/latex209/contrib/multido/multido.doc | 907 | ||||
-rw-r--r-- | obsolete/macros/latex209/contrib/multido/multido.readme | 24 | ||||
-rw-r--r-- | obsolete/macros/latex209/contrib/multido/multido.sty | 2 | ||||
-rw-r--r-- | obsolete/macros/latex209/contrib/multido/multido.tex | 563 |
8 files changed, 2098 insertions, 0 deletions
diff --git a/obsolete/macros/latex209/contrib/multido/md-doc.dvi b/obsolete/macros/latex209/contrib/multido/md-doc.dvi Binary files differnew file mode 100644 index 0000000000..74803b62d7 --- /dev/null +++ b/obsolete/macros/latex209/contrib/multido/md-doc.dvi diff --git a/obsolete/macros/latex209/contrib/multido/md-doc.tex b/obsolete/macros/latex209/contrib/multido/md-doc.tex new file mode 100644 index 0000000000..ed44f56a26 --- /dev/null +++ b/obsolete/macros/latex209/contrib/multido/md-doc.tex @@ -0,0 +1,459 @@ +%%%%%%%%%%%%%%%%%%%%%%%% md-doc.tex Version 1.0, 92/09/28 %%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%% COPYING %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% +%% COPYRIGHT 1992, by Timothy Van Zandt, tvz@Princeton.EDU +%% +%% Copying of part or all of this file is allowed under the following +%% conditions only: +%% (1) You may freely distribute unchanged copies of the file. Please +%% include the documentation when you do so. +%% (2) You may modify a renamed copy of the file, but only for personal +%% use or use within an organization. +%% (3) You may copy fragments from the file, for personal use or for +%% distribution, as long as credit is given where credit is due. +%% +%% You are NOT ALLOWED to take money for the distribution or use of +%% this file or modified versions or fragments thereof, except for +%% a nominal charge for copying etc. +%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% +%% multido.tex contains a loop macro, \multido, that supports floating +%% point addition and has a nice interface. Among other things, it +%% is useful for pictures and putting numbers on axes. multido.tex +%% is compatible with most TeX macro packages. Name a copy of the file +%% multido.sty if you want to use as a LaTeX style option. +%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GETTING MULTIDO %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% +%% The complete multido.tex distribution is available in .tar.Z form from +%% the /pub directory at Princeton.EDU. multido.tex is also available +%% at various TeX archives. However, all you really need is multido.tex +%% and md-doc.tex. +%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + %%%%%%%%%%%%%%%%%%%%%%%%%% PRINTING THE DOCUMENTATION +%%%%%%%%%%%%%%%%%%%%%%%% %% +%% multido.tex is also distributed with the documentation already +%% typeset. Check the /pub directory at Princeton.EDU if you can +%% handle .tar.Z files. +%% +%% This file contains the Usage Notes, Run with LaTeX with or without NFSS. +%% +%% If you include the doc style option, the documented code +%% in multido.doc is also printed at the end. For this, +%% you must have the files doc.sty and gind.ist from Frank +%% Mittelbach's doc package (try the /soft/tex/latex-supported/doc +%% directory at ftp.uni-stuttgart.de ). This documented was originally +%% prepared using v1.7k (92/08/24) of doc.sty. +%% +%% To make an index on UNIX using makeindex, resolve cross-references and +%% give the command: +%% makeindex -s gind.ist multido.idx +%% and run the file again. The index is only for the documented code. +%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%% BEGIN PREAMBLE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% +\documentstyle[12pt]{article} +\input multido.tex +\catcode`\@=11 +%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%% DOC? STUFF %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% +%% Check whether doc.sty has been input. If not, code won't be printed. +%% \CodeLineIndex can only be used in preamble. Other code-specific +%% preamble stuff has been left to the end of this file. +%% +\@ifundefined{StopEventually}% + {\def\StopEventually{\end{document}}}% + {\CodelineIndex} +%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%% PAGE PARAMETERS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% +\setlength{\parindent}{0pt} % paragraph indent +\setlength{\parskip}{4pt plus 1pt minus 1pt} +\setlength{\oddsidemargin}{4pc} +\setlength{\evensidemargin}{4pc} +\setlength{\topmargin}{-2.5pc} +\setlength{\headheight}{12pt} % height of running head +\setlength{\headsep}{20pt} % distance between header and text +\setlength{\textheight}{54pc} % height of text on page +\setlength{\textwidth}{35pc} % total width of a page +%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%% VERBATIM %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% +%% This is good for examples, using \verb or whatever explicitly. +\def\Ex{\quote\tt} +\def\endEx{\endquote} +%% +%% In the verbatim environment, \trivlist is changed to \list, so that +%% verbatim code is offset from the left margin. +%% +\def\@verbatim{% + \list{}{} \item[]% + \leftskip\@totalleftmargin\rightskip\z@ + \parindent\z@\parfillskip\@flushglue + \@@par\leavevmode\parskip=\z@ + \def\par{\leavevmode\null\@@par}% + \obeylines + \let\do\@makeother \dospecials\catcode`\>=14\tt} +\def\endverbatim{\endlist} +%% +\def\m#1{{\rm\it #1}} % For just putting things in italics (m=>meta>) +\def\M#1{{\tt\{}\m{#1}{\tt\}}} % Argument is in italic, enclosed in tt braces. +\def\N#1{{\tt\string#1}} % For in-line macro names +\catcode`\>=13\def>{} % Now we can write \LaTeX> without problem. +%% +%% This is adapted from Mittelbach's doc.sty: +\def\MyShortVerb#1{% + \expandafter + \xdef\csname cc\string#1\endcsname{\the\catcode`#1}% + \begingroup + \catcode`\~\active \lccode`\~`#1% + \lowercase{% + \global\expandafter\let + \csname ac\string#1\endcsname~% + \gdef~{\verb~}}% + \endgroup + \global\catcode`#1\active} +%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +%%%%%%%%%%%%%%%%%%%%%%%%%% SECTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% +%% Section headings use customizable fonts, leave less space above +%% and below, and may overhang on left. +%% +\def\section{\@startsection{section}{1}{\sechang}{-3ex plus -1ex + minus -.2ex}{1.5ex plus .2ex}{\secfont}} +\def\subsection{\@startsection{subsection}{2}{\subsechang}{-2.75ex plus -1ex + minus -.2ex}{1.25ex plus .2ex}{\subsecfont}} +\newdimen\sechang +\newdimen\subsechang +\sechang=-.6in +\subsechang=-.375in +\def\secfont{\Large\bf} % Section headings +\def\subsecfont{\tt\large} % Subsection heading +%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +%%%%%%%%%%%%%%%%%%%%%% DATES, VERSIONS AND TITLES %%%%%%%%%%%%%%%%%%%%%%%%%%% +%% +\def\expanddate#1/#2/#3/{\number#3{} \month=#2 \ifcase\month\or + January \or February \or March \or April \or May \or June \or + July \or August \or September \or October \or November \or December \fi + 19#1} +\def\thefiledate{\expandafter\expanddate\filedate/} +\date{Version \fileversion\\ \thefiledate} +\def\@maketitle{\newpage + \null + \begin{center} + {\Large\bf \@title \par} + \vskip 1.2em {\lineskip .5em + \begin{tabular}[t]{c}\@author\end{tabular}\par} + \vskip .8em {\@date}% + \end{center} + \par + \vskip .5em} +%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%% PAGE STYLE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% +\pagestyle{myheadings} +\markright{Documentation for multido.tex \hfill + v.\fileversion\hskip 1em \thefiledate\hfill}% +%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%% END PREAMBLE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% +\MyShortVerb\" +\catcode`\@=12 +\begin{document} +%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\title{Documentation for multido.tex:\\[2pt] + A loop macro for Generic \protect\TeX} +\author{Timothy Van Zandt% + \thanks{Author's address: Department of Economics, Princeton University, + Princeton, NJ 08544-1021, USA. Internet: {\tt tvz@Princeton.EDU}}} +\maketitle + + +\section{Usage notes} + + "multido.tex"/"multido.sty" contains the \N\multido> macro, which is a loop +facility for Generic TeX. This macro happens to be useful for drawing +pictures, and was originally developed for the PSTricks +package,\footnote{PSTricks is an extensive collection of PostScript-based +macros for Generic TeX. It is available from the /pub directory at +Princeton.EDU, and \TeX> archives.} but you can use it for other purposes as +well. + + A special feature is support of fixed-point addition. For example, PSTricks +uses the \N\multido> to put numbers on axes, much like in the following +\LaTeX> example: + PSTricks uses "\multdo" internally to put numbers on axes, much like in this +\LaTeX> example: +\begin{verbatim}> +\setlength{\unitlength}{1cm} +\small +\begin{picture}(8,1)(0,-.5) +\put(0,0){\vector(1,0){8}} +\multido{\i=0+1,\n=0+0.25}{8}{% + \put(\i,-.1){\line(0,1){.2}} + \put(\i,-.2){\makebox[t](0,0){\n}}} +\end{picture} +\end{verbatim} +\begin{center}\leavevmode +\setlength{\unitlength}{1cm} +\small +\begin{picture}(8,1)(0,-.5) +\put(0,0){\vector(1,0){8}} +\multido{\i=0+1,\n=0+0.25}{8}{% + \put(\i,-.1){\line(0,1){.2}} + \put(\i,-.2){\makebox(0,0)[t]{\n}}} +\end{picture} +\end{center} + +The general syntax for \N\multido> is: +\begin{Ex} +"\multido"\M{variables}\M{repetitions}\M{stuff} +\end{Ex} + \m{stuff} is whatever you want repeated; it can be any balanced \TeX{} input. +\m{repetitions} is the number times \m{stuff} is repeated. + + The first argument is the interesting one. \m{variables} is a comma-separated +list of variable declarations.\footnote{Don't use commas to mark the decimal +point within the \protect\m{variables} argument, as they will be confused for +delimiters.} Each variable declaration is of the form: +\begin{center}\em + variable "=" initial value "+" increment +\end{center} + \m{variable} is a command sequence that can be used in \m{stuff}. It is +initially set to {\em initial value}, and is then incremented by {\em +increment} with each repetition. + + The first letter of the variable name determines the variable type. There are +four variable types: +\begin{description} + \item[Dimension (d or D)] The initial value and the increment should be +dimensions (lengths, in \LaTeX> parlance). The substitution text is a +dimension, with "sp" units. E.g., "\dx=4cm+5pt". + + \item[Number (n or N)] The initial value and increment should be integers or +numbers with the same number of digits to the right of the decimal. The one +exception is that it is always OK for the initial value to be an integer. +There can be at most 8 digits on each side of the decimal. The substitution +text is a number, with fixed-point addition. E.g., "\n=3+7.05", +"\Nx=5.30+-1.25". + + \item[Integer (i or I)] The initial value and increment should be integers. +This gives the same result as using a number variable, but it is faster. E.g., +"\I=2+-1". + + \item[Real (r or R)] The initial value and increment should be integers or +numbers with at most 4 digits on each side of the decimal. The substitution +text is a number, but with floating point addition and occasional small +errors. This gives a less satisfactory result than using a number variable, +but it is faster. E.g., "\ry=4.2+1.05". +\end{description} + + Here are some examples that illustrate how the substitution text is +determined: +\begin{quote} +"\multido{}{10}{\TeX\ }"\\[3pt] +\hbox to 2em{}\multido{}{10}{\TeX\ }{}\\[8pt] +"\multido{\d=2pt+3pt}{5}{\d, }"\\[3pt] +\hbox to 2em{}\multido{\d=2pt+3pt}{5}{\d, }{}\\[8pt] +"\multido{\n=2+3}{10}{\n, }"\\[3pt] +\hbox to 2em{}\multido{\n=2+3}{10}{\n, }{}\\[8pt] +"\multido{\i=2+3}{10}{\i, }"\\[3pt] +\hbox to 2em{}\multido{\i=2+-3}{10}{\i, }{}\\[8pt] +"\multido{\r=2+3.05}{6}{\r, }"\\[3pt] +\hbox to 2em{}\multido{\r=2+3.05}{6}{\r, }{}\\[8pt] +"\multido{\n=2.00+3.05}{8}{\n, }"\\[3pt] +\hbox to 2em{}\multido{\n=2.00+-3.05}{8}{\n, }{} +\end{quote} + +Here are some details about the choice of names: +\begin{itemize} + \item Your computer won't explode if you use names that conflict with \TeX> +internal commands, but you might want to check name conflicts if you get +inexplicable errors. The command "\MultidoCheckNames" can be useful in this +case. It causes \N\multido> to report an error whenever you use a variable +name that is already defined. But see the next item. + \item The whole \N\multido> loop is grouped. This means, e.g., that although +"\i" is a Plain \TeX{} command sequence (giving a dotless ``\i''), you can use +the variable "\i" if you do not use any dotless i's in \m{stuff} (and if you +do not use "\MultidoCheckNames"). +\end{itemize} + +Here are a few more details: +\begin{itemize} +\item \N\Multido> commands can be nested. + \item Spaces after a \N\multido> command are ignored. This makes \N\multido> +more hospitable for pictures. + \item Spaces between the various parts of the \m{variables} argument are +ignored. +\end{itemize} + + And finally here a few special features, some of which are of interest mainly +macro writers and other \TeX nicians: +\begin{itemize} + \item The material that is repeated is not grouped, so that you can insert +your own recursive routines. + \item There is a variant, "\mmultido", which works just like "\multido" +except that the variables are all incremented once before starting. + \item There are variants, "\Multido" and "\MMultido" of "\multido" and +"\mmultido", resp., that do not group the whole loop. This can be useful, +e.g., for making entries in an alignment environment. However, these cannot be +nested within any "\multido" macro. + \item If the number of repetitions is a negative number, the variables are +incremented backwards. + \item The count register "\multidocount" keeps track of the number of the +iterations. + \item The command "\multidostop" causes the "\multido" loop to quit at the +end of the current iteration. +\item Fixed point addition is performed by \N\FPadd> and \N\FPsub: +\begin{Ex} +"\FPadd"\M{num1}\M{num2}\M{cs}\\ +"\FPsub"\M{num1}\M{num2}\M{cs} +\end{Ex} + \m{num2}\/ is added to or subtracted from \m{num1}, and the answers is stored +in the command sequence given as the third argument. The rules about decimals +and so on that apply to number variables apply here as well. E.g., after +\begin{Ex} + "\FPsub{1.75}{-0.15}{\answer}" +\end{Ex} +the definition of "\answer" is 1.90. +\end{itemize} + +\clearpage + +%%%%%%%%%%%%%%%%%% STOP HERE IF DOC.STY NOT INPUT%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% +\StopEventually{} +%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%% BEGIN CODE-SPECIFIC PREAMBLE %%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% +\catcode`\@=11 +%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%% CHANGE TO MACRO ENVIRONMENTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% +%% A change to the doc.sty's macro environment. +%% Prints macro names like subsections, instead of as marginal notes. +%% Argument is comma separated list of macro names. +%% No nested macro environments. +%% +%% WHY: Don't need as many \begin{macro} ... \end{macro}. +%% Works even there isn't anything between \begin{macro} and +%% \begin{macrocode}. +%% +\newif\iffirst@macroname +\newif\ifnestedmacro +\def\macro{% + \ifnum\macro@level=\z@ + \def\next{\MakePrivateLetters \m@cro@}% + \else + \def\next{\@latexerr{Nested \string\begin{macro}}\@eha + \endgroup\end{macro}\macro@level=\z@\begin{macro}} + \fi + \next} +\def\m@cro@#1{% + \first@macronametrue + \m@@cro@@#1,\@nil,} +\def\m@@cro@@#1,{% + \def\@tempa{#1}\def\@tempb{\@nil}% + \ifx\@tempa\@tempb + \let\next\finishm@@cro@@ + \else + {\advance\c@CodelineNo\@ne\SpecialMainIndex{#1}\nobreak}% + \DoNotIndex{#1}% + \iffirst@macroname + \edef\saved@macronames{\string#1}% + \first@macronamefalse + \else + \def\comma{\noexpand\comma}% + \edef\saved@macronames{\saved@macronames\comma\string#1}% + \fi + \let\next\m@@cro@@ + \fi + \next} +\def\finishm@@cro@@{% + \advance\macro@level\@ne + \def\comma{{\rm, }}% + \subsection*{\tt\saved@macronames}} +%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%% DO NOT INDEX %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% +\DoNotIndex{\ ,\!,\[,\\,\],\^,\`,\{,\},\~} +\DoNotIndex{\@ifundefined,\@namedef,\@spaces,\@tempa,\@tempb} +\DoNotIndex{\@warning,\active} +\DoNotIndex{\begingroup,\catcode,\char,\csname,\def,\do} +\DoNotIndex{\docdate,\dospecials,\edef,\else,\endcsname,\endgroup} +\DoNotIndex{\expandafter,\fi,\filedate,\fileversion} +\DoNotIndex{\gdef,\if,\ifcat} +\DoNotIndex{\ifx,\immediate,\lccode,\let} +\DoNotIndex{\lowercase,\next,\noexpand} +\DoNotIndex{\relax,\space,\the} +\DoNotIndex{\toks@,\count@,\dimen@,\dimen@ii} +\DoNotIndex{\theatcode,\string,\t,\@empty,\@nil,\@nnil,\advance} +\DoNotIndex{\dimen@i,\@,\endinput,\errhelp,\errmessage,\global,ifnum} +\DoNotIndex{\p,\number,\newtoks,\ignorespaces,\message,\multido@temp} +\DoNotIndex{\newcount,\xdef,\z@,\@ne,\tw@,\number,\undefined,\ifnum} +%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%% OTHER DOC PARAMETERS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% +\setcounter{IndexColumns}{2} % two column index; + +%\DisableCrossrefs +\EnableCrossrefs + + \IndexPrologue{This index is only for the documented code. Underlined numbers +refer roughly to the line number of the entry's definition, and all others +indicate code lines where it is used.} +%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%% END CODE-SPECIFIC PREAMBLE %%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% +\catcode`\@=12 +%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\section{Documented code} + +\DocInput{multido.doc} + +\clearpage + +\PrintIndex + +\end{document} diff --git a/obsolete/macros/latex209/contrib/multido/md-make.tex b/obsolete/macros/latex209/contrib/multido/md-make.tex new file mode 100644 index 0000000000..5cdd5d72c7 --- /dev/null +++ b/obsolete/macros/latex209/contrib/multido/md-make.tex @@ -0,0 +1,83 @@ +%% md-make.tex 1992 tvz@Princeton.EDU +%% +%% Run Plain TeX or LaTeX on this file to create a macro file multido.tex +%% from multido.doc, stripped of comments. +%% +%% This is basically a take-off from F. Mittelbach's docstrip.tex +%% +%% This macros can be used for stripping comments from any TeX file. +%% Just change these two lines: +\def\outfile{multido.tex} +\def\infile{multido.doc} + +\catcode`\@=11 +\expandafter\ifx\csname @latexerr\endcsname\relax\else\let\end\@@end\fi + +\newread\@infile +\newwrite\@outfile + +\def\typeout{\immediate\write16} +\typeout{} +\typeout{Preparing to make stripped macro file \outfile.} + +\immediate\openin1=\outfile\relax +\ifeof1\else + \typeout{% + File `\outfile' exists and will be overwritten if in current directory!!!} +\fi + +\def\check@@OK#1#2\@nil{\ifx#1y\else\expandafter\end\fi} + +\typeout{Make `\outfile'? (y=yes, n=no)} +\read16 to\OK +\expandafter\check@@OK\OK\@nil + +\newif\ifflag + +{\catcode`\%=12\gdef\%{%}} +\edef\@@percent{\%\%} + +\def\process@line{\expandafter\process@@line\inline\relax\relax\@nil} +\def\process@@line#1#2#3\@nil{% + \def\temp{#1}% + \ifx\temp\% + \def\temp{#1#2}% + \ifx\temp\@@percent\owrite\inline\fi + \else + \owrite\inline + \fi} + +\def\owrite#1{\immediate\write\@outfile{#1}} + +\def\mo#1{\catcode`#1=12\relax} +\def\sanitize{\mo\ \mo\\\mo\$\mo\&\mo\#\mo\^\mo\_\mo\%\mo\~\mo\}\mo\{} + +\def\stripfile{% + \begingroup + \sanitize + \endlinechar-1 + \flagtrue + \loop + \read\@infile to\inline + \ifeof\@infile\flagfalse\fi + \ifflag + \process@line + \repeat + \endgroup} + +\immediate\openout\@outfile\outfile\relax + +\owrite{\%\% This is file `\outfile' generated on + <\the\year/\the\month/\the\day>.} +\owrite{\%\% The original source file was `\infile'.} +\owrite{\%\%} + +\immediate\openin\@infile\infile\relax +\stripfile +\immediate\closein\@infile + +\owrite{\%\%}% +\owrite{\%\% End of file `\outfile'.}% +\immediate\closeout\@outfile + +\end diff --git a/obsolete/macros/latex209/contrib/multido/md-read.me b/obsolete/macros/latex209/contrib/multido/md-read.me new file mode 100644 index 0000000000..7045f62ac1 --- /dev/null +++ b/obsolete/macros/latex209/contrib/multido/md-read.me @@ -0,0 +1,60 @@ +*********************************************************************** +**** "readme" file for multido.tex, v1.0, 92/09/28 **** +*********************************************************************** + +COPYRIGHT 1992, by Timothy Van Zandt, tvz@Princeton.EDU + +COPYING: + + Copying of part or all of any file in the multido.tex distribution + is allowed under the following conditions only: + + (1) You may freely distribute unchanged copies of the files. Please + include the documentation when you do so. + (2) You may modify a renamed copy of any file, but only for personal + use or use within an organization. + (3) You may copy fragments from the files, for personal use or for use + in a macro package for distribution, as long as credit is given + where credit is due. + + You are NOT ALLOWED to take money for the distribution or use of + these files or modified versions or fragments thereof, except for + a nominal charge for copying etc. + +DESCRIPTION: + + multido.tex contains a loop macro, \multido, that supports floating + point addition and has a nice interface. Among other things, it + is useful for pictures and putting numbers on axes. multido.tex + is compatible with most TeX macro packages. + +GETTING MULTIDO + + The complete multido.tex distribution is available in .tar.Z form from + the /pub directory at Princeton.EDU. multido.tex is also available + at various TeX archives. However, all you really need is multido.tex + and md-doc.tex. + +FILES: + + multido.tex: The stripped input file. + multido.sty: Same as multido.tex, but with .sty extension. + multido.doc: Documented code, from which multido.tex was extracted. + md-doc.dvi: Documentation, already typeset. + md-doc.tex: The LaTeX file from which md-doc.dvi was generated. + md-make.tex: For getting multido.tex from multido.doc. + md-read.me: This file. + +PRINTING THE DOCUMENTATION: + + Pages 1-4 of md-doc.dvi are the User's Guide. Pages 5-12 are the + documentated code - probably not worth printing as there isn't much + documentation. + + If this prints out OK for you, then you don't need to typeset md-doc.tex. + +INSTALLATION: + + Put multido.tex and multido.sty where your TeX looks for inputs. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% END md-read.me %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/obsolete/macros/latex209/contrib/multido/multido.doc b/obsolete/macros/latex209/contrib/multido/multido.doc new file mode 100644 index 0000000000..0ce7f128aa --- /dev/null +++ b/obsolete/macros/latex209/contrib/multido/multido.doc @@ -0,0 +1,907 @@ +%\iffalse%%%%%%%%%%%%% BEGIN multido.doc %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\def\fileversion{1.2} +\def\filedate{92/10/12} +% +% DESCRIPTION: +% multido.tex/multido.sty contains a loop macro, \multido, that supports +% fixed point addition and has a nice interface. Among other things, it +% is useful for pictures and putting numbers on axes. multido.tex +% is compatible with most TeX macro packages, including Plain TeX, LaTeX, +% AmSTeX, and Ams-LaTeX. +% +% INSTALLATION: +% This file can be used as the input file. However, stripped input files +% will load faster. To extract these files and typeset the documentation, +% uncomment this line: +%{}\let\endinput\relax +% Plus one or more of the next three lines: +%{}\let\PrintUsage\relax % To typeset Usage Notes. +%{}\let\PrintCode\relax % To typeset Usage Notes and code. +%{}\let\ExtractFiles\relax % To extract stripped multido.tex/multido.sty. +% (Each line should still begin with {}) +% To print Usage Notes and/or Code, you must use LaTeX. +% To extract files only, you can use Plain TeX or LaTeX. +% To typeset code, you must have Frank Mittelbach's doc.sty, preferably +% v1.7k (or later?), and gind.ist to make an index with +% makeindex -s gind.ist multido.idx , if desired. +% +% CHANGES: +% +% V1.1: Fixed bug in FPadd that gave wrong answer for, e.g., 3.4 + -0.2. +% +% V1.2: Make unit optional for dimension variables when using PSTricks. +% +%--------------------------- BEGIN DOCUMENTED CODE ------------------------- +%% +%% File multido.tex, for use with Generic TeX. +%% +%% COPYRIGHT 1992, by Timothy Van Zandt, tvz@Princeton.EDU +%% +%% Copying of part or all of this file is allowed under the following +%% conditions only: +%% (1) You may freely distribute unchanged copies of the file. Please +%% include the documentation when you do so. +%% (2) You may modify a renamed copy of the file, but only for personal +%% use or use within an organization. +%% (3) You may copy fragments from the file, for personal use or for +%% distribution, as long as credit is given where credit is due. +%% +%% You are NOT ALLOWED to take money for the distribution or use of +%% this file or modified versions or fragments thereof, except for +%% a nominal charge for copying etc. +%% +% \fi +% \CheckSum{528} +% \CharacterTable +% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z +% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z +% Digits \0\1\2\3\4\5\6\7\8\9 +% Exclamation \! Double quote \" Hash (number) \# +% Dollar \$ Percent \% Ampersand \& +% Acute accent \' Left paren \( Right paren \) +% Asterisk \* Plus \+ Comma \, +% Minus \- Point \. Solidus \/ +% Colon \: Semicolon \; Less than \< +% Equals \= Greater than \> Question mark \? +% Commercial at \@ Left bracket \[ Backslash \\ +% Right bracket \] Circumflex \^ Underscore \_ +% Grave accent \` Left brace \{ Vertical bar \| +% Right brace \} Tilde \~} +% +% Yes, the documentation is pretty scimpy. +% +% These macros use \TeX{} primitives, plus the Plain \TeX{} commands: +% \begin{quote} +% "\dimen@", "\dimen@i", "\count@", "\newcount", "\newtoks", "\@ne", +% "\tw@", and "\@z@". +% \end{quote} +% +% Check whether file has been loaded already. +% \begin{macrocode} +\expandafter\ifx\csname multido@\endcsname\relax\else + \expandafter\endinput +\fi +% \end{macrocode} +% +% Identify the file on the terminal: +% \begin{macrocode} +\message{\space\space v\fileversion\space\space + \filedate\space\space <tvz>} +% \end{macrocode} +% +% Take care of the catcode of "@": +% \begin{macrocode} +\edef\MultidoAtCode{\the\catcode`\@} +\catcode`\@=11 +% \end{macrocode} +% +% These are some hacks borrowed from PSTricks, which are loaded if PSTricks is +% not being used. "\@dimtonum" strips the value of "#1", a dimension register, +% of the "pt", and assigns the result to "#2", a command sequence. +% \begin{macrocode} +\expandafter\ifx\csname @pstrickserr\endcsname\relax + \def\@empty{} + \def\@nnil{\@nil} + \def\@dimtonum#1#2{\edef#2{\@@dimtonum#1}} + \def\@@dimtonum#1{\expandafter\@@@dimtonum\the#1} + {\let\@nnil\expandafter\catcode`\p=12\catcode`\t=12 + \global\@nnil\def\csname @@@dimtonum\endcsname#1pt{#1}} +\fi +% \end{macrocode} +% +% \begin{macro}{\multido@count,\multidocount} +% "\multido@count" stores the number of repetitions. "\multidocount" keeps +% track of the iteration. These are also used locally as scratch counters by +% "\FPadd@". +% \begin{macrocode} +\newcount\multido@count +\newcount\multidocount +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\multido@stuff} +% "\multido@stuff" is used to store the \m{stuff} that is to be repeated. +% \begin{macrocode} +\newtoks\multido@stuff +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\multido,\mmultido,\Multido,\MMultido} +% \begin{macrocode} +\def\multido{\multido@{}{\begingroup}{\endgroup}} +\def\mmultido{\multido@{\multido@stepvar}{\begingroup}{\endgroup}} +\def\Multido{\multido@{}{}{}} +\def\MMultido{\multido@{\multido@stepvar}{}{}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\multido@} +% "\multido@initvar" processes the variable declarations, initializing the +% value of the variables and defining "\multido@stepvar" to increment the +% variables with each repetition. "\multido@count" is set to the number of +% repetitions. +% \begin{macrocode} +\def\multido@#1#2#3#4#5#6{%\ + #2% + \multido@count=#5\relax + \def\multido@stepvar{}% + \def\do{\noexpand\do\noexpand}% + \multido@initvar#4,\@nil,% + \let\do\noexpand + \edef\multido@stepvar{\multido@stepvar}% + \ifnum\multido@count<\z@\multido@count=-\multido@count\fi + \multidocount=1\relax + #1% + \multido@stuff{#6}% + \multido@loop + #3% + \ignorespaces} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\multido@loop} +% "\multido@loop" does the repetition. +% \begin{macrocode} +\def\multido@loop{% + \the\multido@stuff + \ifnum\multidocount<\multido@count + \advance\multidocount\@ne + \multido@stepvar + \expandafter\multido@loop + \fi} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\multidostop} +% \begin{macrocode} +\def\multidostop{\multidocount=\multido@count} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\multido@initvar,\multido@@initvar,\multido@getvartype} +% "\multido@initvar" passes each variable declaration to "\multido@@initvar". +% \begin{macrocode} +\def\multido@badvar{% + \multido@count=0 + \errhelp{\multido command will be skipped.}% + \errmessage{Bad \string\multido\space variable declaration}} +\def\multido@initvar#1,{% + \def\multido@temp{#1}% + \ifx\multido@temp\@nnil\else + \ifx\multido@temp\@empty\else + \multido@@initvar#1\@nil=+\@nil\relax + \fi + \expandafter\multido@initvar + \fi} +\def\multido@@initvar#1=#2+#3\@nil#4\relax{% + \ifx\@empty#4\@empty + \multido@badvar + \else + \multido@vartype#1\@empty + \ifx\multido@temp\relax + \multido@badvar + \else + \multido@temp{#2}{#3}#1% + \fi + \fi} +\def\multido@vartype#1{% + \ifcat\noexpand\@nil\noexpand#1% + \expandafter\multido@@vartype\string#1\@nil + \else + \let\multido@temp\relax + \fi} +\def\multido@@vartype#1#2#3\@nil{% + \expandafter\let\expandafter\multido@temp + \csname multido@init@#2\endcsname} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\MultidoCheckNames} +% \begin{macrocode} +\def\MultidoCheckNames{% + \let\multido@@@vartype\multido@vartype + \def\multido@vartype##1{% + \ifx\undefined##1% + \multido@@@vartype{##1}% + \else + \errhelp{\multido command will be skipped.}% + \errmessage{Multido variable \string##1 already defined}% + \let\multido@temp\relax + \fi}} +% \end{macrocode} +% \end{macro} +% +% For each variable type, we must now define "\multido@init"\m{vartype}. The +% syntax of these macros is: +% \begin{quote}\tt +% "\multido@init@"\m{vartype}\M{initial value}\M{increment}\M{variable} +% \end{quote} +% and the outcome should be: +% \begin{enumerate} +% \item Set \m{variable} to the initial value. +% \item Invoke "\multido@addtostep"\M{step stuff}, where \m{step stuff} is +% whatever should be done to increment the variable. \M{step stuff} is +% expanded first, with expansion suppressed by "\do". +% \end{enumerate} +% +% \begin{macro}{\multido@addtostep} +% \begin{macrocode} +\def\multido@addtostep#1{\edef\multido@stepvar{\multido@stepvar#1}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\multido@init@d,\multido@init@D,\multido@step@d} +% We start with the variable type for dimensions ("d", "D"). +% \begin{macrocode} +\def\multido@init@d#1#2#3{% + \expandafter\ifx\csname pssetlength\endcsname\relax + \dimen@=#1\relax\dimen@i=#2\relax + \else + \pssetlength\dimen@{#1}\pssetlength\dimen@i{#2}% + \fi + \edef#3{\number\dimen@ sp}% + \ifnum\multido@count<\z@\dimen@i=-\dimen@i\fi + \multido@addtostep{\do\multido@step@d{\do#3}{\number\dimen@i sp}}} +\def\multido@step@d#1#2{% + \dimen@=#1\advance\dimen@#2 + \edef#1{\number\dimen@ sp}}% +\def\multido@init@D{\multido@init@d} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\multido@init@i,\multido@init@I,\multido@step@i} +% Now the variable type for integers ("i", "I"). +% \begin{macrocode} +\def\multido@init@i#1#2#3{% + \count@=#1\relax + \edef#3{\the\count@}% + \count@=#2\relax + \ifnum\multido@count<\z@\count@=-\count@\fi + \multido@addtostep{\do\multido@step@i{\do#3}{\the\count@}}} +\def\multido@step@i#1#2{% + \count@=#1\advance\count@ by #2 + \edef#1{\the\count@}} +\def\multido@init@I{\multido@init@i} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\multido@init@r,\multido@init@R,\multido@step@r} +% Now the variable type for reals ("r", "R"). +% \begin{macrocode} +\def\multido@init@r#1#2#3{% + \dimen@=#1pt + \@dimtonum\dimen@#3% + \dimen@=#2pt + \ifnum\multido@count<\z@\dimen@=-\dimen@\fi + \multido@addtostep{\do\multido@step@r{\do#3}{\number\dimen@ sp}}} +\def\multido@step@r#1#2{% + \dimen@=#1pt\advance\dimen@#2 + \@dimtonum\dimen@#1} +\def\multido@init@R{\multido@init@r} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\multido@init@n,\multido@step@n} +% Now the variable type for numbers ("n", "N"). +% \begin{macrocode} +\def\multido@init@n#1#2#3{% + \edef#3{#1}% + \ifnum\multido@count<\z@\expandafter\FPsub\else\expandafter\FPadd\fi + {0}{#2}\multido@temp + \multido@addtostep{\do\FPadd{\do#3}{\multido@temp}{\do#3}}} +\def\multido@init@N{\multido@init@n} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\FPadd,\FPsub} +% Simple fixed-point addition couldn't be harder. "\dimen@" and "\dimen@i" are +% used as scratch {\em counters} (to avoid creating a new counter). "\count@", +% "\multido@count" and "\multidocount" are also used as scratch counters. % +% This is probably pretty optimal, given the requirements that leading and +% trailing spaces be OK in the arguments, and that there need not be any +% numbers to the left of the decimal. +% \begin{macrocode} +\def\FPadd#1#2#3{% + \edef\multido@temp{#1..\noexpand\@nil#2}% + \expandafter\FPadd@\multido@temp..\@nil + \let#3\multido@temp} +\def\FPsub#1#2{% + \edef\multido@temp{\noexpand\FPsub@#2\noexpand\@empty}% + \FPadd{#1}{\multido@temp}} +\def\FPsub@#1{\ifx-#1\else-#1\fi} +\def\FPadd@#1.#2.#3\@nil#4.#5.#6\@nil{% + \begingroup + \def\multido@temp{\let\next\relax}% + \let\next\z@ + \afterassignment\multido@temp\count@=#1\next + \dimen@i=0#2sp\relax + \let\next\z@ + \afterassignment\multido@temp\multido@count=#4\next + \multidocount=0#5\relax + \dimen@=\number\count@ sp + \count@=\@ne + \FPadd@@@#500000000\@nil + \ifnum#11<\z@ + \count@=-\tw@ + \dimen@=-\dimen@ + \fi + \ifnum#41<\z@ + \count@=-\count@ + \multido@count=-\multido@count + \fi + \ifnum\count@>\z@ + \advance\multido@count\dimen@ + \advance\multidocount\dimen@i + \ifnum\multidocount<\multido@temp\relax + \advance\multidocount\multido@temp\relax + \else + \advance\multido@count\@ne + \fi + \advance\count@-3 + \else + \advance\multido@count-\dimen@ + \advance\multidocount-\dimen@i + \ifnum\multido@count<\z@ + \multido@count=-\multido@count + \multidocount=-\multidocount + \advance\count@\@ne + \else + \ifnum\multido@count=\z@ + \ifnum\multidocount<\z@ + \multidocount=-\multidocount + \advance\count@\@ne + \fi + \fi + \fi + \ifnum\multidocount<\z@ + \advance\multidocount\multido@temp + \advance\multido@count-\@ne + \fi + \advance\multidocount\multido@temp\relax + \fi + \expandafter\FPadd@@\the\multidocount\@empty\@nil + \endgroup} +\def\FPadd@@#1#2#3\@nil{\xdef\multido@temp{% + \ifnum\count@=-1-\fi + \the\multido@count\ifx#2\@empty\else.#2#3\fi}} +\def\FPadd@@@#1#2#3#4#5#6#7#8#9\@nil{\def\multido@temp{1#9}} +% \end{macrocode} +% +% \end{macro} +% \begin{macrocode} +\catcode`\@=\MultidoAtCode\relax +% \end{macrocode} +% +% \Finale +% \Endinput +% +\endinput +% +%%%%%%%%%%%%%%%%%%%%%%%% END DOCUMENTED CODE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\catcode`\@=11 + +%%%%%%%%%%%%%%%%%%%%%%%% INPUT FILE EXTRACTION %%%%%%%%%%%%%%%%%%%%%%%%%%% +\ifx\ExtractFiles\relax\else + \begingroup + \catcode`\*=0 *catcode`*\=12 + *long*def*next#1\relax\relax\relax{*endgroup} + *def*do#1{*catcode`#1=12}*dospecials*expandafter*next*fi +\fi + +\def\infile{multido.doc} +\def\outfile{multido.tex} +\def\styfile{multido.sty} + +\newread\Infile +\newwrite\Outfile + +\def\typeout{\immediate\write16} +\newif\ifflag +\def\CheckOK#1#2+{\ifx#1y\flagtrue\else\flagfalse\fi} + +\def\CheckFile#1{% + \typeout{} + \typeout{Preparing to make file `#1'.} + \immediate\openin1=#1\relax + \ifeof1\else + \typeout{% + File `#1' exists and will be overwritten if in current directory!!!} + \fi + \typeout{Make `#1'? (y=yes, n=no)} + \read16 to\OK + \expandafter\CheckOK\OK+} + +\begingroup + \catcode`\{=12 + \catcode`\}=12 + \catcode`\(=1 + \catcode`\)=2 + \catcode`\%=12 + \gdef\%(%) + \gdef\Percent(%%) + \gdef\Braces({}) +\endgroup + +\def\temp#1{} +\edef\Endinput{\expandafter\temp\string\\endinput} + +\def\ProcessLine{\expandafter\ProcessLINE\inline\relax\relax\nil} +\def\ProcessLINE#1#2#3\nil{% + \def\tempa{#1}% + \def\tempb{#1#2}% + \ifx\tempa\% + \ifx\tempb\Percent\owrite\inline\fi + \else + \ifx\tempb\Braces\else\owrite\inline\fi + \fi} + +\def\owrite#1{\immediate\write\Outfile{#1}} + +\def\stripfile{% + \begingroup + \def\do##1{\catcode`##1=12\relax} + \dospecials + \endlinechar-1 + \flagtrue + \loop + \read\Infile to\inline + \ifx\inline\Endinput\flagfalse\fi + \ifeof\Infile\flagfalse\fi + \ifflag + \ProcessLine + \repeat + \endgroup} + +\CheckFile{\outfile} + +\ifflag + \immediate\openout\Outfile\outfile\relax + + \owrite{\%\% This is file `\outfile' generated on + \the\year/\the\month/\the\day.} + \owrite{\%\% The original source file was `\infile'.} + \owrite{\%\%} + + \immediate\openin\Infile\infile\relax + \stripfile + \immediate\closein\Infile + + \owrite{\Endinput} + \owrite{\%\%} + \owrite{\%\% End of file `\outfile'.} + \immediate\closeout\Outfile +\fi + +\expandafter\ifx\csname styfile\endcsname\relax\flagfalse\else + \CheckFile{\styfile} +\fi + +\ifflag + \immediate\openout\Outfile\styfile\relax + \immediate\write\Outfile{\string\input\space \outfile} + \immediate\write\Outfile{\Endinput} + \immediate\closeout\Outfile +\fi +\relax\relax\relax +%%%%%%%%%%%%%%%%%%% END INPUT FILE EXTRACTION %%%%%%%%%%%%%%%%%%%%%%%%%%% + +\ifx\PrintUsage\relax + \let\next\relax +\else + \ifx\PrintCode\relax + \let\next\relax + \else + \expandafter\ifx\csname @latexerr\endcsname\relax + \let\next\end\else\let\next\@@end + \fi + \fi +\fi +\next + +%%%%%%%%%%%%%% BEGIN PREAMBLE FOR DOCUMENATION %%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% +%% +\let\FileVersion\fileversion +\let\FileDate\filedate +%% +\documentstyle[12pt]{article} +\makeatletter +%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%% DOC? STUFF %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% +%% Check whether doc.sty has been input. If not, code won't be printed. +%% \CodeLineIndex can only be used in preamble. Other code-specific +%% preamble stuff has been left to the end of this file. +%% +\ifx\PrintCode\relax\@input{doc.sty}\CodelineIndex\else + \def\StopEventually{\end{document}} +\fi +%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%% PAGE PARAMETERS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% +\setlength{\parindent}{0pt} % paragraph indent +\setlength{\parskip}{4pt plus 1pt minus 1pt} +\setlength{\oddsidemargin}{4pc} +\setlength{\evensidemargin}{4pc} +\setlength{\topmargin}{-2.5pc} +\setlength{\headheight}{12pt} % height of running head +\setlength{\headsep}{20pt} % distance between header and text +\setlength{\textheight}{54pc} % height of text on page +\setlength{\textwidth}{35pc} % total width of a page +%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%% VERBATIM %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% +%% This is good for examples, using \verb or whatever explicitly. +\def\Ex{\quote\tt} +\def\endEx{\endquote} +%% +%% In the verbatim environment, \trivlist is changed to \list, so that +%% verbatim code is offset from the left margin. +%% +\def\@verbatim{% + \list{}{} \item[]% + \leftskip\@totalleftmargin\rightskip\z@ + \parindent\z@\parfillskip\@flushglue + \@@par\leavevmode\parskip=\z@ + \def\par{\leavevmode\null\@@par}% + \obeylines + \let\do\@makeother \dospecials\catcode`\>=14\tt} +\def\endverbatim{\endlist} +%% +\def\m#1{{\rm\it #1}} % For just putting things in italics (m=>meta>) +\def\M#1{{\tt\{}\m{#1}{\tt\}}} % Argument is in italic, enclosed in tt braces. +\def\N#1{{\tt\string#1}} % For in-line macro names +\catcode`\>=13\def>{} % Now we can write \LaTeX> without problem. +%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +%%%%%%%%%%%%%%%%%%%%%%%%%% SECTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% +%% Section headings use customizable fonts, leave less space above +%% and below, and may overhang on left. +%% +\def\section{\@startsection{section}{1}{\sechang}{-3ex plus -1ex + minus -.2ex}{1.5ex plus .2ex}{\secfont}} +\def\subsection{\@startsection{subsection}{2}{\subsechang}{-2.75ex plus -1ex + minus -.2ex}{1.25ex plus .2ex}{\subsecfont}} +\newdimen\sechang +\newdimen\subsechang +\sechang=-.6in +\subsechang=-.375in +\def\secfont{\Large\bf} % Section headings +\def\subsecfont{\tt\large} % Subsection heading +%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +%%%%%%%%%%%%%%%%%%%%%% DATES, VERSIONS AND TITLES %%%%%%%%%%%%%%%%%%%%%%%%%%% +%% +\def\expanddate#1/#2/#3/{\number#3{} \month=#2 \ifcase\month\or + January \or February \or March \or April \or May \or June \or + July \or August \or September \or October \or November \or December \fi + 19#1} +\def\thefiledate{\expandafter\expanddate\FileDate/} +\date{Version \FileVersion\\ \thefiledate} +\def\@maketitle{\newpage + \null + \begin{center} + {\Large\bf \@title \par} + \vskip 1.2em {\lineskip .5em + \begin{tabular}[t]{c}\@author\end{tabular}\par} + \vskip .8em {\@date}% + \end{center} + \par + \vskip .5em} +%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%% PAGE STYLE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% +\pagestyle{myheadings} +\markright{Documentation for multido.tex \hfill + v.\FileVersion\hskip 1em \thefiledate\hfill}% +%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%% END PREAMBLE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% +\catcode`\"=13 +\def"{\verb"} +\catcode`\@=12 +\begin{document} +%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\title{Documentation for multido.tex:\\[2pt] + A loop macro for Generic \protect\TeX} +\author{Timothy Van Zandt% + \thanks{Author's address: Department of Economics, Princeton University, + Princeton, NJ 08544-1021, USA. Internet: {\tt tvz@Princeton.EDU}}} +\maketitle + + +\section{Usage notes} + + "multido.tex"/"multido.sty" contains the \N\multido> macro, which is a loop +facility for Generic TeX. This macro happens to be useful for drawing +pictures, and was originally developed for the PSTricks +package,\footnote{PSTricks is an extensive collection of PostScript-based +macros for Generic TeX. It is available from the /pub directory at +Princeton.EDU, and \TeX> archives.} but you can use it for other purposes as +well. + + A special feature is support of fixed-point addition. For example, PSTricks +uses the \N\multido> to put numbers on axes, much like in the following +\LaTeX> example: +\begin{verbatim}> +\setlength{\unitlength}{1cm} +\small +\begin{picture}(8,1)(0,-.5) +\put(0,0){\vector(1,0){8}} +\multido{\i=0+1,\n=0+0.25}{8}{% + \put(\i,-.1){\line(0,1){.2}} + \put(\i,-.2){\makebox(0,0)[t]{\n}}} +\end{picture} +\end{verbatim} +\begin{center}\leavevmode +\setlength{\unitlength}{1cm} +\small +\begin{picture}(8,1)(0,-.5) +\put(0,0){\vector(1,0){8}} +\multido{\i=0+1,\n=0+0.25}{8}{% + \put(\i,-.1){\line(0,1){.2}} + \put(\i,-.2){\makebox(0,0)[t]{\n}}} +\end{picture} +\end{center} + +The general syntax for \N\multido> is: +\begin{Ex} +"\multido"\M{variables}\M{repetitions}\M{stuff} +\end{Ex} + \m{stuff} is whatever you want repeated; it can be any balanced \TeX{} input. +\m{repetitions} is the number times \m{stuff} is repeated. + + The first argument is the interesting one. \m{variables} is a comma-separated +list of variable declarations.\footnote{Don't use commas to mark the decimal +point within the \protect\m{variables} argument, as they will be confused for +delimiters.} Each variable declaration is of the form: +\begin{center}\em + variable "=" initial value "+" increment +\end{center} + \m{variable} is a command sequence that can be used in \m{stuff}. It is +initially set to {\em initial value}, and is then incremented by {\em +increment} with each repetition. + + The first letter of the variable name determines the variable type. There are +four variable types: +\begin{description} + \item[Dimension (d or D)] The initial value and the increment should be +dimensions (lengths, in \LaTeX> parlance). The substitution text is a +dimension, with "sp" units. E.g., "\dx=4cm+5pt".\footnote{For PSTricks users, +the unit is optional.} + + \item[Number (n or N)] The initial value and increment should be integers or +numbers with the same number of digits to the right of the decimal. The one +exception is that it is always OK for the initial value to be an integer. +There can be at most 8 digits on each side of the decimal. The substitution +text is a number, with fixed-point addition. E.g., "\n=3+7.05", +"\Nx=5.30+-1.25". + + \item[Integer (i or I)] The initial value and increment should be integers. +This gives the same result as using a number variable, but it is faster. E.g., +"\I=2+-1". + + \item[Real (r or R)] The initial value and increment should be integers or +numbers with at most 4 digits on each side of the decimal. The substitution +text is a number, but with floating point addition and occasional small +errors. This gives a less satisfactory result than using a number variable, +but it is faster. E.g., "\ry=4.2+1.05". +\end{description} + + Here are some examples that illustrate how the substitution text is +determined: +\begin{quote} +"\multido{}{10}{\TeX\ }"\\[3pt] +\hbox to 2em{}\multido{}{10}{\TeX\ }{}\\[8pt] +"\multido{\d=2pt+3pt}{5}{\d, }"\\[3pt] +\hbox to 2em{}\multido{\d=2pt+3pt}{5}{\d, }{}\\[8pt] +"\multido{\n=2+3}{10}{\n, }"\\[3pt] +\hbox to 2em{}\multido{\n=2+3}{10}{\n, }{}\\[8pt] +"\multido{\i=2+-3}{10}{\i, }"\\[3pt] +\hbox to 2em{}\multido{\i=2+-3}{10}{\i, }{}\\[8pt] +"\multido{\r=2+3.05}{6}{\r, }"\\[3pt] +\hbox to 2em{}\multido{\r=2+3.05}{6}{\r, }{}\\[8pt] +"\multido{\n=2.00+-3.05}{8}{\n, }"\\[3pt] +\hbox to 2em{}\multido{\n=2.00+-3.05}{8}{\n, }{} +\end{quote} + +Here are some details about the choice of names: +\begin{itemize} + \item Your computer won't explode if you use names that conflict with \TeX> +internal commands, but you might want to check name conflicts if you get +inexplicable errors. The command "\MultidoCheckNames" can be useful in this +case. It causes \N\multido> to report an error whenever you use a variable +name that is already defined. But see the next item. + \item The whole \N\multido> loop is grouped. This means, e.g., that although +"\i" is a Plain \TeX{} command sequence (giving a dotless ``\i''), you can use +the variable "\i" if you do not use any dotless i's in \m{stuff} (and if you +do not use "\MultidoCheckNames"). +\end{itemize} + +Here are a few more details: +\begin{itemize} +\item \N\Multido> commands can be nested. + \item Spaces after a \N\multido> command are ignored. This makes \N\multido> +more hospitable for pictures. + \item Spaces between the various parts of the \m{variables} argument are +ignored. +\end{itemize} + + And finally here a few special features, some of which are of interest mainly +macro writers and other \TeX nicians: +\begin{itemize} + \item The material that is repeated is not grouped, so that you can insert +your own recursive routines. + \item There is a variant, "\mmultido", which works just like "\multido" +except that the variables are all incremented once before starting. + \item There are variants, "\Multido" and "\MMultido" of "\multido" and +"\mmultido", resp., that do not group the whole loop. This can be useful, +e.g., for making entries in an alignment environment. However, these cannot be +nested within any "\multido" macro. + \item If the number of repetitions is a negative number, the variables are +incremented backwards. + \item The count register "\multidocount" keeps track of the number of current +iteration. + \item The command "\multidostop" causes the "\multido" loop to quit at the +end of the current iteration. +\item Fixed point addition is performed by \N\FPadd> and \N\FPsub: +\begin{Ex} +"\FPadd"\M{num1}\M{num2}\M{\string\cs}\\ +"\FPsub"\M{num1}\M{num2}\M{\string\cs} +\end{Ex} + \m{num2}\/ is added to or subtracted from \m{num1}, and the answers is stored +in the command sequence given as the third argument. The rules about decimals +and so on that apply to number variables apply here as well. E.g., after +\begin{Ex} + "\FPsub{1.75}{-0.15}{\answer}" +\end{Ex} +the definition of "\answer" is 1.90. +\end{itemize} + +\clearpage + +%%%%%%%%%%%%%%%%%% STOP HERE IF DOC.STY NOT INPUT%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% +\StopEventually{} +%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%% BEGIN CODE-SPECIFIC PREAMBLE %%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% +\catcode`\@=11 +%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%% CHANGE TO MACRO ENVIRONMENTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% +%% A change to the doc.sty's macro environment. +%% Prints macro names like subsections, instead of as marginal notes. +%% Argument is comma separated list of macro names. +%% No nested macro environments. +%% +%% WHY: Don't need as many \begin{macro} ... \end{macro}. +%% Works even there isn't anything between \begin{macro} and +%% \begin{macrocode}. +%% +\newif\iffirst@macroname +\newif\ifnestedmacro +\def\macro{% + \ifnum\macro@level=\z@ + \def\next{\MakePrivateLetters \m@cro@}% + \else + \def\next{\@latexerr{Nested \string\begin{macro}}\@eha + \endgroup\end{macro}\macro@level=\z@\begin{macro}} + \fi + \next} +\def\m@cro@#1{% + \first@macronametrue + \m@@cro@@#1,\@nil,} +\def\m@@cro@@#1,{% + \def\@tempa{#1}\def\@tempb{\@nil}% + \ifx\@tempa\@tempb + \let\next\finishm@@cro@@ + \else + {\advance\c@CodelineNo\@ne\SpecialMainIndex{#1}\nobreak}% + \DoNotIndex{#1}% + \iffirst@macroname + \edef\saved@macronames{\string#1}% + \first@macronamefalse + \else + \def\comma{\noexpand\comma}% + \edef\saved@macronames{\saved@macronames\comma\string#1}% + \fi + \let\next\m@@cro@@ + \fi + \next} +\def\finishm@@cro@@{% + \advance\macro@level\@ne + \def\comma{{\rm, }}% + \subsection*{\tt\saved@macronames}} +%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%% DO NOT INDEX %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% +\DoNotIndex{\ ,\!,\[,\\,\],\^,\`,\{,\},\~} +\DoNotIndex{\@ifundefined,\@namedef,\@spaces,\@tempa,\@tempb} +\DoNotIndex{\@warning,\active} +\DoNotIndex{\begingroup,\catcode,\char,\csname,\def,\do} +\DoNotIndex{\docdate,\dospecials,\edef,\else,\endcsname,\endgroup} +\DoNotIndex{\expandafter,\fi,\filedate,\fileversion} +\DoNotIndex{\gdef,\if,\ifcat} +\DoNotIndex{\ifx,\immediate,\lccode,\let} +\DoNotIndex{\lowercase,\next,\noexpand} +\DoNotIndex{\relax,\space,\the} +\DoNotIndex{\toks@,\count@,\dimen@,\dimen@ii} +\DoNotIndex{\theatcode,\string,\t,\@empty,\@nil,\@nnil,\advance} +\DoNotIndex{\dimen@i,\@,\endinput,\errhelp,\errmessage,\global,ifnum} +\DoNotIndex{\p,\number,\newtoks,\ignorespaces,\message,\multido@temp} +\DoNotIndex{\newcount,\xdef,\z@,\@ne,\tw@,\number,\undefined,\ifnum} +%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%% OTHER DOC PARAMETERS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% +\setcounter{IndexColumns}{2} % two column index; + +%\DisableCrossrefs +\EnableCrossrefs + +\IndexPrologue{This index is only for the documented code. Underlined numbers refer roughly to the line number of the entry's definition, and all others indicate code lines where it is used.} +%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%% END CODE-SPECIFIC PREAMBLE %%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% +\catcode`\@=12 +%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\section{Documented code} + +\def\Endinput{\clearpage\PrintIndex\end{document}} + +\DocInput{multido.doc} +%%%%%%%%%%%%%%%%%%% END DOCUMENTATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%% END multido.doc %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + diff --git a/obsolete/macros/latex209/contrib/multido/multido.readme b/obsolete/macros/latex209/contrib/multido/multido.readme new file mode 100644 index 0000000000..e99bf86a04 --- /dev/null +++ b/obsolete/macros/latex209/contrib/multido/multido.readme @@ -0,0 +1,24 @@ +From: tvz@zandtwerk.Princeton.EDU +Newsgroups: comp.text.tex +Date: 21 Oct 92 19:12:29 GMT +Organization: Princeton University +Nntp-Posting-Host: zandtwerk.princeton.edu + +(This is a repost. The previously posted file had lines exceeeding 78 +characters.) + +Appended is v1.2 of multido.tex/multido.sty. v1.1 fixed a bug in +fixed-point addition, and v1.2 made the unit optional for dimension +variables when used with PSTricks. The version distributed with v0.92 +of PSTricks is v1.1. + +The appended file is called multido.doc. It can be used as the input +file without modification, but it can also be used to extract stripped +input files and to print the documentation. + +Tim +--- +Timothy Van Zandt (609)258-4050 tvz@Princeton.EDU (NeXTMail) +Dept. of Economics, Princeton University, Princeton, NJ 08544 + + diff --git a/obsolete/macros/latex209/contrib/multido/multido.sty b/obsolete/macros/latex209/contrib/multido/multido.sty new file mode 100644 index 0000000000..da78169679 --- /dev/null +++ b/obsolete/macros/latex209/contrib/multido/multido.sty @@ -0,0 +1,2 @@ +\input multido.tex +\endinput diff --git a/obsolete/macros/latex209/contrib/multido/multido.tex b/obsolete/macros/latex209/contrib/multido/multido.tex new file mode 100644 index 0000000000..45c86505df --- /dev/null +++ b/obsolete/macros/latex209/contrib/multido/multido.tex @@ -0,0 +1,563 @@ +%%% Save file as: MULTIDO.TEX/MULTIDO.STY Source: FILESERV@SHSU.BITNET +%%% NOTE: The documentation for this TeX macro/LaTeX style option appears +%%% in multido.doc, a LaTeX file which follows \endinput +%%% The following checksum includes all SHSU-generated topmatter +%%% checksum = "61709 563 2028 19405" +%% BEGIN multido.tex/multido.sty +%% +\def\fileversion{1.3} +\def\filedate{92/11/06} +%% +%% COPYRIGHT 1992, by Timothy Van Zandt, tvz@Princeton.EDU +%% +%% DESCRIPTION: +%% multido.tex/multido.sty contains a loop macro, \multido, that supports +%% fixed-point addition and has a nice interface. Among other things, it +%% is useful for pictures and putting numbers on axes. multido.tex +%% is compatible with most TeX macro packages, including Plain TeX, LaTeX, +%% AmSTeX, and Ams-LaTeX. +%% +%% INSTALLATION: +%% Put this file where your TeX looks for inputs, under the name multido.tex. +%% Name a copy multido.sty to use as a LaTeX style option, or create a file +%% multido.sty with the lines: +%% \input multido.tex +%% \endinput +%% +%% DOCUMENTATION: +%% See multido.doc, which might be appended to this file. +%% +%% COPYING: +%% Copying of part or all of this file is allowed under the following +%% conditions only: +%% (1) You may freely distribute unchanged copies of the file. Please +%% include the documentation when you do so. +%% (2) You may modify a renamed copy of the file, but only for personal +%% use or use within an organization. +%% (3) You may copy fragments from the file, for personal use or for +%% distribution, as long as credit is given where credit is due. +%% +%% You are NOT ALLOWED to take money for the distribution or use of +%% this file or modified versions or fragments thereof, except for +%% a nominal charge for copying etc. +%% +%% CODE: +% These macros use TeX primitives, plus the Plain TeX commands: +% \dimen@, \dimen@i, \count@, \newcount, \newtoks, \@ne, \tw@, \@z@. +% +% Check if file is loaded, announce file on terminal, and take care of @: +% +\expandafter\ifx\csname multido@\endcsname\relax\else\expandafter\endinput\fi +\message{\space\space v\fileversion\space\space\filedate\space\space <tvz>} +\edef\MultidoAtCode{\the\catcode`\@}\catcode`\@=11 +% +% These are some hacks borrowed from PSTricks, which are loaded if PSTricks is +% not being used. "\@dimtonum" strips the value of "#1", a dimension register, +% of the "pt", and assigns the result to "#2", a command sequence. +% +\expandafter\ifx\csname @pstrickserr\endcsname\relax + \def\@empty{} + \def\@nnil{\@nil} + \def\@dimtonum#1#2{\edef#2{\@@dimtonum#1}} + \def\@@dimtonum#1{\expandafter\@@@dimtonum\the#1} + {\let\@nnil\expandafter\catcode`\p=12\catcode`\t=12 + \global\@nnil\def\csname @@@dimtonum\endcsname#1pt{#1}} +\fi +% +% "\multido@count" stores the number of repetitions. "\multidocount" keeps +% track of the iteration. These are also used locally as scratch counters by +% "\FPadd@". "\multido@stuff" is used to store the <stuff> that is to be +% repeated. +% +\newcount\multido@count +\newcount\multidocount +\newtoks\multido@stuff +% +\def\multido{\multido@{}{\begingroup}{\endgroup}} +\def\mmultido{\multido@{\multido@stepvar}{\begingroup}{\endgroup}} +\def\Multido{\multido@{}{}{}} +\def\MMultido{\multido@{\multido@stepvar}{}{}} +% +% "\multido@initvar" processes the variable declarations, initializing the +% value of the variables and defining "\multido@stepvar" to increment the +% variables with each repetition. "\multido@count" is set to the number of +% repetitions. +% +\long\def\multido@#1#2#3#4#5#6{% + #2% + \multido@count=#5\relax + \ifnum\multido@count=\z@\else\multido@@{#1}{#4}{#6}\fi + #3% + \ignorespaces} +\def\multido@@#1#2#3{% + \def\multido@stepvar{}% + \def\do{\noexpand\do\noexpand}% + \multido@initvar#2,\@nil,% + \let\do\noexpand + \edef\multido@stepvar{\multido@stepvar}% + \ifnum\multido@count<\z@\multido@count=-\multido@count\fi + \multidocount=1\relax + #1% + \multido@stuff{#3}% + \multido@loop} +\def\multido@loop{% + \the\multido@stuff + \ifnum\multidocount<\multido@count + \advance\multidocount\@ne + \multido@stepvar + \expandafter\multido@loop + \fi} +\def\multidostop{\multidocount=\multido@count} +\def\multido@badvar{% + \multido@count=0 + \errhelp{\multido command will be skipped.}% + \errmessage{Bad \string\multido\space variable declaration}} +\def\multido@initvar#1,{% + \def\multido@temp{#1}% + \ifx\multido@temp\@nnil\else + \ifx\multido@temp\@empty\else + \multido@@initvar#1\@nil=+\@nil\relax + \fi + \expandafter\multido@initvar + \fi} +\def\multido@@initvar#1=#2+#3\@nil#4\relax{% + \ifx\@empty#4\@empty + \multido@badvar + \else + \multido@vartype#1\@empty + \ifx\multido@temp\relax + \multido@badvar + \else + \multido@temp{#2}{#3}#1% + \fi + \fi} +\def\multido@vartype#1{% + \ifcat\noexpand\@nil\noexpand#1% + \expandafter\multido@@vartype\string#1\@nil + \else + \let\multido@temp\relax + \fi} +\def\multido@@vartype#1#2#3\@nil{% + \expandafter\let\expandafter\multido@temp + \csname multido@init@#2\endcsname} +\def\MultidoCheckNames{% + \let\multido@@@vartype\multido@vartype + \def\multido@vartype##1{% + \ifx\undefined##1% + \multido@@@vartype{##1}% + \else + \errhelp{\multido command will be skipped.}% + \errmessage{Multido variable \string##1 already defined}% + \let\multido@temp\relax + \fi}} +% +% For each variable type, we must now define \multido@init<vartype>. The +% syntax of these macros is: +% +% \multido@init@<vartype>{initial value}{increment}{variable} +% +% and the outcome should be: +% +% 1. Set <variable> to the initial value. +% 2. Invoke \multido@addtostep{step stuff}, where <step stuff> is whatever +% should be done to increment the variable. <step stuff> is expanded first, +% with expansion suppressed by "\do". +% +\def\multido@addtostep#1{\edef\multido@stepvar{\multido@stepvar#1}} +% +% Variable type for dimensions ("d", "D"): +% +\def\multido@init@d#1#2#3{% + \expandafter\ifx\csname pssetlength\endcsname\relax + \dimen@=#1\relax\dimen@i=#2\relax + \else + \pssetlength\dimen@{#1}\pssetlength\dimen@i{#2}% + \fi + \edef#3{\number\dimen@ sp}% + \ifnum\multido@count<\z@\dimen@i=-\dimen@i\fi + \multido@addtostep{\do\multido@step@d{\do#3}{\number\dimen@i sp}}} +\def\multido@step@d#1#2{% + \dimen@=#1\advance\dimen@#2 + \edef#1{\number\dimen@ sp}}% +\def\multido@init@D{\multido@init@d} +% +% Variable type for integers ("i", "I"): +% +\def\multido@init@i#1#2#3{% + \count@=#1\relax + \edef#3{\the\count@}% + \count@=#2\relax + \ifnum\multido@count<\z@\count@=-\count@\fi + \multido@addtostep{\do\multido@step@i{\do#3}{\the\count@}}} +\def\multido@step@i#1#2{% + \count@=#1\advance\count@ by #2 + \edef#1{\the\count@}} +\def\multido@init@I{\multido@init@i} +% +% Variable type for reals ("r", "R"). +% +\def\multido@init@r#1#2#3{% + \dimen@=#1pt + \@dimtonum\dimen@#3% + \dimen@=#2pt + \ifnum\multido@count<\z@\dimen@=-\dimen@\fi + \multido@addtostep{\do\multido@step@r{\do#3}{\number\dimen@ sp}}} +\def\multido@step@r#1#2{% + \dimen@=#1pt\advance\dimen@#2 + \@dimtonum\dimen@#1} +\def\multido@init@R{\multido@init@r} +% +% Variable type for numbers ("n", "N"). +% +\def\multido@init@n#1#2#3{% + \edef#3{#1}% + \ifnum\multido@count<\z@\expandafter\FPsub\else\expandafter\FPadd\fi + {0}{#2}\multido@temp + \multido@addtostep{\do\FPadd{\do#3}{\multido@temp}{\do#3}}} +\def\multido@init@N{\multido@init@n} +% +% Simple fixed-point addition couldn't be harder. "\dimen@" and "\dimen@i" are +% used as scratch {\em counters} (to avoid creating a new counter). "\count@", +% "\multido@count" and "\multidocount" are also used as scratch counters. +% +% This is probably pretty close to optimal, given the requirements that +% leading and trailing spaces be OK in the arguments, and that there need not +% be any numbers to the left of the decimal. +% +\def\FPadd#1#2#3{% + \edef\multido@temp{#1..\noexpand\@nil#2}% + \expandafter\FPadd@\multido@temp..\@nil + \let#3\multido@temp} +\def\FPsub#1#2{% + \edef\multido@temp{\noexpand\FPsub@#2\noexpand\@empty}% + \FPadd{#1}{\multido@temp}} +\def\FPsub@#1{\ifx-#1\else-#1\fi} +\def\FPadd@#1.#2.#3\@nil#4.#5.#6\@nil{% + \begingroup + \def\multido@temp{\let\next\relax}% + \let\next\z@ + \afterassignment\multido@temp\count@=#1\next + \dimen@i=0#2sp\relax + \let\next\z@ + \afterassignment\multido@temp\multido@count=#4\next + \multidocount=0#5\relax + \dimen@=\number\count@ sp + \count@=\@ne + \FPadd@@@#500000000\@nil + \ifnum#11<\z@ + \count@=-\tw@ + \dimen@=-\dimen@ + \fi + \ifnum#41<\z@ + \count@=-\count@ + \multido@count=-\multido@count + \fi + \ifnum\count@>\z@ + \advance\multido@count\dimen@ + \advance\multidocount\dimen@i + \ifnum\multidocount<\multido@temp\relax + \advance\multidocount\multido@temp\relax + \else + \advance\multido@count\@ne + \fi + \advance\count@-3 + \else + \advance\multido@count-\dimen@ + \advance\multidocount-\dimen@i + \ifnum\multido@count<\z@ + \multido@count=-\multido@count + \multidocount=-\multidocount + \advance\count@\@ne + \else + \ifnum\multido@count=\z@ + \ifnum\multidocount<\z@ + \multidocount=-\multidocount + \advance\count@\@ne + \fi + \fi + \fi + \ifnum\multidocount<\z@ + \advance\multidocount\multido@temp + \advance\multido@count-\@ne + \fi + \advance\multidocount\multido@temp\relax + \fi + \expandafter\FPadd@@\the\multidocount\@empty\@nil + \endgroup} +\def\FPadd@@#1#2#3\@nil{\xdef\multido@temp{% + \ifnum\count@=-1-\fi + \the\multido@count\ifx#2\@empty\else.#2#3\fi}} +\def\FPadd@@@#1#2#3#4#5#6#7#8#9\@nil{\def\multido@temp{1#9}} +% +\catcode`\@=\MultidoAtCode\relax +\endinput +%% END multido.tex/multido.sty + +%% BEGIN multido.doc +%% +%% Documentation for multido.tex/multido.sty. +%% Run through LaTeX, with or without the NFSS. +%% +%% If you find this file appended to multido.tex, copy it to a separate file +%% or simply add "\let\endinput\relax" to the beginning of multido.tex. +%% +\documentstyle[12pt]{article} +\input multido.tex + +\makeatletter + +%% PAGE PARAMETERS: +\setlength{\parindent}{0pt} % paragraph indent +\setlength{\parskip}{4pt plus 1pt minus 1pt} +\setlength{\topmargin}{-2.5pc} +\setlength{\headheight}{12pt} % height of running head +\setlength{\headsep}{30pt} % distance between header and text +\setlength{\textheight}{54pc} % height of text on page +%% +%% DATES, VERSIONS AND TITLES: +%% +\def\expanddate#1/#2/#3/{\year=19#1 \month=#2 \day=#3} +\begingroup + \expandafter\expanddate\filedate/ + \xdef\thefiledate{\today} +\endgroup +\date{Version \fileversion\\ \thefiledate} +\def\@maketitle{% + \begin{center} + {\Large\bf \@title \par} + \vskip 1.2em {\lineskip .5em + \begin{tabular}[t]{c}\@author\end{tabular}\par} + \vskip .8em {\@date}% + \end{center} + \par + \vskip .5em} +%% +%% PAGE STYLE: +%% +\pagestyle{myheadings} +\markright{Documentation for multido.tex \hfill + v.\fileversion\hskip 1em \thefiledate\hfill}% +%% +%% VERBATIM: +%% +\begingroup + \catcode`\{=12 \catcode`\}=12 + \catcode`\(=1 \catcode`\)=2 + \catcode`\+=0 \catcode`\\=12 + +gdef+|(\) % \| = character \ + +gdef+{({) % \{ = character { + +gdef+}(}) % \} = character } ++endgroup +\def\Backslash{\protect\|} +%% +%% Define some functional font commands: +%% +\def\MainFont{\tt} % For macro definitions. +\def\UsageFont{\tt} % For in-line macro names. +\def\InlineFont{\tt} % For other in-line snipets of code. +\def\MetaFont{\rm\it} % For meta arguments. +%% +%% Short-cuts for font commands: +%% +\def\s#1{\string#1} +\def\t#1{{\InlineFont\string#1}} % For other in-line code. +\def\m#1{{\MetaFont #1\/}} % For just putting things in italics +\def\M#1{{\InlineFont\{\m{#1}\}}} % Arg is in italic, enclosed in tt braces. +\let\N\t % For in-line macro names. +\catcode`\<=13 \def<#1>{\m{#1}} % <meta> +%% +%% This is for listing macro definitions in a quote-like environment. +%% +\begingroup + \catcode`\[=1 \catcode`\]=2 + \catcode`\{=13 \catcode`\}=12 + \gdef\@MD[% + \catcode`\{=13 \catcode`\}=12 + \def{##1}[\{[\MetaFont ##1]\}]] +\endgroup +\def\MD{% + \quote + \begingroup + \@MD + \def\end{\endgroup\end}% + \def\\{\@centercr\s}% + \MainFont + \s} +\def\endMD{\endquote} +%% +%% END PREAMBLE: +%% +\catcode`\"=13 +\def"{\verb"} +\catcode`\@=12 +\begin{document} +%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\title{Documentation for multido.tex:\\[2pt] + A loop macro for Generic \protect\TeX} +\author{Timothy Van Zandt% + \thanks{Author's address: Department of Economics, Princeton University, + Princeton, NJ 08544-1021, USA. Internet: {\tt tvz@Princeton.EDU}}} +\maketitle + + "multido.tex"/"multido.sty" contains the \N\multido\ macro, which is a loop +facility for Generic TeX. This macro happens to be useful for drawing +pictures, and was originally developed for the PSTricks +package,\footnote{PSTricks is an extensive collection of PostScript-based +macros for Generic TeX. It is available from the /pub directory at +Princeton.EDU, and \TeX\ archives.} but you can use it for other purposes as +well. + + A special feature is support of fixed-point addition. For example, PSTricks +uses the \N\multido\ to put numbers on axes, much like in the following +\LaTeX\ example: +\begin{verbatim} + \setlength{\unitlength}{1cm} + \small + \begin{picture}(8,1)(0,-.5) + \put(0,0){\vector(1,0){8}} + \multido{\i=0+1,\n=0+0.25}{8}{% + \put(\i,-.1){\line(0,1){.2}} + \put(\i,-.2){\makebox(0,0)[t]{\n}}} + \end{picture} +\end{verbatim} +\begin{center} + \setlength{\unitlength}{1cm} + \small + \begin{picture}(8,1)(0,-.5) + \put(0,0){\vector(1,0){8}} + \multido{\i=0+1,\n=0+0.25}{8}{% + \put(\i,-.1){\line(0,1){.2}} + \put(\i,-.2){\makebox(0,0)[t]{\n}}} + \end{picture} +\end{center} + +The general syntax for \N\multido\ is: +\begin{MD} + \multido{variables}{repetitions}{stuff} +\end{MD} + <stuff> is whatever you want repeated; it can be any balanced \TeX\ input. +<repetitions> is the number times <stuff> is repeated. + + The first argument is the interesting one. <variables> is a comma-separated +list of variable declarations.\footnote{Don't use commas to mark the decimal +point within the \protect<variables> argument, as they will be confused for +delimiters.} Each variable declaration is of the form: +\begin{center}\tt + <variable> = <initial value> + <increment> +\end{center} + <variable> is a command sequence that can be used in <stuff>. It is initially +set to <initial value>, and is then incremented by <increment> with each +repetition. + + The first letter of the variable name determines the variable type. There are +four variable types: +\begin{description} + \item[Dimension (d or D)] The initial value and the increment should be +dimensions (lengths, in \LaTeX\ parlance). The substitution text is a +dimension, with "sp" units. E.g., "\dx=4cm+5pt".\footnote{For PSTricks users, +the unit is optional.} + + \item[Number (n or N)] The initial value and increment should be integers or +numbers with the same number of digits to the right of the decimal. The one +exception is that it is always OK for the initial value to be an integer. +There can be at most 8 digits on each side of the decimal. The substitution +text is a number, with fixed-point addition. E.g., "\n=3+7.05", +"\Nx=5.30+-1.25". + + \item[Integer (i or I)] The initial value and increment should be integers. +This gives the same result as using a number variable, but it is faster. E.g., +"\I=2+-1". + + \item[Real (r or R)] The initial value and increment should be integers or +numbers with at most 4 digits on each side of the decimal. The substitution +text is a number, but with floating point addition and occasional small +errors. This gives a less satisfactory result than using a number variable, +but it is faster. E.g., "\ry=4.2+1.05". +\end{description} + + Here are some examples that illustrate how the substitution text is +determined: +\begin{quote} + "\multido{}{10}{\TeX\ }"\\[3pt] + \hbox to 2em{}\multido{}{10}{\TeX\ }{}\\[8pt] + "\multido{\d=2pt+3pt}{5}{\d, }"\\[3pt] + \hbox to 2em{}\multido{\d=2pt+3pt}{5}{\d, }{}\\[8pt] + "\multido{\n=2+3}{10}{\n, }"\\[3pt] + \hbox to 2em{}\multido{\n=2+3}{10}{\n, }{}\\[8pt] + "\multido{\i=2+-3}{10}{\i, }"\\[3pt] + \hbox to 2em{}\multido{\i=2+-3}{10}{\i, }{}\\[8pt] + "\multido{\r=2+3.05}{6}{\r, }"\\[3pt] + \hbox to 2em{}\multido{\r=2+3.05}{6}{\r, }{}\\[8pt] + "\multido{\n=2.00+-3.05}{8}{\n, }"\\[3pt] + \hbox to 2em{}\multido{\n=2.00+-3.05}{8}{\n, }{} +\end{quote} + +Here are some details about the choice of names: +\begin{itemize} + \item Your computer won't explode if you use names that conflict with \TeX\ +internal commands, but you might want to check name conflicts if you get +inexplicable errors. The command \N\MultidoCheckNames\ can be useful in this +case. It causes \N\multido\ to report an error whenever you use a variable +name that is already defined. But see the next item. + \item The whole \N\multido\ loop is grouped. This means, e.g., that although +"\i" is a Plain \TeX\ command sequence (giving a dotless ``\i''), you can use +the variable "\i" if you do not use any dotless i's in <stuff> (and if you do +not use \N\MultidoCheckNames). +\end{itemize} + +Here are a few more details: +\begin{itemize} +\item \N\Multido\ commands can be nested. + \item Spaces after a \N\multido\ command are ignored. This makes \N\multido\ +more hospitable for pictures. + \item Spaces between the various parts of the <variables> argument are +ignored. +\end{itemize} + + And finally here a few special features, some of which are of interest mainly +macro writers and other \TeX nicians: +\begin{itemize} + \item The material that is repeated is not grouped, so that you can insert +your own recursive routines. + \item There is a variant, "\mmultido", which works just like "\multido" +except that the variables are all incremented once before starting. + \item If you use "\Multido" or "\MMultido" instead of "\multido" or +"\mmultido", resp., then the whole loop is not grouped. This can be useful, +e.g., for making entries in an alignment environment. However, these cannot be +nested within any "\multido" macro. + \item If the number of repetitions is a negative number, the variables are +incremented backwards. + \item The count register "\multidocount" keeps track of the number of current +iteration. + \item The command "\multidostop" causes the "\multido" loop to quit at the +end of the current iteration. +\item Fixed point addition is performed by \N\FPadd\ and \N\FPsub: +\begin{MD} + \FPadd{num1}{num2}{command}\\ + \FPsub{num1}{num2}{command} +\end{MD} + <num2> is added to or subtracted from <num1>, and the answers is stored in +the command sequence given as the third argument. The rules about decimals and +so on that apply to number variables apply here as well. E.g., after +\begin{verbatim} + \FPsub{1.75}{-0.15}{\answer} +\end{verbatim} +the definition of "\answer" is 1.90. +\end{itemize} + +\subsection*{Changes:} + +\begin{description} + \item[V1.1] Fixed bug in \N\FPadd\ that gave wrong answer for, e.g., $3.4 + +-0.2.$ + +\item[V1.2] Made unit optional for dimension variables when using PSTricks. + + \item[V1.3] Now 0 repetitions really gets 0 repetitions. "\def\multido@" +changed to "\long\def\multido@". +\end{description} + +\end{document} +%% END multido.doc |