I have a document that makes heavy use of predefined symbols (in order to later change them), i.e.:
\newcommand{\term}{t}
...
Now I need to introduce different annotated variants of the symbols:
\newcommand{\aterm}{\term^{\alpha}}
\newcommand{\bterm}{\term^{\beta}}
...
It is quite tedious to manually manage these sets (especially when adding a new symbol or removing an obsolete one).
So I naturally wonder, how one would define multiple (differently prefixed) arguments in one batch? Due to the macro capabilities of TeX, this is should certainly be possible, but is there a safe and convenient way?
i.e. is there some "meta"-newcommand that works somewhat like this:
\metanewcommand{\declaresymbols}[2]{\newcommand{\#1term}{t^{#2}} ... }
edit: Thanks to Steven's comment below, I was able to implement what I need myself:
\newcommand{\declaresymbol}[4]{
%introduce a symbol \#3 -> #4 prefixed with #1 and annotated with #2
\ifthenelse{\equal{#1}{}}{
\expandafter\newcommand\csname#3\endcsname{#4}
} {
\expandafter\newcommand\csname#1#3\endcsname{#4^{#2}}
}
}
\newcommand{\declaresymbols}[2]{
\declaresymbol{#1}{#2}{val}{v}
\declaresymbol{#1}{#2}{term}{t}
}
% Standard symbol, no variant
\declaresymbols{}{} %gives \term -> t and \val -> v
% Alpha variant
\declaresymbols{a}{\alpha} %gives \aterm -> t^\alpha \aval -> v^\alpha
\newcommand{\declaresymbols}[2]{\expandafter\newcommand\csname#1term\endcsname{t^{#2}}}
. Of course,\declaresymbols{a}{\alpha}
is as hard to type as\newcommand{\aterm}{\term^{\alpha}}