6

I seem to be getting conflict between the eqnarray environment and the tabstackengine package (which is very useful for matrices, column vectors, etc.).

\documentclass{report}
\usepackage{tabstackengine}

\begin{document}

\begin{eqnarray*}
  v &=& \bracketMatrixstack{1 & 2 \\ 3 & 3} \bracketVectorstack{-3 \\ 2} \\
  a &=& b 
\end{eqnarray*}

\end{document}

I get about a million errors if I try to compile this!

cmhughes
  • 100,947

1 Answers1

10

The error has nothing to do with eqnarray (which should not be used anyway) apart from it being an alignment environment.

The problem is that tabstackengine doesn't protect the internal & from a possible outer alignment.

Just brace the matrix:

\documentclass{report}
\usepackage{amsmath}
\usepackage{tabstackengine}

\begin{document}

\begin{align*}
  v &= {\bracketMatrixstack{1 & 2 \\ 3 & 3}} \bracketVectorstack{-3 \\ 2} \\
  a &= b
\end{align*}

\end{document}

enter image description here

I'm not sure how this is better than

\documentclass{report}
\usepackage{amsmath}

\begin{document}

\begin{align*}
  v &= \begin{bmatrix} 1 & 2 \\ 3 & 3 \end{bmatrix} 
       \begin{bmatrix} -3 \\ 2 \end{bmatrix} \\
  a &= b
\end{align*}

\end{document}

enter image description here

You can fix tabstackengine:

\documentclass{report}
\usepackage{amsmath}
\usepackage{tabstackengine}

\makeatletter
\renewcommand\ensureTABstackMath[1]{%
  {\ifnum`}=\z@\fi
  \let\sv@TABmode\TAB@delim\TABstackMath#1\let\TAB@delim\sv@TABmode
  \ifnum`{=\z@\fi}%
}
\makeatother

\begin{document}

\begin{align*}
  v &= \bracketMatrixstack{1 & 2 \\ 3 & 3} \bracketVectorstack{-3 \\ 2} \\
  v &= \begin{bmatrix} 1 & 2 \\ 3 & 3 \end{bmatrix}
       \begin{bmatrix} -3 \\ 2 \end{bmatrix} \\
  a &= b
\end{align*}

\end{document}

but I still can't see any improvement.

enter image description here

egreg
  • 1,121,712