7

I am trying to produce 3 matrices on the same line. And on top of the each matrix, there is a name. I tried using tabular for the names and then I use align for the matrices. However, this creates some kind of space between the names and the matrices, which I do not want. Is there a better way to do this ? I have seen other posts but they do not seem to solve my problem. Please note that I need to use bordermatrix because I need to label the rows and columns as well.

\begin{center}
\begin{tabular}{ccc}
Kay & Brian &  Edwin \\
\end{tabular}
\end{center}
\begin{align*}
\bordermatrix{ & I & A \cr
I &1 & 2 \cr
A & 3 & 4
} 
&
\bordermatrix{ & I & A \cr
I &5 & 6 \cr
A & 7 & 8
} 
&
\bordermatrix{ & I & A \cr
I &9 & 10 \cr
A & 11 & 12
} 
\end{align*}
  • Welcome to TeX.SE! Please convert your code snippets into a compilable MWE (minimum working example). The MWE should load any and all specialized packages you require as well as all custom commands you use. – Mico Sep 15 '13 at 18:48
5

The optional argument to \stackon which I set to 3pt, is the spacing between the matrix and the name.

\documentclass{article}
\usepackage{amsmath}
\usepackage[usestackEOL]{stackengine}[2013-09-11]

\begin{document}
\(
\stackon[3pt]{%
\bordermatrix{ & I & A \cr
I &1 & 2 \cr
A & 3 & 4
}%
}{Kay}\quad
\stackon[3pt]{%
\bordermatrix{ & I & A \cr
I &5 & 6 \cr
A & 7 & 8
}%
}{Brian}\quad
\stackon[3pt]{%
\bordermatrix{ & I & A \cr
I &9 & 10 \cr
A & 11 & 12
} %
}{Edwin}
\)
\end{document}

enter image description here

  • Do I need to install a package usestackEOL ? – user1769197 Sep 15 '13 at 19:21
  • @user1769197 No, [usestackEOL] is an package option on the stackengine package. I could actually omit it for this case, because I didn't make use of a stack that employed that feature. – Steven B. Segletes Sep 15 '13 at 19:25
  • But I do need to install stackengine package right ? – user1769197 Sep 15 '13 at 19:32
  • @user1769197 yes, It is at ctan.org/pkg/stackengine. In the short run, you can place the .sty file in your working directory, if your installation doesn't know how to install it. In the long run, you should figure out where LaTeX would like to place the file on your system. – Steven B. Segletes Sep 15 '13 at 19:41
  • thanks a lot for your great answer. Just want to know where should i place the packages in the long run. Because I dont have "texmf" folder on my system and I am using texmaker at the moment. – user1769197 Sep 15 '13 at 19:54
5

The following example converts \bordermatrix to a math operator \mathop that allows putting a "limit" (superscript) on top of it.

Just for fun, two variants follow:

  1. Curly brace over the matrix below the label.

  2. Matrix label in the top left corner of the matrix.

\documentclass{article}
\usepackage{amsmath}

\newcommand*{\topbordermatrix}[2]{%
  {\mathop{\bordermatrix{#2}}\limits^{\mbox{#1}}}%
}

\begin{document}
  \begin{align*}
    \topbordermatrix{Kay}{ & I & A \cr
    I &1 & 2 \cr
    A & 3 & 4
    }
    &&
    \topbordermatrix{Brian}{ & I & A \cr
    I &5 & 6 \cr
    A & 7 & 8
    }
    &&
    \topbordermatrix{Edwin}{ & I & A \cr
    I &9 & 10 \cr
    A & 11 & 12
    }
  \end{align*}

  \renewcommand*{\topbordermatrix}[2]{%
    {\overbrace{\bordermatrix{#2}}^{\mbox{#1}}}%
  }
  \begin{align*}
    \topbordermatrix{Kay}{ & I & A \cr
    I &1 & 2 \cr
    A & 3 & 4
    }
    &&
    \topbordermatrix{Brian}{ & I & A \cr
    I &5 & 6 \cr
    A & 7 & 8
    }
    &&
    \topbordermatrix{Edwin}{ & I & A \cr
    I &9 & 10 \cr
    A & 11 & 12
    }
  \end{align*}

  \renewcommand*{\topbordermatrix}[2]{%
    {\settowidth{\dimen0}{$\scriptstyle\text{#1}$}\kern\dimen0}%
    {\settowidth{\dimen0}{$A$}\kern-\dimen0}%
    \kern-\tabcolsep
    \bordermatrix{\hfill\llap{$\scriptstyle\text{#1}$}\kern-\tabcolsep #2}%
  }  
  \begin{align*}
    \topbordermatrix{Kay}{ & I & A \cr
    I &1 & 2 \cr
    A & 3 & 4
    } 
    &&
    \topbordermatrix{Brian}{ & I & A \cr
    I &5 & 6 \cr
    A & 7 & 8
    } 
    &&
    \topbordermatrix{Edwin}{ & I & A \cr
    I &9 & 10 \cr
    A & 11 & 12
    }
  \end{align*} 
\end{document}

Result

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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