2

I write a code for a simple diagram using tikz-cd and does not compile. I don't know why, I have installed texlive-full in lubuntu 14.04 LTS.

\begin{tikzcd}

& C^\prime \arrow[dr, "g"]  & \\

C \arrow[ur, "f"]\arrow[rr, "g\circ f"] &   & C^{\prime\prime}

\end{tikzcd}

The error given is "Package tikz-cd Error: Arrow direction argument must contain only the characters u, d, l, r.".

If I write only one r instead of two, the same error message appear.

karlkoeller
  • 124,410
user
  • 307

1 Answers1

6

I only get errors because you can't put blank lines inside the tikzcd environment.

If you remove them, it compiles fine.

MWE:

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

\begin{document}

\begin{tikzcd}
& C^\prime \arrow[dr, "g"]  & \\
C \arrow[ur, "f"]\arrow[rr, "g\circ f"] &   & C^{\prime\prime}
\end{tikzcd}

\end{document} 

enter image description here

If you have an old tikz-cd you can try with the old syntax of \arrow

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

\begin{document}

\begin{tikzcd}
& C^\prime \arrow{dr}{g}  & \\
C \arrow{ur}{f}\arrow{rr}{g\circ f} &   & C^{\prime\prime}
\end{tikzcd}

\end{document} 

If it still fails, try adding blank atoms {} at empty positions (thanks to daleif for the suggestion), so either

\begin{tikzcd}
{} & C^\prime \arrow[dr, "g"]  & {}\\
C \arrow[ur, "f"]\arrow[rr, "g\circ f"] & {} & C^{\prime\prime}
\end{tikzcd}

or (with old syntax)

\begin{tikzcd}
{} & C^\prime \arrow{dr}{g}  & {}\\
C \arrow{ur}{f}\arrow{rr}{g\circ f} & {} & C^{\prime\prime}
\end{tikzcd}
karlkoeller
  • 124,410
  • Thanks, but.. if I copy and paste your code I obtain the following error message:

    ! Missing $ inserted.

    $ l.74 &C^ \prime \arrow[dr, "g"] & \\ I've inserted a begin-math/end-math symbol since I think you left one out. Proceed, with fingers crossed.
    – user Jan 10 '15 at 06:56
  • I already tried with that, but doesn't work either – user Jan 10 '15 at 06:58
  • @User You should update your TeX distribution... – karlkoeller Jan 10 '15 at 07:08
  • Can you explain me how I should do that? I have the 2. 1 version of pgf. I had just installed this (14.04 LTS) distribution of lubuntu and installed texlive-full.. What should I do now? – user Jan 10 '15 at 07:12
  • I think I realised why that code doesn't compile. I must write a white space with "\ " instead of nothing at all. I mean, the correct code will be:

    \begin{tikzcd} \ &C^\prime \arrow{rd}{g} &\\ C \arrow{ur}{f}\arrow{rr}{g\circ f} & & C^{\prime\prime} \end{tikzcd}

    I'm not sure if I must put this as a comment or as an answer. Thank you for your time (:

    – user Jan 10 '15 at 07:30
  • This shouldn't be needed... – karlkoeller Jan 10 '15 at 07:39
  • Yes, I know it shouldn't be. But that code compiles and the others don't. I don't know why it is needed only in the first place. Maybe if there isn't a character, doesn't take into account the first "&". – user Jan 10 '15 at 07:46
  • I'd just write {} in the blank cells. I've seen tikzcd fail because it could not detect anything in a cell. Adding a blank atom usually does the trick – daleif Jan 10 '15 at 08:17