MHB How do I put matrices in columns

  • Thread starter Thread starter Swlabr1
  • Start date Start date
  • Tags Tags
    Columns Matrices
AI Thread Summary
To display matrices side-by-side in LaTeX, one can simply place the matrix code next to each other within the math environment. For example, using the command $$\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]$$ achieves this layout. If the LaTeX code is not rendering correctly, it may be due to hidden formatting characters or incorrect syntax, such as missing spaces between commands. For functions, the align environment can be utilized to present them side-by-side, using commands like \quad or \qquad for spacing. Proper formatting and avoiding embedded characters are crucial for successful rendering in LaTeX.
Swlabr1
Messages
15
Reaction score
0
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:
Physics news on Phys.org
Swlabr said:
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] \]
 
Prove It said:
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.)
 
You mean something like

$\begin{eqnarray}
f(x) &=& x\\
g(x) & =& x^2
\end{eqnarray}$
 
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:
Danny said:
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*}$

 
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.
 
rapid said:
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:
Swlabr said:
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:
  • #10
rapid said:
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?
 
  • #11
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 ftp://ftp.ams.org/ams/doc/amsmath/amsldoc.pdf (PDF).
 
  • #12
Swlabr said:
So, what is it the \; are doing?
\; is just a space in math environment, in decreasing order of space you have \; \: \,
 
  • #13
rapid said:
\; 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.
 
  • #14
Swlabr said:
$$\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)$$
 
  • #15
Swlabr said:
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:
  • #16
Swlabr said:
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}
 

Similar threads

Back
Top