Having two or more matrices centered on one line

I have the following code:

$$A = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}$$ and $$B = \begin{bmatrix} 0 & 0 \\ 0 & 0 \end{bmatrix}$$.


But this is displayed on two lines. How can I make these matrices as well as text appear on the center of the page, all in one line?

Use \text to write text within displayed math. However, you'll have to handle the spacing inside the \text command, since spacing is ignored in math mode. Also, you'd want to move the final period inside the display math, to prevent it from appearing on a new line.

$$A = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}\text{ and } B = \begin{bmatrix} 0 & 0 \\ 0 & 0 \end{bmatrix}.$$


If you want more space between the matrices, try \quad\text{and}\quad.

(Note: you'll get slightly better spacing if you use $ and $ to begin/end display math instead of $$.) • Thank you. That was useful. How do I represent a matrix with [ and [ though? It transforms the matrix into the array – nz_ Commented Nov 5, 2015 at 19:55 • Not “slightly better”: $$ should not be used in LaTeX. Ever. Commented Nov 5, 2015 at 23:01

You probably want (amsmath package is used):

$A = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix} \text{ and }B = \begin{bmatrix} 0 & 0 \\ 0& 0 \end{bmatrix}$

• You mean \text, rather than text, right? Commented Nov 5, 2015 at 19:50
• @ArunDebray Certainly. Corrected. Thank you! Commented Nov 5, 2015 at 20:21