# tables inside tables in latex

For explaining an example in my paper, I need to have 6 tables and I need to make them as a package. I tried to make a table with small tabled indide in excel and then convert it with a tool to latex but output is not desirable.

Could you help me to maybe edit this and get my desirable output. I need to pack 6 5*5 tables so that the first row of each table includes two cells (last 4 cells are merged).

\begin{tabular}{ | l | l | l | l | l | l | l | l | l | l | l | l | l | }
\hline
&  &  &  &  &  &  &  &  &  &  &  &  \\ \hline
& node's id & node's list &  &  &  &  & node's id & node's list &  &  &  &  \\ \hline
& 1 & 1 & 1 & 1 & 1 &  & 1 & 2 & 2 & 2 & 2 &  \\ \hline
& 2 & 1 & 1 & 1 & 1 &  & 3 & 2 & 2 & 2 & 2 &  \\ \hline
& 3 & 1 & 1 & 1 & 1 &  & 4 & 2 & 2 & 2 & 2 &  \\ \hline
& 4 & 1 & 1 & 1 & 1 &  & 5 & 2 & 2 & 2 & 2 &  \\ \hline
& 5 & 1 & 1 & 1 & 1 &  &  &  &  &  &  &  \\ \hline
&  &  &  &  &  &  &  &  &  &  &  &  \\ \hline
& node's id & node's list &  &  &  &  & node's id & node's list &  &  &  &  \\ \hline
& 2 & 3 & 3 & 3 & 3 &  & 1 & 4 & 4 & 4 & 4 &  \\ \hline
& 3 & 3 & 3 & 3 & 3 &  & 2 & 4 & 4 & 4 & 4 &  \\ \hline
& 4 & 3 & 3 & 3 & 3 &  & 3 & 4 & 4 & 4 & 4 &  \\ \hline
& 5 & 3 & 3 & 3 & 3 &  & 5 & 4 & 4 & 4 & 4 &  \\ \hline
&  &  &  &  &  &  &  &  &  &  &  &  \\ \hline
& node's id & node's list &  &  &  &  & node's id & node's list &  &  &  &  \\ \hline
& 1 & 5 & 5 & 5 & 5 &  & 1 & 6 & 6 & 6 & 6 &  \\ \hline
& 3 & 5 & 5 & 5 & 5 &  & 3 & 6 & 6 & 6 & 6 &  \\ \hline
& 4 & 5 & 5 & 5 & 5 &  & 4 & 6 & 6 & 6 & 6 &  \\ \hline
& 5 & 5 & 5 & 5 & 5 &  & 5 & 6 & 6 & 6 & 6 &  \\ \hline
\end{tabular}

• You should read the booktabs manual for some advice on laying out professional quality tables. Or see LaRiFaRi's answer below. – cfr Mar 10 '15 at 0:28

You can put several tabulars in one table. For the line break just insert a blank line.

% arara: pdflatex

\documentclass{article}
\usepackage{booktabs}
\usepackage{caption}

\begin{document}
\begin{table}
\caption{6 tables}
\centering
\begin{tabular}{*{5}{l}}
\toprule
1.1 & \multicolumn{4}{l}{merged cell}\\\midrule
2.1 & 2.2 & 2.3 & 2.4 & 2.5\\
3.1 & 3.2 & 3.3 & 3.4 & 3.5\\
4.1 & 4.2 & 4.3 & 4.4 & 4.5\\
5.1 & 5.2 & 5.3 & 5.4 & 5.5\\
\bottomrule
\end{tabular}\hfil % you can also leave this away, try \hfill or \hspace{'some length'em}
\begin{tabular}{*{5}{l}}
\toprule
1.1 & \multicolumn{4}{l}{merged cell}\\\midrule
2.1 & 2.2 & 2.3 & 2.4 & 2.5\\
3.1 & 3.2 & 3.3 & 3.4 & 3.5\\
4.1 & 4.2 & 4.3 & 4.4 & 4.5\\
5.1 & 5.2 & 5.3 & 5.4 & 5.5\\
\bottomrule
\end{tabular}\vspace{2ex} % optional

\begin{tabular}{*{5}{l}}
\toprule
1.1 & \multicolumn{4}{l}{merged cell}\\\midrule
2.1 & 2.2 & 2.3 & 2.4 & 2.5\\
3.1 & 3.2 & 3.3 & 3.4 & 3.5\\
4.1 & 4.2 & 4.3 & 4.4 & 4.5\\
5.1 & 5.2 & 5.3 & 5.4 & 5.5\\
\bottomrule
\end{tabular}\hfil
\begin{tabular}{*{5}{l}}
\toprule
1.1 & \multicolumn{4}{l}{merged cell}\\\midrule
2.1 & 2.2 & 2.3 & 2.4 & 2.5\\
3.1 & 3.2 & 3.3 & 3.4 & 3.5\\
4.1 & 4.2 & 4.3 & 4.4 & 4.5\\
5.1 & 5.2 & 5.3 & 5.4 & 5.5\\
\bottomrule
\end{tabular}\vspace{2ex}

