I would like to define a series of command using two loops.
For instance I want to create a series of variables that can have YY or NN as subscripts.
I would like to define commands \yy
and \nn
that puts those letters as UPPER CASE subscripts.
Following this solution, I use Tikz / pgffor
:
\documentclass{minimal}
\usepackage{pgffor}
\foreach \p in {yy,nn}{%
\expandafter\xdef\csname \p\endcsname{
\noexpand\ensuremath{_{\uppercase{\p}}}
}
}
\begin{document}
$B\nn$ and $B\yy$
\end{document}
Now I would like to know how to create variables \ann
, \ayy
, \bnn
, \byy
, \cnn
and so on, that would be the equivalent of $A\nn$
, $A\yy$
, $B\nn$
, etc.
I would like to do something along the line of
\foreach \p in {yy,nn}{%
\expandafter\xdef\csname \a\\p\endcsname{
\noexpand\ensuremath{A\\p}
}
}
where I have written \\p
when I wanted the loop to use functions \yy
and \nn
previously defined. But obviously it doesn't work
(! Undefined control sequence.
\GenericError ... \@empty \def \MessageBreak...)
Any idea?