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




& A \arrow{dl}\arrow{dr} &\\
B \arrow{dr} & \arrow{dl} C\\
& D & 


When I compile this using pdflatex, I get the error:

Package pgfbasematrix Error: Single ampersand used with wrong catcode.

I've looked around on this site, in the documentation and online, and I've only seen this error arise before when using Beamer or trying to define a newcommand. Since I'm doing neither, I'm at a loss as to what's going on.


You missed one ampersand on the 2nd line.

Also, as observed by @egreg and the OP, the last & in the 1st and 3rd lines are not necessary, and you should start only the 1st line with {}.



{}& A \arrow{dl}\arrow{dr} & \\
B \arrow{dr} &&  C\arrow{dl} \\
  & D  

enter image description here

  • Ah, thanks. I toyed with changing the number of ampersands to see if that was the problem, but missed using {}. Why is this not always necessary when beginning a line with &? – Alex Becker May 31 '13 at 22:30
  • @AlexBecker, I don't why but sometimes we have to insert some characters with no effect, like {} to change the behavior of others. Maybe some expert could explain better. – Sigur May 31 '13 at 22:32
  • It's necessary only to start the first line with {}; the trailing & are not needed. I don't really know why the first & must be preceded by something (even empty), but it surely has to do with TikZ internals (matrices are quite strange in how they use &). – egreg May 31 '13 at 22:42
  • @egreg, I'll edit the post and cite your note. – Sigur May 31 '13 at 22:45
  • 1
    @Sigur I believe that the trailing & is not needed on the first line either. I just throw them in for bookkeeping. – Alex Becker May 31 '13 at 22:58

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.