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.)

  • 1
    I believe you want \arrow{rr} in the bottom row (and no trailing & in the top row). – egreg Sep 23 '16 at 19:38
  • @egreg Sorry, didn't see your comment before I posted the answer. Do you want to answer instead? – Torbjørn T. Sep 23 '16 at 19:40
  • @TorbjørnT. Don't worry! – egreg Sep 23 '16 at 19:42
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}
  • 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 Sep 23 '16 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. – Torbjørn T. Sep 23 '16 at 19:53

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.