I have read the question and answers about:
- Defining a newcommand, with variable name, inside another newcommand
- How to define a macro to create a new macro with a name passed as its argument?
- What exactly do \csname and \endcsname do?
What I want to do is similar, but one step further. I would like to define a new command with a variable name, but the new command should have parameters (exactly one in my case).
I tried to use the hash symbol # twice, like this:
\newcommand{\deffun}[1]{\expandafter\newcommand[1]\csname #1\endcsname[1]{#1(##1)}}
But this does not seem to work and I am too confused or ignorant to produce a mwe with nesting of macro definitions with parameters. For an answer, pointing me to the relevant place of the documentation would be enough. It looks like nesting of macro definitions is not a commonly used nor explained feature.
PD: I was almost right, it is like this:
\newcommand{\deffun}[1]{\expandafter\newcommand\csname #1\endcsname[1]{#1(##1)}}

\newcommand[1]supposed to do? – jon Sep 10 '15 at 02:17\def\deffun#1{\expadafter\def\csname#1\endcsname##1{#1(##1)}}. The combination of TeX primitives\csname,\endcsnamewith the LaTeX macro\newcommandlooks funny. And pointer to the documentation? The TeXbook. – wipet Sep 10 '15 at 03:37*facepalm*I'm sorry, I was getting errors and I thought that everything was wrong because (honestly) I had no idea of what I was doing. Turns out that was the only problem to make it work... – Trylks Sep 10 '15 at 05:14