Page LayoutMatrices on same line

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
david__taylor
Posts: 2
Joined: Wed Nov 25, 2009 2:54 pm

Matrices on same line

Post by david__taylor »

I have two 6x6 matrices in a latex document, and I want them to appear on the same line in the document. At the moment, the second one just sits below the first one. Can anyone help?

Thanks,

David


This is the code I have for the matrices:


\[ \left( \begin{array}{cccccc}
1 & 0 & 0 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 & 0 & 0 \\
0 & 0 & 1 & 0 & 0 & 0 \\
0 & 0 & 0 & 1 & 0 & 0 \\
0 & 0 & 0 & 0 & 1 & 0 \\
0 & 0 & 0 & 0 & 0 & 1
\end{array} \right)\]


\[ \left( \begin{array}{cccccc}
1 & 0 & 0 & 0 & 0 & 0 \\
1 & 0 & 0 & 0 & 0 & 0 \\
1 & 0 & 0 & 0 & 0 & 0 \\
1 & 0 & 0 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 & 0 & 0 \\
0 & 0 & 1 & 0 & 0 & 0
\end{array} \right)\]

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Matrices on same line

Post by gmedina »

Hi,

you could try something like the following:

Code: Select all

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{equation*}
\left( \begin{array}{cccccc}
  1 & 0 & 0 & 0 & 0 & 0 \\
  0 & 1 & 0 & 0 & 0 & 0 \\
  0 & 0 & 1 & 0 & 0 & 0 \\
  0 & 0 & 0 & 1 & 0 & 0 \\
  0 & 0 & 0 & 0 & 1 & 0 \\
  0 & 0 & 0 & 0 & 0 & 1
\end{array} \right)
\left( \begin{array}{cccccc}
  1 & 0 & 0 & 0 & 0 & 0 \\
  1 & 0 & 0 & 0 & 0 & 0 \\
  1 & 0 & 0 & 0 & 0 & 0 \\
  1 & 0 & 0 & 0 & 0 & 0 \\
  0 & 1 & 0 & 0 & 0 & 0 \\
  0 & 0 & 1 & 0 & 0 & 0
\end{array} \right)
\end{equation*}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
david__taylor
Posts: 2
Joined: Wed Nov 25, 2009 2:54 pm

Re: Matrices on same line

Post by david__taylor »

Thanks for the reply.

Do you know how to space them out across the page more? I want the first one on the left, and the next one on the right of the page (maybe with a bullet point before each or something like '(a)' before the first one and '(b)' before the 2nd one.???
php1ic
Posts: 192
Joined: Wed Jan 28, 2009 8:17 pm

Matrices on same line

Post by php1ic »

You can modify gmedina's code slightly and put each matrix as a single element of a larger array, with (a) and (b) in the neighbouring cells and use \hspace{} to create a gap between the two, as big or small as you wish.

Code: Select all

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{equation*}
\begin{array}{cccc}
(a)&
\left( \begin{array}{cccccc}
  1 & 0 & 0 & 0 & 0 & 0 \\
  0 & 1 & 0 & 0 & 0 & 0 \\
  0 & 0 & 1 & 0 & 0 & 0 \\
  0 & 0 & 0 & 1 & 0 & 0 \\
  0 & 0 & 0 & 0 & 1 & 0 \\
  0 & 0 & 0 & 0 & 0 & 1
\end{array} \right)\hspace{0.2\textwidth}&
(b)&
\left( \begin{array}{cccccc}
  1 & 0 & 0 & 0 & 0 & 0 \\
  1 & 0 & 0 & 0 & 0 & 0 \\
  1 & 0 & 0 & 0 & 0 & 0 \\
  1 & 0 & 0 & 0 & 0 & 0 \\
  0 & 1 & 0 & 0 & 0 & 0 \\
  0 & 0 & 1 & 0 & 0 & 0
\end{array} \right)
\end{array}
\end{equation*}

\end{document}
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Matrices on same line

Post by localghost »

Code: Select all

\documentclass[11p4,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}

\begin{document}
  \begin{alignat*}{2}
    (a)\quad &
    \begin{pmatrix}
      1 & 0 & 0 & 0 & 0 & 0 \\
      0 & 1 & 0 & 0 & 0 & 0 \\
      0 & 0 & 1 & 0 & 0 & 0 \\
      0 & 0 & 0 & 1 & 0 & 0 \\
      0 & 0 & 0 & 0 & 1 & 0 \\
      0 & 0 & 0 & 0 & 0 & 1
    \end{pmatrix} \qquad&
    (b)\quad &
    \begin{pmatrix}
      1 & 0 & 0 & 0 & 0 & 0 \\
      1 & 0 & 0 & 0 & 0 & 0 \\
      1 & 0 & 0 & 0 & 0 & 0 \\
      1 & 0 & 0 & 0 & 0 & 0 \\
      0 & 1 & 0 & 0 & 0 & 0 \\
      0 & 0 & 1 & 0 & 0 & 0
    \end{pmatrix}
  \end{alignat*}
\end{document}

Best regards and welcome to the board
Thorsten¹
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Matrices on same line

Post by gmedina »

An alternative to localghost's suggestion:

Code: Select all

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{flalign*}
  (a)\quad &
  \begin{pmatrix}
    1 & 0 & 0 & 0 & 0 & 0 \\
    0 & 1 & 0 & 0 & 0 & 0 \\
    0 & 0 & 1 & 0 & 0 & 0 \\
    0 & 0 & 0 & 1 & 0 & 0 \\
    0 & 0 & 0 & 0 & 1 & 0 \\
    0 & 0 & 0 & 0 & 0 & 1
  \end{pmatrix} \qquad&
  (b)\quad &
  \begin{pmatrix}
    1 & 0 & 0 & 0 & 0 & 0 \\
    1 & 0 & 0 & 0 & 0 & 0 \\
    1 & 0 & 0 & 0 & 0 & 0 \\
    1 & 0 & 0 & 0 & 0 & 0 \\
    0 & 1 & 0 & 0 & 0 & 0 \\
    0 & 0 & 1 & 0 & 0 & 0
  \end{pmatrix}
\end{flalign*}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Post Reply