[Tex/LaTex] Missing $ inserted inside matrix

errors

I'm getting "missing $ inserted" (along with a lot of other nearby errors, but that's the first one) on this snippet:

$$
(\tilde A-\lambda)^m =
\begin{blockarray}{(cccc)}
        \BAmulticolumn{3}{c}{\multirow{3}{*}{(A-\lambda)^m}} & \multirow{3}{*}{\vdots} \\
        & & & & \\ \\
        0 & \dots & 0 & (1-\lambda)^m
\end{blockarray}
\end{pmatrix}
$$

Specifically, it's at the line

\BAmulticolumn{3}{c}{\multirow{3}{*}{(A-\lambda)^m}} & \multirow{3}{*}{\vdots}

I can't find a way to see exactly where the $ was inserted, but either way I have no idea why there would be one there. The code renders fine, the error is just bothering me.

Best Answer

You were missing the $ in the \multirow and had an extraneous \end{pmatrix}:

enter image description here

Notes:

  • I replaced the $$...$$ with \[ ... \]. As Werner pointed out, please see Why is \[ ... \] preferable to $$ ... $$?.
  • The $ were required in the option to \multirow as that parameter is assumed to be in text mode. Using the $ ensures that math mode is used.

Code:

\documentclass{article}
\usepackage{amsmath}
\usepackage{blkarray}
\usepackage{multirow}

\begin{document}

\[
(\tilde A-\lambda)^m =
\begin{blockarray}{(cccc)}
        \BAmulticolumn{3}{c}{\multirow{3}{*}{$(A-\lambda)^m$}} & \multirow{3}{*}{\vdots} \\
        & & & & \\ \\
        0 & \dots & 0 & (1-\lambda)^m
\end{blockarray}
%\end{pmatrix}
\]
\end{document}