home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / text / tex / 13338 < prev    next >
Encoding:
Text File  |  1992-11-19  |  3.8 KB  |  139 lines

  1. Newsgroups: comp.text.tex
  2. Path: sparky!uunet!paladin.american.edu!darwin.sura.net!news.duc.auburn.edu!ducvax.auburn.edu!hank
  3. From: hank@ducvax.auburn.edu
  4. Subject: Re: HELP on LaTeX macro
  5. Message-ID: <1992Nov19.183843.1@ducvax.auburn.edu>
  6. Lines: 125
  7. Sender: usenet@news.duc.auburn.edu (News Account)
  8. Nntp-Posting-Host: ducvax
  9. Organization: Auburn University, AL
  10. References: <1992Nov19.112431.7525@inesc.pt>
  11. Date: Thu, 19 Nov 1992 23:38:43 GMT
  12. Lines: 125
  13.  
  14. In article <1992Nov19.112431.7525@inesc.pt>, njm@thor.inesc.pt (Nuno Joao Mamede) writes:
  15. > I would like to use a command in LaTeX with an argument specifying how
  16. > many times other command shoud be executed.
  17. > How can I define such a loop in LaTeX (TeX)?
  18.  
  19. EVERYONE, get DM Jones' tex-index:
  20.  archive.cs.ruu.nl:TEX/DOC/TeX-index.Z
  21.  ftp.th-darmstadt.de:
  22.         pub/tex/documentation/styles-and-macros.Index.Z
  23.  ftp.math.utah.edu:pub/tex/tex-index
  24.  ftp.uni-stuttgart.de:/soft/tex/documentation/TeX-index
  25.  ftp.diku.dk:pub/TeX/misc/TeX-Index.Z
  26.  Niord.SHSU.edu:[fileserv.tex-index]tex.index
  27.  TeX.ac.uk:[tex-archive.doc]TeX-index.txt
  28.  ymir.claremont.edu:[anonymous.tex.documentation]tex-index.txt
  29.  
  30. Look for 'loop'. Some old, untested macros which do not appear in the 
  31. tex-index follow.
  32.  
  33. % Date: Wed,  9 Nov 88 14:07:12 CST
  34. % From: J E PITTMAN <JEPTEX@venus.tamu.edu>
  35. % Subject: TeX Inputs loopy.tex (nested loop constructs)
  36. % Keywords: macros, TeX
  37.  
  38. % File:       TeX Inputs loopy.tex
  39. % Author:     J E Pittman
  40. % Bitnet:     JEPTeX@TAMVenus
  41. % Internet:   JEPTeX@Venus.TAMU.EDU
  42. % Date:       September 29, 1988
  43. %
  44. % These macros supply structured, nested loop constructs as follows:
  45. %
  46. %     \forcount \csname=number to number by number do
  47. %        valid_TeX_input
  48. %        \endfor \csname
  49. %
  50. %     \while \csname \if_of_any_type do
  51. %        valid_TeX_input
  52. %        \endwhile \csname
  53. %
  54. %     \whilenot \csname \if_of_any_type do
  55. %        valid_TeX_input
  56. %        \endwhile \csname
  57. %
  58. % The \csname for the for loop must refer to a count register, for the
  59. % while loops it must uniquely identify the while loop.
  60. %
  61. \def\forcount #1{\relax
  62.    \def
  63.          \for #1=##1to ##2by ##3do
  64.             ##4%
  65.             \endfor #1%
  66.       {\relax
  67.       #1=##1\relax
  68.       \ifnum ##3>0
  69.          \whilenot #1\ifnum ##2<#1do
  70.             ##4%
  71.             \advance #1 by ##3\relax
  72.             \endwhilenot #1%
  73.       \else
  74.          \while #1\ifnum ##2<#1do
  75.             ##4%
  76.             \advance #1 by ##3\relax
  77.             \endwhile #1%
  78.       \fi
  79.       }%
  80.    \for #1%
  81.    }%
  82. %
  83. \let\endwhilenot=\fi
  84. %
  85. \def\whilenot #1{\relax
  86.    \def
  87.          \whilenotloop#1 ##1do
  88.             ##2%
  89.             \endwhilenot #1%
  90.       {\relax
  91.          \expandafter\def\csname whilenotbody\string#1\endcsname{##2}%
  92.          \expandafter\def\csname whilenotloop\string#1\endcsname
  93.             {\relax
  94.                ##1%
  95.                   \let\next=\relax
  96.                \else
  97.                   \csname whilenotbody\string#1\endcsname
  98.                   \expandafter\let\expandafter\next
  99.                         \csname whilenotloop\string#1\endcsname
  100.                \fi
  101.                \next
  102.                }%
  103.          \csname whilenotloop\string#1\endcsname
  104.          }%
  105.    \whilenotloop#1
  106.    }%
  107. %
  108. \let\endwhile=\fi
  109. %
  110. \def\while #1{\relax
  111.    \def
  112.          \whileloop#1 ##1do
  113.             ##2%
  114.             \endwhile #1%
  115.       {\relax
  116.          \expandafter\def\csname whilebody\string#1\endcsname{##2}%
  117.          \expandafter\def\csname whileloop\string#1\endcsname
  118.             {\relax
  119.                ##1%
  120.                   \csname whilebody\string#1\endcsname
  121.                   \expandafter\let\expandafter\next
  122.                         \csname whileloop\string#1\endcsname
  123.                \else
  124.                   \let\next=\relax
  125.                \fi
  126.                \next
  127.                }%
  128.          \csname whileloop\string#1\endcsname
  129.          }%
  130.    \whileloop#1
  131.    }%
  132. %
  133. \endinput
  134.  
  135.  
  136.  
  137. -- 
  138. --Darrel Hankerson hank@ducvax.auburn.edu
  139.