In a paper I am writing, I need to to draw double complex, which is a fairly complicated commutative diagram. I wrote it using tikzcd, and the code is the following
\documentclass{article}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{tikz-cd}
\newcommand{\s}[1]{\mathscr{#1}}
\begin{document}
\begin{tikzcd}
& 0 \arrow{r}
& O_X \arrow{r}{\partial}\arrow{d}{i}
& \Omega^1_X \arrow{r}{\partial}\arrow{d}{i}
& \dots\arrow{r}{\partial}\arrow{d}{i}
& \Omega^n_X\arrow{r}\arrow{d}{i}
& 0 \\
& 0 \arrow{r}
& \s{A}\arrow{r}{\partial}\arrow{d}{\bar{\partial}}
& \s{A}^{1,0}\arrow{r}{\partial}\arrow{d}{\bar{\partial}}
& \dots\arrow{r}{\partial}\arrow{d}{\bar{\partial}}
& \s{A}^{n,0}\arrow{r}\arrow{d}{\bar{\partial}}
& 0 \\
& 0 \arrow{r}
& \s{A}^{0,1} \arrow{r}{\partial}\arrow{d}{\bar{\partial}}
& \s{A}^{1,1}\arrow{r}{\partial}\arrow{d}{\bar{\partial}}
& \dots \arrow{r}{\partial}\arrow{d}{\bar{\partial}}
& \s{A}^{n,1}\arrow{r}\arrow{d}{\bar{\partial}}
& 0 \\
&
& \tvdots\arrow{r}{\partial}\arrow{d}{\bar{\partial}}
& \tvdots\arrow{r}{\partial}\arrow{d}{\bar{\partial}}
& \tvdots\arrow{r}{\partial}\arrow{d}{\bar{\partial}}
& \tvdots\arrow{r}{\partial}\arrow{d}{\bar{\partial}}
& \\
& 0 \arrow{r}
& \s{A}^{0,n}\arrow{r}{\partial}
& \s{A}^{1,n}\arrow{r}{\partial}
& \dots\arrow{r}{\partial}
& \s{A}^{n,n}\arrow{r}{\partial}
& 0\\
\end{tikzcd}
\end{document}
Since I need to draw the same diagram multiple times, I thought that I could define a control sequence
\def\DoubleComplex{
"All the code you saw above"
}
When I try to compile it using
\[
\DoubleComplex
\]
I keep getting the following error message:
! Missing $ inserted.
<inserted text>
$
l.234 \DoubleComplex
I wonder what is going on? And what would be a good way to reuse a commutative diagram?
\protect\DoubleComplex
, but that's a guess only.! Undefined control sequence. <recently read> \s
if I try to make a document from your fragment