2

I'm trying to draw a triangle-shaped commutative diagram using the tikz-cd package. Here is my LaTeX source:

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

\begin{document}
\begin{tikzcd} 
{}& A \arrow{dl}\arrow{dr}& \\
B\arrow{r}   &&  C
\end{tikzcd}
\end{document}

I tried to follow the post of Sigur in tikz-cd error: Single ampersand used with wrong catcode but I still get the error message

! Package pgf Error: No shape named tikz@f@1-2-2 is known.

Playing with ampersands was of no help. (I can easily draw a commutative diagram of the form of a right triangle by placing A in the first column, but I don't see why I cannot use my above code to place A in the middle column and get an isosceles triangle.)

3
  • 1
    I believe you want \arrow{rr} in the bottom row (and no trailing & in the top row).
    – egreg
    Commented Sep 23, 2016 at 19:38
  • @egreg Sorry, didn't see your comment before I posted the answer. Do you want to answer instead? Commented Sep 23, 2016 at 19:40
  • @TorbjørnT. Don't worry!
    – egreg
    Commented Sep 23, 2016 at 19:42

1 Answer 1

3

That error means that there is no node in the second cell on the second row, as there is no content there. To get around that you can add {} in that cell, or [nodes in empty cells] after \begin{tikzcd}.

That said, I presume you want the arrow to go all the way from B to C, so you want \arrow{rr}, not \arrow{r}.

enter image description here

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

\begin{document}
\begin{tikzcd} 
{}& A \arrow{dl}\arrow{dr}& \\
B\arrow{r}   & {} &  C
\end{tikzcd}

\begin{tikzcd}[nodes in empty cells]
{}& A \arrow{dl}\arrow{dr}& \\
B\arrow{r}   &  &  C
\end{tikzcd}

\begin{tikzcd} 
{}& A \arrow{dl}\arrow{dr}& \\
B\arrow{rr}   &  &  C
\end{tikzcd}
\end{document}
2
  • Thank you for the nodes in empty cells, that's really nice. By the way, I've noticed that I can remove {} in the first line and the code runs on my computer with no errors. Why is that? I was expecting to get an error without it as I learned from the post that I've linked to my question.
    – EPS
    Commented Sep 23, 2016 at 19:44
  • @EPS I don't know why that was required before, but that question was written before version 3 of TikZ came out I believe, so probably something has changed in TikZ's handling of their matrix nodes. Commented Sep 23, 2016 at 19:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .