In "Defining a newcommand, with variable name, inside another newcommand" we learned how to use \newcommand
within a command definition with another \newcommand
, when the name of the inner command needs to contain a parameter of the outer command. Now, suppose I want to do the same, but for the inner \newcommand
to also have parameters, i.e. I want the following code to work:
\newcommand{\defsilly}[1]{%
% define a command named silly#1 , taking a single parameter
}
\defsilly{willy}
\sillywilly{theparameter}
Motivation: I'm writing a thesis document class, which has a bunch of the following kind of command pairs:
\newcommand{\iitthesis@authorEnglish}{Name of Author}
\newcommand{\authorEnglish}[1]{\renewcommand{\iitthesis@authorEnglish}{#1}}
I want to replace each of these pairs with something like:
\iitthesis@thesisdatafield{authorEnglish}{Name of Author}
This defines both the above commands.
newcommand
is defined within thenewcommand
the innernewcommand
needs to use##1
to access its first parameter, as#1
refers to the parents first parameter. Also, need to usemakeatletter
,maketatother
around commands that use an@
sign in them.\newcommand
". The\newcommand
macro defines new commands, but these aren't "a\newcommand
". What are your trying to do now? Define a new macro given by name (plus prefix) or a new version of\newcommand
?