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
? 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. :)source2e
trying to boost by understanding of TeX. Datatool can probably achieve it also.\addtocommalist
to add an element to a comma list (if it does not exist already),\removefromcommalist
to remove an element,\appendtocommalist
and\prependtocommalist
to append an element (without checking if it is already there),\getfromcommalist
to get the n-th element from a comma list, etc. If you are interested in a ConTeXt solution, I can post more details.