# Problems with table

I have some issues by creating my table. I can't find out to add: "Test3", "X1", and "Y1" - so it fit in -- in a good way.

My preamble:

\documentclass[a4paper]{article}
\usepackage{siunitx,booktabs,threeparttable}

% customize threeparttable
\renewcommand{\TPTnoteSettings}{\footnotesize}
\renewcommand{\TPTnoteLabel}[1]{#1}

\begin{document}

% natural width
\begin{table}[htp]
\centering

\begin{threeparttable}
\caption{What is this table about?}\label{test1}

\medskip

\begin{tabular}{
l
S[table-format=4.0]
S[table-format=3.0]
S[table-format=3.0]
S[table-format=3.0]
S[table-format=2.0]
}
\toprule
& \multicolumn{2}{c}{Name1} & \multicolumn{2}{c}{Name2} \\
\cmidrule(lr){2-3} \cmidrule(lr){4-5}
& {Factor1} & {Factor2} & {Factor1} & {Factor2} & {Total} \\
\midrule
Test 1 &   12 &  32 &   3 & 5     & 99 \\
Test 2 & 1234 & 234 & 334 & {---} & 99 \\
\bottomrule
\end{tabular}
\begin{tablenotes}
\item[Note:] A long note that goes beyond the table width
because we want to have many many words that
mean as little as possible
\end{tablenotes}
\end{threeparttable}
\end{table}

% enlarged width
\begin{table}[htp]
\centering
\begin{threeparttable}

\medskip

\begin{tabular*}{.8\textwidth}{
@{\extracolsep{\fill}}
l
S[table-format=4.0]
S[table-format=3.0]
S[table-format=3.0]
S[table-format=3.0]
S[table-format=2.0]
}
\toprule
& \multicolumn{2}{c}{Name1} & \multicolumn{2}{c}{Name2} \\
\cmidrule(lr){2-3} \cmidrule(lr){4-5}
& {Factor1} & {Factor2} & {Factor1} & {Factor2} & {Total} \\
\midrule
Test 1 &   12 &  32 &   3 & 5     & 99 \\
Test 2 & 1234 & 234 & 334 & {---} & 99 \\
\bottomrule
\end{tabular*}
\begin{tablenotes}
\item[Note:]
\end{tablenotes}
\end{threeparttable}
\end{table}

\end{document}


Thank you very much!

-

A few & where missing... and I added an extra column to insert the X1 and Y1

\begin{tabular}{
l
c
S[table-format=3.0]
S[table-format=3.0]
S[table-format=3.0]
S[table-format=3.0]
S[table-format=2.0]
}
\toprule
& & \multicolumn{2}{c}{Name1} & \multicolumn{2}{c}{Name2} & \\
\cmidrule(lr){3-4} \cmidrule(lr){5-6}
& & {Factor1} & {Factor2} & {Factor1} & {Factor2} & {Total} \\
\midrule
Test 1 &    &   12 &  32 &   3 &    5  & 99 \\
Test 2 &    & 1234 & 234 & 334 & {---} & 99 \\
Test 3 & X1 &    2 &   2 &   2 &    2  &  8 \\
& Y1 &    2 &   2 &   2 &    2  &  8 \\
\bottomrule
\end{tabular}
\begin{tablenotes}
\item[Note:] A long note that goes beyond the table width
because we want to have many many words that
mean as little as possible
\end{tablenotes}
\end{threeparttable}
\end{table}


And got

Cheers!

-
Thank you very much, Dox. If I would like to add a line between X1 and Y1, how do I do that? –  A. F. May 11 '14 at 13:41
@A.F. Just add a whole empty table line (in your case  & & & & & & \, because you have 7 columns, you'll need 6 separators. ;) –  Dox May 11 '14 at 13:46
@A.F. Since you are using booktabs, \addlinespace after the end of the X1 row is probably a better option. (At least, if you accept this part of the booktabs aesthetic.) –  cfr May 11 '14 at 13:52
It won't work. It should look like the line between "Name1" and "Factor1" and "Factor2". \underline won't work either. –  A. F. May 11 '14 at 13:56
@A.F. \usepackage{multirow} and use \multirow{2}{*}{Test 3} & X1 & 2 & 2 & 2 & 2 & 8 \\\cmidrule{2-2} –  Harish Kumar May 11 '14 at 14:19