2

My LaTeX document looks like this:

\documentclass{article}    
\usepackage{tikz-cd}

\newcommand{\commSq}[8]
{
    \begin{tikzcd}
        #1 \ar[r, "#2"] \ar[d, "#6"] & #3 \ar[d,"#4"] \\
        #7 \ar[r, "#8"] & #5
    \end{tikzcd}
}

\begin{document}
%1
\begin{tikzcd}
    A \ar[r, "f"] \ar[d, "g"] & B \ar[d,"h"] \\
    C \ar[r, "i"] & D
\end{tikzcd}
%2
\commSq{A}{f}{B}{h}{D}{g}{C}{i}
\end{document}

I figured that the part the code below %1 and the code below %2 do the same thing. However, using the command \commSq instead yields the error "Package pgf Error: Single ampersand used with wrong catcode. [...]" and I get this output:

enter image description here

What am I doing wrong here?

LaRiFaRi
  • 43,807

0 Answers0