3

I try to make a diagram:

\[
\begin{tikzcd}[column sep=small]
                    &D^n \arrow{r}{e_\alpha^n}    &X\arrow{r} &X/(X-e_\beta^{n-1}(B^{n-1}))\\
S^{n-1}\arrow{r}{\cong} &\partial D^n \arrow{u}[hook] &D^{n-1} \arrow{u}[swap]{e_\beta^{n-1}} \arrow{r} &D^{n-1}/\partial D^{n-1} \arrow{u}[swap,dashed]{\cong} \arrow{r}{\cong} &S^{n-1}
\end{tikzcd}
\]

But when I compile, it simply says undefined control sequence referring to the line containing \end{tikzcd}, but does not give any reason. What is wrong?

P.S. I have included the packages

\usepackage{tikz}
\usetikzlibrary{matrix,arrows,decorations.pathmorphing}
\usepackage{tikz-cd}
\tikzset{commutative diagrams/.cd}
5

You had a syntax error in

\arrow{u}[hook]

it should be

\arrow[hook]{u}

Similarly (although this won't produce errors), instead of

\arrow{u}[swap,dashed]{\cong} 

you should use

\arrow[swap,dashed]{u}{\cong} 

otherwise, the dashed option is ignored. The code:

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

\begin{document}

\[
\begin{tikzcd}[column sep=small]
& D^n \arrow{r}{e_\alpha^n} & X\arrow{r} & X/(X-e_\beta^{n-1}(B^{n-1})) \\
S^{n-1}\arrow{r}{\cong} & \partial D^n \arrow[hook]{u} & D^{n-1} \arrow{u}[swap]{e_\beta^{n-1}} \arrow{r} &D^{n-1}/\partial D^{n-1} \arrow[swap,dashed]{u}{\cong} \arrow{r}{\cong} &S^{n-1}
\end{tikzcd}
\]

\end{document}

If you have a recent version of tikz-cd (using PGF/TikZ version 3.0), you have a more comfortable syntax (using the quotes library):

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

\begin{document}

\[
\begin{tikzcd}[column sep=small]
& D^n \arrow[r,"e_\alpha^n"] & X\arrow[r] & X/(X-e_\beta^{n-1}(B^{n-1})) \\
S^{n-1}\arrow[r,"\cong"] & \partial D^n \arrow[u,hook] & D^{n-1} \arrow[u,swap,"e_\beta^{n-1}"] \arrow[r] &D^{n-1}/\partial D^{n-1} \arrow[u,swap,dashed,"\cong"] \arrow[r,"\cong"] &S^{n-1}
\end{tikzcd}
\]

\end{document}

enter image description here

  • I just realized the problem. I should move the [hook] before {u}. Otherwise the hook effect does not work. – Y.H. Jul 17 '14 at 4:21
  • @Y.H. please see the second part of my edited answer for an option using a better (less prone to error) syntax; it requires updated packages (tikz-cd and PGF/TikZ). – Gonzalo Medina Jul 17 '14 at 4:23
  • @Y.H. And that was not the only problem; in the dashed arrow you also need to chenge the order of the arguments. – Gonzalo Medina Jul 17 '14 at 4:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.