How do I put matrices in columns

In summary: 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
  • #1
Swlabr1
15
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
  • #2
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] \]
 
  • #3
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.)
 
  • #4
You mean something like

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

 
  • #7
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.
 
  • #8
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:
  • #9
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}
 

FAQ: How do I put matrices in columns

1. How do I put matrices in columns?

To put matrices in columns, you can use the column vector method. This involves organizing the elements of the matrix into a single column by listing them one after the other, starting with the first row and moving down.

2. Can I put matrices in columns without using the column vector method?

Yes, there are other methods to put matrices in columns such as using the transpose matrix or using the reshape function in programming languages like MATLAB.

3. Is there a specific way to arrange the elements of the matrix in a column?

Yes, when using the column vector method, it is important to arrange the elements in the same order as they appear in the original matrix. This means starting with the first row, and listing the elements in each subsequent row in the same order.

4. Why is it important to know how to put matrices in columns?

Knowing how to put matrices in columns is important in many areas of mathematics and science, particularly in linear algebra and data analysis. It allows for efficient storage and manipulation of data, and is a fundamental concept for solving equations and performing calculations with matrices.

5. Are there any common mistakes when putting matrices in columns?

One common mistake is mixing up the order of the elements or rows when arranging them in a column. It is also important to ensure that the dimensions of the original matrix and the column vector are compatible. Another common mistake is not properly labeling or identifying the elements in the column vector, which can lead to errors in calculations.

Similar threads

Replies
4
Views
2K
Replies
2
Views
10K
Replies
2
Views
2K
Replies
5
Views
1K
Replies
11
Views
2K
Replies
2
Views
2K
Back
Top