I was wondering how to reduce the duplication of code when using \newcommand. The following code is highlights for explaining things, full TeX code can be found here and the compiled PDF here:
\newcommand\transone{\ensuremath{\ket{2,2} \rightarrow \ket{1,1}}\xspace}
\newcommand\transtwo{\ensuremath{\ket{1,1} \rightarrow \ket{2,0}}\xspace}
\newcommand\transfull{\ensuremath{\ket{2,2} \rightarrow \ket{1,1} \rightarrow \ket{2,0}}\xspace}
\newcommand\ground[1]{\ensuremath{\ket{\text{#1}}}\xspace}
\newcommand\exited{\ensuremath{\ket{\text{e}}}\xspace}
Then you can declare something like declaring a \newmathcommand instead:
\newcommand\newmathcommand[2]{\newcommand#1{\ensuremath{ #2 } \xspace}}
And then declare commands by
\newmathcommand\transone{\ket{2,2} \rightarrow \ket{1,1}}
to reduce redundancy. But this prevents me from passing arguments like with \ground. Is there a way to assemble a command that can pass arguments such that you can declare that a command takes input, like this:
\newmathcommand\ground[1]{\ket{\text{#1}}}
Best, Theis


\newcommand{\exited}{\ket{\text{e}}. You gain nothing in being able to use\exitedin text mode; in that case type$\exited$and you have no problem with spaces. – egreg Dec 06 '13 at 10:10