3

I have this code:

\[
    \begin{bmatrix}
    Pagerank&Sidnummer\\
    0.068945&2\\
    0.068945&3\\
    0.076517&1\\
    0.076517&4\\
    0.11536&7\\
    0.11536&8\\
    0.11536&6\\
    0.11536&5\\
    0.14069&9\\
    0.14069&12\\
    0.16501&14\\
    0.33015&13\\
    0.33015&15\\
    0.56601&10\\
    0.56601&11\\
    \end{bmatrix}
\]
\[
    \begin{bmatrix}
    Pagerank&Sidnummer\\
    0.076517&1\\
    0.068945&2\\
    0.068945&3\\
    0.076517&4\\
    0.11536&5\\
    0.11536&6\\
    0.11536&7\\
    0.11536&8\\
    0.14069&9\\
    0.56601&10\\
    0.56601&11\\
    0.14069&12\\
    0.33015&13\\
    0.16501&14\\
    0.33015&15\\
    \end{bmatrix}
\]

And individually the matrices are correct. But I don't like the way they display on the screen. The second matrix is placed beneath the first one. I want them to share the horizontal space and lay next to each other. Is this possible?

David Carlisle
  • 757,742
  • and btw I read http://tex.stackexchange.com/questions/9901/how-to-have-matrices-side-by-side-in-latex but if I remove the ] [ that are in between the two matrices, it results in many errors. –  May 06 '11 at 20:13
  • You can remove ] and [ but without leaving any blank lines; in my answer I used % to comment out one blank line between the matrices thus making the code more "readable" while preventing an error. – Gonzalo Medina May 06 '11 at 20:18

1 Answers1

5

Place them inside the same displayed environment:

\documentclass[a4paper,10pt]{article}
\usepackage{amsmath}

\begin{document}

\[
    \begin{bmatrix}
    \textrm{Pagerank} & \textrm{Sidnummer}\\
    0.068945&2\\
    0.068945&3\\
    0.076517&1\\
    0.076517&4\\
    0.11536&7\\
    0.11536&8\\
    0.11536&6\\
    0.11536&5\\
    0.14069&9\\
    0.14069&12\\
    0.16501&14\\
    0.33015&13\\
    0.33015&15\\
    0.56601&10\\
    0.56601&11\\
    \end{bmatrix}%\hspace*{20pt} % to increase the horizontal space
%
    \begin{bmatrix}
    \textrm{Pagerank} & \textrm{Sidnummer}\\
    0.076517&1\\
    0.068945&2\\
    0.068945&3\\
    0.076517&4\\
    0.11536&5\\
    0.11536&6\\
    0.11536&7\\
    0.11536&8\\
    0.14069&9\\
    0.56601&10\\
    0.56601&11\\
    0.14069&12\\
    0.33015&13\\
    0.16501&14\\
    0.33015&15\\
    \end{bmatrix}
\]

\end{document}

Note that I used the \textrm command to change the font for the text part. You can use \hspace to increase the horizontal separation between the matrices (commented out in my example).

David Carlisle
  • 757,742
Gonzalo Medina
  • 505,128
  • Thank you, that worked. The % in between the two matrices seem to be key, if I remove it I get an error. Why is that? I'm marking this as the correct solution, it works perfect. –  May 06 '11 at 20:21
  • 1
    @Calle: \par is not allowed in math mode; leaving a blank line is equivalent to using \par and this will trigger an error (tipically the well known Missing $ inserted). – Gonzalo Medina May 06 '11 at 20:27