# Why does Resizebox and blockarray give errors?

I am making a table using blkarray but I need to scale it so that it fits:

\documentclass{memoir}
\usepackage{blkarray}
\usepackage{graphicx}

\begin{document}
\begin{table}[tbp]
\caption{Lore ipsum}
\resizebox{\textwidth}{!}{
$\begin{blockarray}{rccccccccccccc} & O1 & C2 & O3 & C4 & C5 & C6 & C7 & C8 & C9 & C10 & O11 & O12 & C13 \\ \begin{block}{r[ccccccccccccc]} O1 & 0 & 2 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ C2 & 2 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \\ O3 & 0 & 1 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ C4 & 0 & 0 & 1 & 0 & 1.5 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\ C5 & 0 & 0 & 0 & 1.5 & 0 & 1.5 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ C6 & 0 & 0 & 0 & 0 & 1.5 & 0 & 1.5 & 0 & 0 & 0 & 0 & 0 & 0 \\ C7 & 0 & 0 & 0 & 0 & 0 & 1.5 & 0 & 1.5 & 0 & 0 & 0 & 0 & 0 \\ C8 & 0 & 0 & 0 & 0 & 0 & 0 & 1.5 & 0 & 1.5 & 0 & 0 & 0 & 0 \\ C9 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 1.5 & 0 & 1 & 0 & 0 & 0 \\ C10 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 2 & 1 & 0 \\ O11 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 2 & 0 & 0 & 0 \\ O12 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\ C13 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ \end{block} \end{blockarray}$
}
\end{table}
\end{document}

But I keep getting strange errors. How can this be accomplished?

The delimiters $...$ do not produce a horizontal-mode quantity that can be operated upon by \resizebox. Thus, change your $and$ delimiters to $and$.

Shown with showframe.

\documentclass{memoir}
\usepackage{blkarray}
\usepackage{graphicx}
\usepackage[pass,showframe]{geometry}

\begin{document}
\begin{table}[tbp]
\caption{Lore ipsum}
\resizebox{\textwidth}{!}{
$\begin{blockarray}{rccccccccccccc} & O1 & C2 & O3 & C4 & C5 & C6 & C7 & C8 & C9 & C10 & O11 & O12 & C13 \\ \begin{block}{r[ccccccccccccc]} O1 & 0 & 2 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ C2 & 2 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \\ O3 & 0 & 1 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ C4 & 0 & 0 & 1 & 0 & 1.5 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\ C5 & 0 & 0 & 0 & 1.5 & 0 & 1.5 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ C6 & 0 & 0 & 0 & 0 & 1.5 & 0 & 1.5 & 0 & 0 & 0 & 0 & 0 & 0 \\ C7 & 0 & 0 & 0 & 0 & 0 & 1.5 & 0 & 1.5 & 0 & 0 & 0 & 0 & 0 \\ C8 & 0 & 0 & 0 & 0 & 0 & 0 & 1.5 & 0 & 1.5 & 0 & 0 & 0 & 0 \\ C9 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 1.5 & 0 & 1 & 0 & 0 & 0 \\ C10 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 2 & 1 & 0 \\ O11 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 2 & 0 & 0 & 0 \\ O12 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\ C13 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ \end{block} \end{blockarray}$
}
\end{table}
\end{document}

• And so it shows how rarely I work with the equation parts of LaTeX... :) – jonalv Jul 27 '17 at 13:16
• @jonalv No problem. You will note that $...$ adds vertical space relative to surrounding elements. That is often an indicator that it is producing something in vertical (page) mode rather than horizontal (paragraph) mode. You would run into the same problem if you tried to put an \fbox around such quantities. – Steven B. Segletes Jul 27 '17 at 13:18