# tikzcd not working inside \newcommand? [closed]

Can anyone of you wonderful guys tell why this doesn't work?

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix,arrows,decorations.pathmorphing}
\usepackage{tikz-cd}

\newcommand{\cmd}[1]{#1}

\begin{document}
\cmd{%
$\begin{tikzcd} A \arrow{r}{f} & B \\ \end{tikzcd}$
}
\end{document}


while

$\begin{tikzcd} A \arrow{r}{f} & B \\ \end{tikzcd}$


works perfectly outside the \cmd?

## closed as off-topic by Sebastiano, Phelype Oleinik, Stefan Pinnow, TeXnician, BobyandbobJul 31 '18 at 21:22

• This question does not fall within the scope of TeX, LaTeX or related typesetting systems as defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

• \begin{tikzcd}[ampersand replacement=\&] and use \& instead of & – egreg May 17 '17 at 11:22
• Great, it works! (But why the "original" didn't?) Thank you!!! – kenNash May 17 '17 at 13:57
• I'm voting to close this question as off-topic because it is solved in the first comment. – Sebastiano Jul 31 '18 at 19:34
• Possible duplicate of Using tikzcd in newcommand (for inline arrows) – TeXnician Jul 31 '18 at 20:37