\documentclass{article}
\usepackage{amsmath,amscd,amssymb,amsthm,graphicx,amsxtra}
\usepackage{verbatim}
\usepackage{tikz-cd,xparse}
\usetikzlibrary{matrix,arrows,decorations.pathmorphing}
\newcommand {\dc}[3]{$#1_{#2,#3}$}
\begin{document}
\begin{tikzcd}
{} \dc B {-2} 2 \arrow[dotted]{l} &\dc B {-1} 2 \arrow{l} &dc B 0 2 \arrow{l} &\dc B 1 2 \arrow{l} & \dc B 2 2 \arrow{l} &{} \arrow[dotted]{l}\\
\end{tikzcd}
\end{document}
I wrote this and several variants of it (using braces, with no space, with 'ampersand replacement' and so on) to produce and sadly none of it worked. I know I can get around it by using (_) but would like to know why my code wasn't working. I need to produce several of such images and objects, this (for me) was the first step towards defining a newcommand but it failed miserably. The error which keep appearing is
Package pgfbasematrix Error: Single ampersand used with wrong catcode.
Missing } inserted
, complaining afterB {-2} 2
...