Inside a command I would like to define multiple new commands. Their names are parametrized by arguments, but they should also be able to call each other during definition. Here is an example:
\documentclass{article}
\newcommand{\defFooAndBar}[2]{%
\expandafter\newcommand\csname foo#1\endcsname{#2}
\expandafter\newcommand\csname bar#1\endcsname{let us expand \foo#1 and show #2.}
}
\defFooAndBar{One}{the second argument}
\defFooAndBar{Two}{the second argument}
\begin{document}
\fooOne
\barOne
\fooTwo
\barTwo
\end{document}
However, there is an error generated:
! Undefined control sequence. \barOne ->let us expand \foo One and show the argument.
Apparently, Latex puts a blank space after \foo and therefore \foo#1 is not treated as a single entity. Is it possible to indicate the parser that they belong together?
\csname foo#1\endcsname
in the second line of the definition.