Welcome to our community

Be a part of something great, join today!

How do I put matrices in columns

Swlabr

New member
Feb 21, 2012
27
As the title says, how can I put my matrices in columns in Latex?

Say I had two matrices,

\[ \left( \begin{array}{ccc}a & b & c \\ d & e & f \\ g & h & i \end{array} \right) \]

and

\[ \left( \begin{array}{ccc}j & k & l \\ m & n & o \\ p & q & r \end{array} \right) \]

then how can I get them to be displayed side-by-side in my document?

(Also, any ideas as to why the latex I just posted isn't rendering would be much appreciated!)
 
Last edited by a moderator:

Prove It

Well-known member
MHB Math Helper
Jan 26, 2012
1,403
As the title says, how can I put my matrices in columns in Latex?

Say I had two matrices,

$$\left( \begin{array}{ccc}a & b & c \\d & e & f \\g & h & i \end{array} \right)$$

and

$$\left( \begin{array}{ccc}j & k & l \\m & n & o \\p & q & r \end{array} \right)$$

then how can I get them to be displayed side-by-side in my document?

(Also, any ideas as to why the latex I just posted isn't rendering would be much appreciated!)
Just type the code for each matrix next to each other...

\[ \displaystyle \left[\begin{matrix} a & b & c \\ d & e & f \\ g & h & i \end{matrix}\right]\left[\begin{matrix} j & k & l \\ m & n & o \\ p & q & r \end{matrix}\right] \]
 

Swlabr

New member
Feb 21, 2012
27
Just type the code for each matrix next to each other...

\[ \displaystyle \left[\begin{matrix} a & b & c \\ d & e & f \\ g & h & i \end{matrix}\right]\left[\begin{matrix} j & k & l \\ m & n & o \\ p & q & r \end{matrix}\right] \]
Hmm. Okay. Well, I was asking about matrices 'cause I thought they would be similar - I am actually trying to write functions (actually, I'm not entirely sure why I asked about matrices and not functions...but anyway!). Although you could write functions in the array environment, they look kinda...laboured. So is there anything you can do to try and write two functions side-by-side? (so, using align.)
 

Jester

Well-known member
MHB Math Helper
Jan 26, 2012
183
You mean something like

$\begin{eqnarray}
f(x) &=& x\\
g(x) & =& x^2
\end{eqnarray}$
 

rapid

New member
Jan 31, 2012
13
side by side could be done using the display math environment to get it centered and \quad command to get it in `columns'

Code:
$$
f(x) = x \quad g(x) = x^{2}
$$
or use \qquad for an even bigger gap.
 
Last edited:

Swlabr

New member
Feb 21, 2012
27
You mean something like

$\begin{eqnarray}
f(x) &=& x\\
g(x) & =& x^2
\end{eqnarray}$
I mean like,

$\begin{align*}
f: x&\mapsto x^2\\
y&\mapsto x+1
\end{align*}$

 

rapid

New member
Jan 31, 2012
13
Do you have any way of drawing what you want on paper and then uploading the picture for us? Or even drawing it in Paint.
 

Swlabr

New member
Feb 21, 2012
27
Do you have any way of drawing what you want on paper and then uploading the picture for us? Or even drawing it in Paint.
I want it to look like, but less...clunky,

$$\displaystyle\begin{matrix} f: & a & \mapsto & b \\ & c & \mapsto & d \end{matrix}\begin{matrix} h: & e & \mapsto & f \\ & g & \mapsto & h \end{matrix}$$

(although, again the LaTeX doesn't want to render correctly!)
 
Last edited:

rapid

New member
Jan 31, 2012
13
I want it to look like, but less...clunky,

$$\displaystyle\begin{matrix} f: & a & \mapsto & b \\ & c & \mapsto & d \end{matrix}\begin{matrix} h: & e & \mapsto & f \\ & g & \mapsto & h \end{matrix}$$

(although, again the LaTeX doesn't want to render correctly!)

Ok try this,

\begin{align*}
f:\; a&\mapsto b &h:\; e&\mapsto f\\
b&\mapsto d &g&\mapsto h\\
\end{align*}
 
Last edited:

Swlabr

New member
Feb 21, 2012
27
Ok try this,

\begin{align*}
f:\; a&\mapsto b &h:\; e&\mapsto f\\
b&\mapsto d &g&\mapsto h\\
\end{align*}
So, what is it the \; are doing?
 

Evgeny.Makarov

Well-known member
MHB Math Scholar
Jan 30, 2012
2,490
There are also environments gathered, aligned, and alignedat that are analogous to gather, align, and alignat but do not occupy the whole line and can be combined within a single-line equation. See the Guide for the amsmath Package (PDF).
 

rapid

New member
Jan 31, 2012
13
So, what is it the \; are doing?
\; is just a space in math environment, in decreasing order of space you have \; \: \,
 

Swlabr

New member
Feb 21, 2012
27
\; is just a space in math environment, in decreasing order of space you have \; \: \,
Okay, I'll try this. I've had problems using multiple &s in align before. I'll try again though.
 

Opalg

MHB Oldtimer
Staff member
Feb 7, 2012
2,697
$$\left( \begin{array}{ccc}j & k & l \\m & n & o \\p & q & r \end{array} \right)$$

...any ideas as to why the latex I just posted isn't rendering would be much appreciated!
There is nothing wrong with your LaTeX. But it looks as though you have copied and pasted it from somewhere else, and it has embedded within it some hidden font and color commands, which the TeX compiler used here cannot deal with. You can verify that by clicking on View>Source in your browser and searching for where the double dollar signs come on the page.

If I retype the exact same expression from scratch, then it compiles correctly as $$\left( \begin{array}{ccc}j & k & l \\m & n & o \\p & q & r \end{array} \right)$$
 

CaptainBlack

Well-known member
Jan 26, 2012
890
As the title says, how can I put my matrices in columns in Latex?

Say I had two matrices,

\[ \left( \begin{array}{ccc}a & b & c \\ d & e & f \\ g & h & i \end{array} \right) \]

and

\[ \left( \begin{array}{ccc}j & k & l \\ m & n & o \\ p & q & r \end{array} \right) \]

then how can I get them to be displayed side-by-side in my document?

(Also, any ideas as to why the latex I just posted isn't rendering would be much appreciated!)
Two things that the system did not seem to like in the LaTeX,

a) the \\ with no gap, seems sometimes to be interpreted as a link and won't compile (not the problem with your LaTeX I introduced that while trying to fix it)

b) there appear to be non-printing characters (or HTML formatting?) leaking into some posts somehow, copying your LaTeX to a text editor then copying it back seems to work for some reason.

I have also replaced double dollars with slash-square-bracket, but that does bot seem to be the problem.

CB
 
Last edited:

dwsmith

Well-known member
Feb 1, 2012
1,673
As the title says, how can I put my matrices in columns in Latex?

Say I had two matrices,

\[ \left( \begin{array}{ccc}a & b & c \\ d & e & f \\ g & h & i \end{array} \right) \]

and

\[ \left( \begin{array}{ccc}j & k & l \\ m & n & o \\ p & q & r \end{array} \right) \]

then how can I get them to be displayed side-by-side in my document?

(Also, any ideas as to why the latex I just posted isn't rendering would be much appreciated!)
Well since this posted isn't marked solved, I guess I will answer.
There seems to be two questions: in columns and side by side

Side by side
$$
\begin{pmatrix}
a & b\\
c & d\\
\end{pmatrix}

\begin{pmatrix}
a & b\\
c & d\\
\end{pmatrix}
$$

Code:
\begin{pmatrix}
a & b\\
c & d\\
\end{pmatrix}

\begin{pmatrix}
a & b\\
c & d\\
\end{pmatrix}
in a column

\begin{alignat}{1}
\begin{pmatrix}
a & b\\
c & d\\
\end{pmatrix}\\
\begin{pmatrix}
a & b\\
c & d\\
\end{pmatrix}
\end{alignat}

Code:
\begin{alignat}{1}
\begin{pmatrix}
a & b\\
c & d\\
\end{pmatrix}\\
\begin{pmatrix}
a & b\\
c & d\\
\end{pmatrix}
\end{alignat}