# Making an array in the Table

So we have an Table and there is an array which we wish to have it in the Table:

Here is the code

\documentclass[onecolumn,amsmath,amssymb,nofootinbib,superscriptaddress,floatfix]{revtex4}
\begin{document}

\begin{table}[!h]
\begin{tabular}{|c ||c| c| c| c|}
\hline
$d$ \; & \;  $Z$  & \; $UZ1$ & \; $UZ2$ & \; $U$\\
\; & \;   & \;       \;   & \;       \;   & \;   \\ \hline
$d=1$    \; & \; $S_1=\int x_1{}^2$,    & \;  $Y_3=\int y_3{}^2$,       \;   & \;       \;   & \;  \\
\; & \;  $S_2=\int x_2{}^2$  & \;   $G_4=\int g_4{}^2$    \;   & \;    \;   & \;   \\   \cline{2-5}
\; & \multicolumn{4}{l|}{$S1, S2, S3, \dots$ }  \\   \hline
$d=2$       \; & \;   & \;       \;   & \;     \;   & \;   \\
\; & \;   & \;       \;   & \;    \;   & \;   \\   \hline
\end{tabular}
\caption{}
\end{table}

$$\left\{ \begin{array}{ll} S_1=\int x_1{}^2,\\ S_2=\int x_2{}^2 \end{array} \right.$$

\end{document}


We have the array outside the Table I: Question: What we wish is that to put this array form:

$$\left\{ \begin{array}{ll} S_1=\int x_1{}^2,\\ S_2=\int x_2{}^2 \end{array} \right.$$


into the table, which a single array exactly joins the two command lines $S_1=\int x_1{}^2$, $S_2=\int x_2{}^2$ together inside the table. How to do that?

While we keep $Y3$ and $G_4$ separated not joined by another array.

• argggg all those \; came back:-) and the [!h] – David Carlisle May 24 '14 at 0:24

Here is a more compact code, with the cases and matrix* environments. In addition, as I don't like too small integrals, I used the medint switch from the nccmath package:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{fourier}

\usepackage{booktabs,mathtools, nccmath}
\def\mint{\medint\int}

\begin{document}

\renewcommand{\arraystretch}{1.2}% Stretch out the tabular
$\begin{array}{*{5}{c}} \toprule d & Z & UZ1 & UZ2 & U \\ \midrule d = 1 & \begin{cases} S_1 = \mint x_1{}^2, \\[3pt] S_2 = \mint x_2{}^2 \end{cases} & \begin{matrix*}[l]Y_3 = \mint y_3{}^2, \\ G_4 = \mint g_4{}^2\end{matrix*} \\ \addlinespace & \multicolumn{4}{l}{ S1, S2, S3, \dots } \\[0.5\normalbaselineskip] d = 2 \\ \bottomrule \end{array}$

\end{document} There's nothing fancy about putting an array inside a tabular: \documentclass{article}
\usepackage{booktabs,amsmath}
\begin{document}

\renewcommand{\arraystretch}{1.2}% Stretch out the tabular
\begin{tabular}{*{5}{c}}
\toprule
$d$ & $Z$ & $UZ1$ & $UZ2$ & $U$ \\
\midrule
$1$ & \raisebox{-.5\normalbaselineskip}{$\biggl\{$}$\begin{array}[t]{@{}r@{}l@{}} S_1 & {}= \int x_1{}^2, \\ S_2 & {}= \int x_2{}^2 \end{array}$ & $\begin{array}[t]{@{}r@{}l@{}} Y_3 & {}= \int y_3{}^2, \\ G_4 & {}= \int g_4{}^2 \end{array}$ \\
& \multicolumn{4}{l}{$S1, S2, S3, \dots$} \\[.5\normalbaselineskip]
$2$ \\
\bottomrule
\end{tabular}

\end{document}


If you must "keep Y3 and G4 ... not joined by another array", the following produces the exact same output (with proper alignment of Y3 and G4:

\documentclass{article}
\usepackage{booktabs,mathtools}
\begin{document}

\renewcommand{\arraystretch}{1.2}% Stretch out the tabular
\begin{tabular}{*{5}{c}}
\toprule
$d$ & $Z$ & $UZ1$ & $UZ2$ & $U$ \\
\midrule
$1$ & \smash{\raisebox{-.5\normalbaselineskip}{$\biggl\{$}$\begin{array}[t]{@{}r@{}l@{}} S_1 & {}= \int x_1{}^2, \\ S_2 & {}= \int x_2{}^2 \end{array}$} & $\phantom{G_4}\mathllap{Y_3} = \int y_3{}^2,$ \\
& & $G_4 = \int g_4{}^2\phantom{,}$ \\
& \multicolumn{4}{l}{$S1, S2, S3, \dots$} \\[.5\normalbaselineskip]
$2$ \\
\bottomrule
\end{tabular}

\end{document}

• OP asked "While we keep $Y3$ and $G_4$ separated not joined by another array." (which is why the alignment is worse in my image:-) – David Carlisle May 24 '14 at 0:41
• @DavidCarlisle: Done... sorry, it didn't seem reasonable. – Werner May 24 '14 at 0:54
• It's not:-) (actually OP may have just meant that Y_3/G_4 were not to be braced, so perhaps you should put it back – David Carlisle May 24 '14 at 1:05 \documentclass[onecolumn,amsmath,amssymb,nofootinbib,superscriptaddress,floatfix]{revtex4}
\usepackage{array}

\begin{document}

\begin{table}[htp]
\setlength\tabcolsep{8pt}
\setlength\extrarowheight{2pt}
\begin{tabular}{|c ||c| c| c| c|}
\hline
$d$  &   $Z$  &  $UZ1$ &  $UZ2$ &  $U$\\
&    &           &           &    \\ \hline
$d=1$     &
\smash{\raisebox{-10pt}{$\left\{ \begin{array}{ll} S_1=\int x_1{}^2,\\ S_2=\int x_2{}^2 \end{array} \right.$}}
&   $Y_3=\int y_3{}^2$,          &           &   \\[7pt]
&   &    $G_4=\int g_4{}^2$       &        &    \\   \cline{2-5}
& \multicolumn{4}{l|}{$S1, S2, S3, \dots$ }  \\   \hline
$d=2$        &    &           &         &    \\
&    &           &        &    \\   \hline
\end{tabular}
\caption{}
\end{table}

\end{document}


Here is a different approach.

\documentclass[onecolumn,amsmath,amssymb,nofootinbib,superscriptaddress,floatfix]{revtex4}
\usepackage{array}

\newcommand{\head}{%       %% code stolen from egreg
\bfseries
\begin{tabular}{@{}c@{}}
\strut#1\strut
\end{tabular}%
}

\begin{document}

\begin{table}[htp]
\setlength\tabcolsep{8pt}
\setlength\extrarowheight{2pt}
\begin{tabular}{|c ||c| c| c| c|}
\hline
$d$  &   $Z$  &  $UZ1$ &  $UZ2$ &  $U$\\ \hline
\head{$d=1$}     &
\head{$\left\{ \begin{array}{ll} S_1=\int x_1{}^2,\\ S_2=\int x_2{}^2 \end{array} \right.$}
&   \head{$Y_3=\int y_3{}^2$,\\[7pt] $G_4=\int g_4{}^2$ }          &           &   \\\cline{2-5}
& \multicolumn{4}{l|}{$S1, S2, S3, \dots$ }  \\   \hline
$d=2$        &    &           &         &    \\
&    &           &        &    \\   \hline
\end{tabular}
\caption{}
\end{table}

\end{document} And another:

\documentclass[onecolumn,amsmath,amssymb,nofootinbib,superscriptaddress,floatfix]{revtex4}
\usepackage{array}

\newcommand{\head}{%       %% code stolen from egreg
\begin{tabular}{@{}c@{}}
\strut#1\strut
\end{tabular}%
}

\begin{document}

\begin{table}[htp]
\setlength\tabcolsep{8pt}
\setlength\extrarowheight{2pt}
\begin{tabular}{|c ||c| c| c| c|}
\hline
$d$  &   $Z$  &  $UZ1$ &  $UZ2$ &  $U$\\ \hline
\raisebox{-1.5\height}{\head{$d=1$}}     &
\raisebox{-0.5\height}{\head{$\left\{ \begin{array}{ll} S_1=\int x_1{}^2,\\ S_2=\int x_2{}^2 \end{array} \right.$}}
&   $Y_3=\int y_3{}^2$,         &           &   \\[-1.25em]
&   &    $G_4=\int g_4{}^2$         &           &    \\   \cline{2-5}
& \multicolumn{4}{l|}{$S1, S2, S3, \dots$ }  \\   \hline
$d=2$        &    &           &         &    \\
&    &           &        &    \\   \hline
\end{tabular}
\caption{}
\end{table}

\end{document} 