Possible Duplicate:
What is the meaning of double pound symbol (##1) in an argument?
I'm quite sure this question has been asked many times but I can't find the answer.
I'd like to make a macro defining a new macro but I can't get the arguments working. How do I escape the parameter place-holders e.g. #1 for the inner command? Here is an absolutely senseless minimal example:
\documentclass{article}
\newcommand{\defprint}[1]{%
\newcommand{\print}[1]{#1\#1}
}
\begin{document}
\defprint{foo}
\print{bar}
\print{boo}
\end{document}
Gives "foo#1 foo#1" but I want it to be "foobar fooboo".
Additionally I'd like to know how to do the same in plain Tex using \def
. I'd expect something like the following, but the backslash seems to be the wrong kind of escape character too.
\documentclass{article}
\def\defprint#1{%
\def\print\#1{#1\#1}
}
\begin{document}
\defprint{foo}
\print{bar}
\print{boo}
\end{document}