TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 5 down vote accepted

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

share|improve this answer
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
@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 posting your answer, you agree to the privacy policy and terms of service.

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