How to merge two tabulars into a single table the width of the column?

Here's one option using tabularx:

\documentclass{book}
\usepackage{tabularx}

\newcolumntype{C}{>{\centering\arraybackslash}X}

\begin{document}

\begin{table}
\small
\centering
\begin{tabularx}{.7\linewidth}{|X|C|X|C|}
\hline
    parameter & value & parameter & value \\
\hline
    blah blah & a & blah blah & 2 \\
    blah blah & 4 & blah blah   & 17 \\             
    blah blah & 4 & blah blah & 4 \\
    blah blah & 4 & blah blah & 128  \\
    blah blah & 1 & blah blah &  6 \\
    blah blah & 8 & blah blah & 48 \\
    blah blah & 48 & blah blah & 32 \\ 
    blah blah & 10 & blah blah & 16 \\
\hline
\end{tabularx}\par\vskip-1.4pt
\begin{tabularx}{.7\linewidth}{*{6}{|X}|}
\hline
        blah & bloo & bleeblee & bloo bloo & meeh & hoohaa  \\ \hline
        xyz & 3ubfjdf & 14 & 64 & 4 & 444 \\ 
        abc & fddf4 & 44 & 64 & 8 & 555 \\ 
        mno & dsf4tv & 100 & 64 & 8 & 777 \\
\hline
\end{tabularx}
\caption{My merged table}
\end{table}

\end{document}

enter image description here


You can simply use the standard command multicolumn to achieve this. Then you choose which of the columns of the top tables should span more than one column of the lower table. Then do this in each row of the top table.

\begin{tabular}{|l|l|l|l|l|l|}
\hline
 \multicolumn{2}{|l|}{  parameter } & value & \multicolumn{2}{l|}{  parameter } & value \\
\hline
 \multicolumn{2}{|l|}{ blah blah }&  a & \multicolumn{2}{l|}{ blah blah } &  2 \\
 \multicolumn{2}{|l|}{ blah blah }&  4 & \multicolumn{2}{l|}{ blah blah } &  17 \\             
 \multicolumn{2}{|l|}{ blah blah }&  4 & \multicolumn{2}{l|}{ blah blah } &  4 \\
 \multicolumn{2}{|l|}{ blah blah }&  4 & \multicolumn{2}{l|}{ blah blah } &  128  \\
 \multicolumn{2}{|l|}{ blah blah }&  1 & \multicolumn{2}{l|}{ blah blah } &   6 \\
 \multicolumn{2}{|l|}{ blah blah }&  8 & \multicolumn{2}{l|}{ blah blah } &  48 \\
 \multicolumn{2}{|l|}{ blah blah }& 48 & \multicolumn{2}{l|}{ blah blah } &  32 \\ 
 \multicolumn{2}{|l|}{ blah blah }& 10 & \multicolumn{2}{l|}{ blah blah } &  16 \\
\hline
    blah & bloo & bleeblee & bloo bloo & meeh & hoohaa  \\ \hline
    xyz & 3ubfjdf & 14 & 64 & 4 & 444 \\ 
    abc & fddf4 & 44 & 64 & 8 & 555 \\ 
    mno & dsf4tv & 100 & 64 & 8 & 777 \\
\hline
\end{tabular}
\caption{My merged table}
\end{table}

It looks like: enter image description here

The advantages of this approach is that

  • it uses standard commands
  • it's versatile, you can easily use other columns and combine more than two tabulars.
  • it doesn't rely on spacings and other values that could change

The disadvantage is of course it must be done manually. Which can be bothersome. But this is unfortunately quite often the case for tables in LaTeX. (But when it is complicated to produce them it will also be complicated to read them. This can be a hint, that you should think of another way to show your data.)

I hope this answers your question.


A first trial without equal widths, but I am not sure whether I understand the request correctly... ;-)

\documentclass{book}

\begin{document}

\begin{table}[ht]
\small
\centering

\begin{tabular}{l|l|c|l|c|l}
\cline{2-5} 
&    parameter & value & parameter & value \\
\cline{2-5} 
 &   blah blah & a & blah blah & 2 \\
 &   blah blah & 4 & blah blah   & 17 \\             
 &   blah blah & 4 & blah blah & 4 \\
 &   blah blah & 4 & blah blah & 128  \\
 &   blah blah & 1 & blah blah &  6 \\
 &   blah blah & 8 & blah blah & 48 \\
 &   blah blah & 48 & blah blah & 32 \\ 
 &   blah blah & 10 & blah blah & 16 \\
\hline
\multicolumn{1}{|l|}{        blah} & bloo & bleeblee & bloo bloo & meeh & \multicolumn{1}{|l|}{hoohaa}  \\ \hline
\multicolumn{1}{|l|}{        xyz} & 3ubfjdf & 14 & 64 & 4 & \multicolumn{1}{|l|}{444} \\ 
\multicolumn{1}{|l|}{        abc} & fddf4 & 44 & 64 & 8 & \multicolumn{1}{|l|}{555} \\ 
\multicolumn{1}{|l|}{        mno} & dsf4tv & 100 & 64 & 8 & \multicolumn{1}{|l|}{777} \\
\hline
\end{tabular}
\caption{My merged table}
\end{table}

\end{document}

enter image description here