# How to have matrices side by side in latex?

I'm new to latex and all of my matrices seem to be created on new lines, I can't seem to put them side by side. Here is what I am doing to make a matrix (with the 2d identity matrix as an example):

$\left( \begin{array}{cc} 1 & 0 \\ 0 & 1 \end{array} \right)$


Am I making it wrong? How can I place a second matrix directly beside this, as you would when doing matrix mathematics? Thanks

Don't enclose each array with $...$; instead, put all the arrays that you want together within one set of delimeters. Like this:

$\left( \begin{array}{cc} 1 & 0 \\ 0 & 1 \end{array} \right) % \left( \begin{array}{cc} 1 & 0 \\ 0 & 1 \end{array} \right)$


You should read the mathmode documentation. It should be part of your TeX Distribution, and has lots of examples to follow.

• This makes sense. However, does this still handle things like [Matrix][vector] = [vector] all one one line?
– user3231
Jan 29 '11 at 20:49
• @bbel Sure. As long as they will fit on the same line, you can just put them one after another like this (no blank lines in between which is why I separated the two matrices in my example with a % (comment character)). Jan 29 '11 at 20:52

This is slightly tangential, but you might find it convenient to use the pmatrix environment (defined in amsmath.sty)

$\begin{pmatrix} 1 & 0 \\ 0 & e^{i\pi/k} \end{pmatrix} \begin{pmatrix} u \\ v \end{pmatrix} = \begin{pmatrix} u \\ -v \end{pmatrix}$


The idea is to enclose both matrices in one block i.e.  see this example

$\begin{bmatrix} a & b \\ c & d \end{bmatrix} = \begin{bmatrix} 8 & 1 \\ 7 & 6 \end{bmatrix}$


It will be something like: – Werner
Oct 19 '16 at 4:27

like this

$\left( \begin{array}{cc} 1 & 0 \\ 0 & 1 \end{array} \right) \times \left( \begin{array}{cc} 1 & 0 \\ 0 & 1 \end{array} \right) =\left( \begin{array}{cc} 1 & 0 \\ 0 & 1 \end{array} \right)$


You need to place the matrices inside the math environment

• Inside the math environment by surrounding them with the dollar sign operator? Because that gives me errors in itself..
– user3231
Jan 29 '11 at 20:45
• $..$ is a math environment When you use this environment the math expression is written on a single line. Like Alan, I think you should read the mathmode.pdf documentation from Herbert Voss. Jan 29 '11 at 21:18

Just doing this is enough; you don't need \left and \right.

$\begin{bmatrix} z_{1}^{(1)} \\ z_{2}^{(1)} \\ \end{bmatrix} = \begin{bmatrix} a_{0}^{(0)} & a_{1}^{(0)} & a_{2}^{(0)} \\ a_{0}^{(0)} & a_{1}^{(0)} & a_{2}^{(0)} \end{bmatrix} % \begin{bmatrix} w_{10}^{(1)} & w_{20}^{(1)} \\ w_{11}^{(1)} & w_{21}^{(1)} \\ w_{12}^{(1)} & w_{22}^{(1)} \end{bmatrix}$


I was confused by the answers and the syntax so I'll share mine and include an image. I'm using \begin{equation} which is arguably less convenient but also more verbose for beginners (like myself) than using the \[ syntax.
To be clear, what is causing the matrices to be on separate lines is the blank line between the min the code. If you fill it with the placeholder % or remove the line completely it will render like the attached picture. (Thanks to Teepeemm for clarifying what % is!)

\begin{equation}
\begin{bmatrix}
C_1 & C_2 & C_3 & C_4
\end{bmatrix}
%
\begin{bmatrix}
z_1 \\
z_2 \\
z_3 \\
z_4 \\
\end{bmatrix}
\end{equation} • The % in the middle is a place holder that doesn't need to be there. TeX doesn't allow have a blank line, so the % gives a line that isn't blank but doesn't have any consequences. Also, the \[ syntax is equivalent to \begin{equation*}. \begin{equation} (without the *) will number the equation. Dec 5 '18 at 15:29
• Thanks for your clarification on the %. That explains why my matrices didn't line up side-by-side when adding a space between them. They do however line up correctly without the % and without an empty line between them. Thanks for clearing that up for me! :) I'll modify my answer. Dec 6 '18 at 17:30