# Equation and image aligned on beamer slide

I'm trying to make a beamer slide which has some matrix equations and an image lined up with each other. Here is my attempt:

\begin{frame}\frametitle{Transportation polytope constraints}
A $\nu$-index transportation polytope is a polytope with constraint equation $Ax = b$
with the entries of $b$ the $S^j_{m_j}$ sums along hyperplane slices,
and each column of $A$ has $\nu$ ones and the remainder of the entries are zero.

{\small
\begin{tabular}{p{2.5cm} l}
\includegraphics[keepaspectratio=true,width=.2\paperwidth{Presentation/BetterCubicPolytope.png} &
$A = \left( \begin{array}{c c c c c c c c} 1 & 1 & 1 & 1 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 1 & 1 & 1 & 1\\ 1 & 0 & 1 & 0 & 1 & 0 & 1 & 0\\ 0 & 1 & 0 & 1 & 0 & 1 & 0 & 1\\ 1 & 1 & 0 & 0 & 1 & 1 & 0 & 0\\ 0 & 0 & 1 & 1 & 0 & 0 & 1 & 1 \end{array} \right)\qquad b = \left(\begin{array}{c} 14\\ 19\\ 20\\ 13\\26\\ 7 \end{array} \right)$\end{tabular}}
\end{frame}


And what it ends up looking like is this:

Related is probably the fact that when I compile it complains about an end{frame} error (but still renders the slide). When I replace the graphics with some sort of text it lines up the equation environment correctly, but I still get the error.

• one problem is a missing ] at the end of the optional argument to \includegraphics -- add it after .2\paperwidth. without a compilable example, i can't go further, but david is going in the right direction. – barbara beeton Nov 17 '14 at 18:39
• Ack, that seems to have been deleted when I was re-arranging my code into the format necessary for a code block (four spaces in for each line). The process seemed unnecessarily cumbersome, is there some way beyond manually spacing each line? Sorry about that. – David Benson-Putnins Nov 17 '14 at 23:57
• above the block for entering answers, one of the icons is a pair of braces -- '{ }. run your cursor down the code block to highlight it, then click on that icon and it magically indents. agreed -- having to type in the four leading spaces is at best a drag. – barbara beeton Nov 18 '14 at 13:03

Use \begin{array}[b] so the reference point for the array is on its bottom row, or use \raisebox to move the reference point of the image. In this case you probably want to use \raisebox so as not to change the alignment of the =.
 \raisebox{-.5\height}{\includegraphics...

I can't comment in detail the errors you say your document generated as you have not provided a test document that generates them, fragments are not so useful as a complete document, but you seem to have the tabular specifications the wrong way round  is a display environment so can be in a p column but not an l column, whereas the \includegraphics would be better in an l. • Swapping the p and l columns killed the weird error I was getting, thanks. I didn't really understand what it was doing, I just got it off an example from google (for a different but similar type of problem with aligning things). The raisebox command was able to fit everything perfectly as well! I wasn't able to get adding a [b] in front of begin{array} though; it threw an error and from the documentation on arrays I don't see the optional command there. – David Benson-Putnins Nov 18 '14 at 0:03 Another option is to load \usepackage[export]{adjustbox} and use valign=c in \includegraphics[keepaspectratio=true,width=.2\paperwidth,valign=c]{example-image-a}  Code: \documentclass{beamer} \usepackage[export]{adjustbox} \begin{document} \begin{frame}\frametitle{Transportation polytope constraints} A \nu-index transportation polytope is a polytope with constraint equation Ax = b with the entries of b the S^j_{m_j} sums along hyperplane slices, and each column of A has \nu ones and the remainder of the entries are zero. {\small \begin{tabular}{p{2.5cm} l} \includegraphics[keepaspectratio=true,width=.2\paperwidth,valign=c]{example-image-a} & \[A = \left( \begin{array}{c c c c c c c c} 1 & 1 & 1 & 1 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 1 & 1 & 1 & 1\\ 1 & 0 & 1 & 0 & 1 & 0 & 1 & 0\\ 0 & 1 & 0 & 1 & 0 & 1 & 0 & 1\\ 1 & 1 & 0 & 0 & 1 & 1 & 0 & 0\\ 0 & 0 & 1 & 1 & 0 & 0 & 1 & 1 \end{array} \right)\qquad b = \left(\begin{array}{c} 14\\ 19\\ 20\\ 13\\26\\ 7 \end{array} \right)\end{tabular}}
`