How do I put matrices in columns

  • Context: MHB 
  • Thread starter Thread starter Swlabr1
  • Start date Start date
  • Tags Tags
    Columns Matrices
Click For Summary
SUMMARY

This discussion focuses on displaying matrices side-by-side in LaTeX. Users provided solutions using the array and align environments, specifically employing commands like \texttt{\textbackslash begin\{pmatrix\}} and \texttt{\textbackslash begin\{align\}}. The issue of LaTeX not rendering correctly was attributed to hidden formatting characters and improper use of line breaks. The community emphasized retyping LaTeX code to avoid these rendering issues.

PREREQUISITES
  • Understanding of LaTeX syntax and environments
  • Familiarity with matrix formatting in LaTeX
  • Knowledge of the array and align environments
  • Basic troubleshooting skills for LaTeX rendering issues
NEXT STEPS
  • Research LaTeX matrix environments, specifically \texttt{pmatrix} and \texttt{array}
  • Learn about the \texttt{align} and \texttt{alignat} environments for aligning equations
  • Explore common LaTeX rendering issues and their solutions
  • Practice writing LaTeX code in a plain text editor to avoid formatting issues
USEFUL FOR

Students, researchers, and professionals who use LaTeX for typesetting mathematical documents, particularly those needing to format matrices and equations side-by-side.

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

  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 0 ·
Replies
0
Views
3K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
10K
Replies
7
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K