5

I was curious if it was possible to create a matrix within a table? for example i wanted to create a 2 column table with left containing text and the right containing a matrix. Could someone tell me the syntax?

Alan Munn
  • 218,180
howtotag
  • 169

2 Answers2

4

The suggested and generalized solution should be as follows. It has been used in my production. And vertical correction has been seriously taken into account for the sake of perfectness.

\documentclass[preview,border=12pt]{standalone}
\usepackage{amsmath}
\usepackage{array}
\usepackage{tikz}

\newcolumntype{A}[3]{%
    >{\minipage{\dimexpr#1\linewidth-#2\tabcolsep-#3\arrayrulewidth}\vspace\tabcolsep}%
    c
    <{\vspace\tabcolsep\endminipage}}



\def\correction#1{%
    \abovedisplayshortskip=#1\baselineskip\relax
    \belowdisplayshortskip=#1\baselineskip\relax
    \abovedisplayskip=#1\baselineskip\relax
    \belowdisplayskip=#1\baselineskip\relax
    }

\newcommand*\CL{\tabularnewline\hline}
\newcommand*\One{\[\int_a^b f(x)\,\textrm{d}x = F(b) - F(a)\]}
\newcommand*\Two{\[\lim_{x\to y} \frac{y^2-x^2}{y-x}\]}
\newcommand*\Three{\[\begin{pmatrix} a & b\\ c & d \end{pmatrix}\]}

\begin{document}
\begin{tabular}{|>{\centering}A{0.6}{2}{1.5}|>{\correction{-1}\strut}A{0.4}{2}{1.5}<{\strut}|}\hline
 Fundamental Theorem\\ of Calculus  & \One \CL
 Limit Function & \Two \CL
 \tikz \draw (2,1) circle (1) (1,1) -- (2,3) -- (3,0) -- cycle; & \Three \CL
\end{tabular}
\end{document}

enter image description here

Feel free to edit my answer if you think I did something that disobeys the best-practice protocols.

3

This is quite simple to do, but vertical spacing issues will quickly become a problem. The following example will work in a pinch, but if you search the site for "math in tables" you will find many questions regarding proper spacing of math inside a tabular environment. (Or see Marienplatz's answer. I've used the array package to create a column that is in mathmode.

\documentclass{article}
\usepackage{array}
\newcolumntype{C}{>{$}c<{$}} % centred math column
\begin{document}
\begin{tabular}{cC}
 This is an identity matrix &
\left(\begin{array}{ccc}1 & 0 & 0 \\0 & 1 & 0 \\0 & 0 & 1\end{array}\right)
\end{tabular}
\end{document}

output of code

Alan Munn
  • 218,180