Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
    
and btw I read tex.stackexchange.com/questions/9901/… but if I remove the ] [ that are in between the two matrices, it results in many errors. –  Calle May 6 '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 6 '11 at 20:18
add comment

1 Answer

up vote 5 down vote accepted

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).

share|improve this answer
    
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. –  Calle May 6 '11 at 20:21
    
@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 6 '11 at 20:27
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.