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

Discussion Overview

The discussion focuses on how to display matrices and functions side-by-side in LaTeX. Participants explore various methods for formatting mathematical expressions, including matrices and functions, in a visually appealing manner within documents.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Debate/contested

Main Points Raised

  • Some participants suggest placing matrices next to each other in LaTeX by simply typing the code for each matrix side-by-side.
  • Others propose using the display math environment and commands like \quad or \qquad to create spacing between functions.
  • A participant questions how to write functions side-by-side, mentioning the use of the align environment.
  • There are suggestions for using the eqnarray and align environments to format functions, with examples provided.
  • Some participants express concerns about LaTeX rendering issues, suggesting that hidden characters or formatting might be causing problems.
  • One participant notes that the spacing commands in math environments, such as \;, can be used to adjust the appearance of expressions.
  • Another participant mentions that certain environments like gathered, aligned, and alignedat can be used for formatting without occupying the entire line.

Areas of Agreement / Disagreement

Participants generally agree on the methods for placing matrices and functions side-by-side, but there is no consensus on the best approach or the specific rendering issues encountered.

Contextual Notes

Some participants highlight potential issues with LaTeX rendering due to non-printing characters or formatting issues that may arise from copying and pasting code.

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