LaTeX's low-level programming is poorly documented and the section on what is called control commands is even more so.
LaTeX provides the \@for macro. This works by repeatedly assigning list items to a temporary variable:
I want to define a list that will include all the greek math letters. The list is defined as follows:
\newcommand{\mathList}{\alpha,\beta,\gamma,
\delta,\epsilon,\zeta,\theta}
To iterate over the list I have used the @for macro. For example the following explodes the list
and removes the comma.
\@for\i:=\mathList\do{%
\ensuremath \i \space
}
How can I define a macro to be able to delete the nth element of the list? I have figured out appending to the list but have not posted it for brevity. I would prefer a TeX or LaTeX solution, although I would also be curious to see how it is done in LaTeX3, so all solutions are welcome.
Minimal example for convenience below:
\documentclass[11pt]{article}
\begin{document}
\makeatletter
\let\dotlessi\i
\newcommand*{\mathList}{\alpha,\beta,\gamma,
\delta,\epsilon,\zeta,\theta, }
\@for\i:=\mathList\do{%
\ensuremath \i \space
}
\let\i\dotlessi
\makeatother
\end{document}
etextools? http://tug.ctan.org/cgi-bin/ctanPackageInformation.py?id=etextools It has a lot of CSV manipulation stuff in it, so maybe you don't need to re-invent the wheel. :) – Willie Wong Nov 21 '10 at 18:34source2etrying to boost by understanding of TeX. Datatool can probably achieve it also. – yannisl Nov 21 '10 at 18:43\addtocommalistto add an element to a comma list (if it does not exist already),\removefromcommalistto remove an element,\appendtocommalistand\prependtocommalistto append an element (without checking if it is already there),\getfromcommalistto get the n-th element from a comma list, etc. If you are interested in a ConTeXt solution, I can post more details. – Aditya Nov 21 '10 at 22:03\edef) — I suspect they are complementary in space vs speed but that's only a hunch. expl3 uses the expandable mapping approach for both comma lists and "Seqences". – Will Robertson Nov 22 '10 at 03:35