\begin{tabular}{*{5}{l}}
\toprule
1.1 & \multicolumn{4}{l}{merged cell}\\\midrule
2.1 & 2.2 & 2.3 & 2.4 & 2.5\\
3.1 & 3.2 & 3.3 & 3.4 & 3.5\\
4.1 & 4.2 & 4.3 & 4.4 & 4.5\\
5.1 & 5.2 & 5.3 & 5.4 & 5.5\\
\bottomrule
\end{tabular}\hfil
\begin{tabular}{*{5}{l}}
\toprule
1.1 & \multicolumn{4}{l}{merged cell}\\\midrule
2.1 & 2.2 & 2.3 & 2.4 & 2.5\\
3.1 & 3.2 & 3.3 & 3.4 & 3.5\\
4.1 & 4.2 & 4.3 & 4.4 & 4.5\\
5.1 & 5.2 & 5.3 & 5.4 & 5.5\\
\bottomrule
\end{tabular}
\end{table}
\end{document}


If you need captions for each tabular, please have a look on the package subcaption. You will have to wrap every tabular in a subfigure-environment then.

Like this?

\documentclass{article}
\newcommand{\mc}[2]{\multicolumn{#1}{|c|}{#2}}
\begin{document}
\begin{tabular}{ |*{11}{l|}}
\cline{1-5}\cline{7-11}
node's id & \mc{4}{node's list}
\\ \cline{1-5}\cline{7-11}
1 & 1 & 1 & 1 & 1 & & 1 & 2 & 2 & 2 & 2 \\ \cline{1-5}\cline{7-11}
2 & 1 & 1 & 1 & 1 & & 3 & 2 & 2 & 2 & 2 \\ \cline{1-5}\cline{7-11}
3 & 1 & 1 & 1 & 1 & & 4 & 2 & 2 & 2 & 2 \\ \cline{1-5}\cline{7-11}
4 & 1 & 1 & 1 & 1 & & 5 & 2 & 2 & 2 & 2 \\ \cline{1-5}\cline{7-11}
5 & 1 & 1 & 1 & 1 & &   &   &   &   &      \\ \cline{1-5}\cline{7-11}
\multicolumn{11}{l}{}      \\ \cline{1-5}\cline{7-11}
node's id & \mc{4}{node's list}  &   & node's id & \mc{4}{node's list}
\\ \cline{1-5}\cline{7-11}
2 & 3 & 3 & 3 & 3 & &  1 & 4 & 4 & 4 & 4  \\ \cline{1-5}\cline{7-11}
3 & 3 & 3 & 3 & 3 & &  2 & 4 & 4 & 4 & 4  \\ \cline{1-5}\cline{7-11}
4 & 3 & 3 & 3 & 3 & &  3 & 4 & 4 & 4 & 4  \\ \cline{1-5}\cline{7-11}
5 & 3 & 3 & 3 & 3 & &  5 & 4 & 4 & 4 & 4  \\ \cline{1-5}\cline{7-11}
\multicolumn{11}{l}{}      \\ \cline{1-5}\cline{7-11}
node's id & \mc{4}{node's list}  &   & node's id & \mc{4}{node's list}
\\ \cline{1-5}\cline{7-11}
1 & 5 & 5 & 5 & 5 & &   1 & 6 & 6 & 6 & 6   \\ \cline{1-5}\cline{7-11}
3 & 5 & 5 & 5 & 5 & &   3 & 6 & 6 & 6 & 6   \\ \cline{1-5}\cline{7-11}
4 & 5 & 5 & 5 & 5 & &   4 & 6 & 6 & 6 & 6   \\ \cline{1-5}\cline{7-11}
5 & 5 & 5 & 5 & 5 & &   5 & 6 & 6 & 6 & 6   \\ \cline{1-5}\cline{7-11}
\end{tabular}
\end{document}


• thanks but i am looking for 6 tables in 2 columns and each table with 5 columns and 5 rows. Also, in the first row of each table, I need to merge the last 4 cells. So that when you see it seems like 6 distinctive 5*5 tables. – user2312186 Mar 9 '15 at 9:23
• @user2312186 Can you put a picture of what you mean? – user11232 Mar 9 '15 at 13:28
• @user2312186 See the update. Is that what you want? – user11232 Mar 10 '15 at 0:24