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.
newcommandis defined within thenewcommandthe innernewcommandneeds to use##1to access its first parameter, as#1refers to the parents first parameter. Also, need to usemakeatletter,maketatotheraround commands that use an@sign in them. – Peter Grill Nov 13 '11 at 17:04\newcommand". The\newcommandmacro 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? – Martin Scharrer Nov 13 '11 at 17:10