summaryrefslogtreecommitdiff
path: root/macros/generic/multido
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/generic/multido
Initial commit
Diffstat (limited to 'macros/generic/multido')
-rw-r--r--macros/generic/multido/Changes12
-rw-r--r--macros/generic/multido/Makefile71
-rw-r--r--macros/generic/multido/multido-doc.pdfbin0 -> 64366 bytes
-rw-r--r--macros/generic/multido/multido-doc.tex274
-rw-r--r--macros/generic/multido/multido.pdfbin0 -> 63288 bytes
-rw-r--r--macros/generic/multido/multido.sty28
-rw-r--r--macros/generic/multido/multido.tex288
7 files changed, 673 insertions, 0 deletions
diff --git a/macros/generic/multido/Changes b/macros/generic/multido/Changes
new file mode 100644
index 0000000000..1abe6687f7
--- /dev/null
+++ b/macros/generic/multido/Changes
@@ -0,0 +1,12 @@
+--- multido.tex
+1.42 2010-05-14 - small changes to the code (hv)
+ - LPPL license (hv)
+1.41 2004-05-18 - fix bug when using the fp-package (same macronames)
+ FPadd -> fpAdd; FPsub -> fpSub (RN/hv)
+1.4 Small change to make it compatible with PSTricks v0.93 and later.
+
+
+--- multido-doc.tex
+2010-05-14 - updated (hv)
+2006-01-01 - updated (hv)
+2004-05-18 - small changes to this documentation (RN/HV)
diff --git a/macros/generic/multido/Makefile b/macros/generic/multido/Makefile
new file mode 100644
index 0000000000..285260e7ed
--- /dev/null
+++ b/macros/generic/multido/Makefile
@@ -0,0 +1,71 @@
+
+# `Makefile' for `multido.pdf', hv, 2007/03/17
+
+.SUFFIXES : .tex .ltx .dvi .ps .pdf .eps
+
+PACKAGE = multido
+
+MAIN = $(PACKAGE)-doc
+
+TDS = ~/PSTricks/PSTricks-TDS
+
+LATEX = latex
+
+ARCHNAME = $(MAIN)-$(shell date +%y%m%d)
+
+ARCHFILES = $(PACKAGE).sty $(PACKAGE).tex $(PACKAGE).pro $(MAIN).tex README Changes Makefile
+
+all : doc clean
+doc: $(MAIN).pdf
+
+$(MAIN).pdf : $(MAIN).ps
+ GS_OPTIONS=-dAutoRotatePages=/None ps2pdf $<
+
+$(MAIN).ps : $(MAIN).dvi
+ dvips $<
+
+$(MAIN).dvi : $(MAIN).tex
+ $(LATEX) $<
+ $(LATEX) $<
+# if ! test -f $(basename $<).glo ; then touch $(basename $<).glo; fi
+# if ! test -f $(basename $<).idx ; then touch $(basename $<).idx; fi
+# makeindex -t $(basename $<).ilg -s pst-doc.ist -o $(basename $<).ind $(basename $<).idx
+# makeindex -s gglo.ist -t $(basename $<).glg -o $(basename $<).gls \
+# $(basename $<).glo
+# bibtex $(basename $<)
+# $(LATEX) $<
+# $(LATEX) $<
+
+clean :
+ $(RM) $(addprefix $(MAIN), .log .aux .glg .glo .gls .ilg .idx .ind .tmp .toc .out .blg .Roessler .bbl )
+ $(RM) $(addprefix $(MAIN), .dvi .ps .xcp)
+ $(RM) data3d.Roessler
+
+veryclean : clean
+ $(RM) $(addprefix $(MAIN), .pdf .bbl .blg)
+
+arch :
+ zip $(ARCHNAME).zip $(ARCHFILES)
+
+tds:
+ cp -u Changes $(TDS)/doc/generic/$(PACKAGE)/
+ cp -u README $(TDS)/doc/generic/$(PACKAGE)/
+ cp -u $(MAIN).pdf $(TDS)/doc/generic/$(PACKAGE)/
+#
+ cp -u Changes $(TDS)/tex/latex/$(PACKAGE)/
+ cp -u $(PACKAGE).sty $(TDS)/tex/latex/$(PACKAGE)/
+#
+ cp -u Changes $(TDS)/tex/generic/$(PACKAGE)/
+ cp -u $(PACKAGE).tex $(TDS)/tex/generic/$(PACKAGE)/
+#
+ cp -u Changes $(TDS)/dvips/$(PACKAGE)/
+ cp -u $(PACKAGE).pro $(TDS)/dvips/$(PACKAGE)/
+ cp -u $(PACKAGE).pro ~/Links/dvips-local/
+#
+ cp -u Changes $(TDS)/source/$(PACKAGE)/
+ cp -u $(MAIN).tex $(TDS)/source/$(PACKAGE)/
+ cp -u $(MAIN).bib $(TDS)/source/$(PACKAGE)/
+ cp -u Makefile $(TDS)/source/$(PACKAGE)/
+
+
+# EOF
diff --git a/macros/generic/multido/multido-doc.pdf b/macros/generic/multido/multido-doc.pdf
new file mode 100644
index 0000000000..54a947cc8b
--- /dev/null
+++ b/macros/generic/multido/multido-doc.pdf
Binary files differ
diff --git a/macros/generic/multido/multido-doc.tex b/macros/generic/multido/multido-doc.tex
new file mode 100644
index 0000000000..2861100173
--- /dev/null
+++ b/macros/generic/multido/multido-doc.tex
@@ -0,0 +1,274 @@
+%% $Id: multido-doc.tex 317 2010-05-14 21:54:15Z herbert $
+\documentclass[12pt]{article}
+\usepackage{fp,multido}
+\let\MDfv\fileversion
+\usepackage{url}
+
+\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=#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, version \MDfv:\\[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: \protect\url{tvz@Princeton.EDU}.
+ This document was edited by Rolf Niepraschk \protect\url{Rolf.Niepraschk@gmx.de} and
+ Herbert Voss \protect\url{hvoss@tug.org} to get it run with LaTeX2e (2006-01-01)}}
+\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 \url{CTAN://graphics/pstricks/}.}
+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}
+\fpSub{1.75}{-0.15}{\answer}
+the definition of "\answer" is \answer.
+\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@".
+
+% RN modification begin
+%\end{description}
+% RN modification end
+
+\item[V1.4] Small change to make it compatible with PSTricks v0.93 and later.
+
+\item[V1.41] Fix bug when using the fp-package (same macronames) and small
+changes to this documentation (RN/HV)
+\end{description}
+
+\end{document}
+%% END multido-doc
diff --git a/macros/generic/multido/multido.pdf b/macros/generic/multido/multido.pdf
new file mode 100644
index 0000000000..db9793caf5
--- /dev/null
+++ b/macros/generic/multido/multido.pdf
Binary files differ
diff --git a/macros/generic/multido/multido.sty b/macros/generic/multido/multido.sty
new file mode 100644
index 0000000000..c17e7bd999
--- /dev/null
+++ b/macros/generic/multido/multido.sty
@@ -0,0 +1,28 @@
+%%% $Id: multido.sty 317 2010-05-14 21:54:15Z herbert $
+%
+%% This is file `multido.sty'.
+%%
+%% IMPORTANT NOTICE:
+%%
+%% multido.sty Copyright (C) 1997 Timothy Van Zandt
+%% (C) 2004-2010 Herbert Voss <hvoss@tug.org>
+%% Rolf Niepraschk <Rolf.Niepraschk@gmx.de>
+%%
+%% This package may be distributed under the terms of the LaTeX Project
+%% Public License, as described in lppl.txt in the base LaTeX distribution.
+%% Either version 1.0 or, at your option, any later version.
+%%
+
+\ProvidesPackage{multido}
+ [2004/05/17 package wrapper for PSTricks `multido.tex', (HV/RN)]
+
+\@ifundefined{MultidoLoaded}
+{%
+ \input{multido.tex}
+ \ProvidesFile{multido.tex}
+ [\filedate\space v\fileversion\space `multido' (tvz,hv)]
+}{}
+
+\endinput
+%%
+%% End of file `multido.sty'.
diff --git a/macros/generic/multido/multido.tex b/macros/generic/multido/multido.tex
new file mode 100644
index 0000000000..eca6355b4e
--- /dev/null
+++ b/macros/generic/multido/multido.tex
@@ -0,0 +1,288 @@
+%% $Id: multido.tex 317 2010-05-14 21:54:15Z herbert $
+%% BEGIN multido.tex
+%%
+\def\fileversion{1.42}
+\def\filedate{2010/05/14}
+%%
+%% COPYRIGHT 1993, 1994, 1999 by Timothy Van Zandt, tvz@nwu.edu.
+%% Version 1.41 (2004) prepared by Rolf Niepraschk <Rolf.Niepraschk@gmx.de>
+%% Herbert Voss <hvoss@tug.org>
+%% COPYRIGHT 2010 by Herbert Voss <hvoss@tug.org>
+%%
+%%
+%% This program can be redistributed and/or modified under the terms
+%% of the LaTeX Project Public License Distributed from CTAN
+%% archives in directory macros/latex/base/lppl.txt.
+%%
+%% 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.
+%%
+%% 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 @:
+%
+\message{ v\fileversion, \filedate\space <tvz>}
+\csname MultidoLoaded\endcsname
+\let\MultidoLoaded\endinput
+\edef\TheAtCode{\the\catcode`\@}
+\catcode`\@=11
+
+% These are some useful hacks. "\multido@dimtonum" strips the value of "#1",
+% a dimension register, of the "pt", and assigns the result to "#2",
+% a command sequence.
+
+\def\@empty{}
+\def\@nnil{\@nil}
+\def\multido@dimtonum#1#2{\edef#2{\multido@@dimtonum#1}}
+\def\multido@@dimtonum#1{\expandafter\multido@@@dimtonum\the#1}
+\edef\next{%
+ \noexpand\def\noexpand\multido@@@dimtonum##1\string p\string t{##1}}
+\next
+
+% "\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
+ \multido@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
+ \multido@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.
+
+% RN modification begin -- 2004/05/17; Rolf.Niepraschk@ptb.de
+% \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\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}}
+\ifx\FPadd\undefined\let\FPadd\fpAdd\let\FPsub\fpSub\fi
+% RN modification end
+\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`\@=\TheAtCode\relax
+
+\endinput
+%%
+%% END multido.tex