# Multicolumn wider than subcolumn

I'm dealing with an aesthetic issue related to a multicolumn in a table.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{multirow}
\usepackage{multicol}
\usepackage{booktabs}

\begin{document}

\begin{table}
\centering
\caption{Large Width Table}\label{ch1tab:rev}
%\renewcommand{\arraystretch}{1.3}

\begin{tabular}{|c|c|}
\toprule
\multicolumn{2}{c}{\textbf{RandomTextRandomText}} \\ %\cline{3-4}
$t_1$                     & $t_1$     \\\midrule
1&1\\
1&1\\
1&1 \\ \bottomrule
\multicolumn{2}{c}{Lorem ipsum dolor sit amet, consectetur adipiscing elit}
\end{tabular}
\end{table}

\end{document}


The problem is that the width of the multicolumn (in this case of the whole table) is larger than the sum of the subcolumn and thus all the excessive width is put in the last subcolum.

From some answers it seems that I should force the width of the subcolumn to be greater than the one of the multicolumn. Is there a more elegant and automatic solution?

Thank you

• welcome to tex.se! one way is measure width of multicolumn content and than divide it between columns with prescribed width. another way is allow to break content in multicolum cell to be break into more lines with prescribed widths of columns as well of multicolumn cell. – Zarko May 14 at 17:08
• – leandriis May 14 at 17:49

\documentclass{article}
\usepackage{array}
\usepackage{booktabs}
\newsavebox\TBox
\begin{document}

\begin{table}
\sbox\TBox{Lorem ipsum dolor sit amet, consectetur adipiscing elit}
\centering
\caption{Large Width Table}\label{ch1tab:rev}
\begin{tabular}{|>{\centering}p{0.5\wd\TBox}|c|}\toprule
\multicolumn{2}{c}{\bfseries RandomTextRandomText} \\ %\cline{3-4}
$t_1$                     & $t_1$     \\\midrule
1&1\\
1&1\\
1&1 \\ \bottomrule
\multicolumn{2}{c}{Lorem ipsum dolor sit amet, consectetur adipiscing elit}\\
\end{tabular}
\end{table}

\end{document}


• why you measure some text not contained in table? your answer is not very consistent. read my comment below question ... – Zarko May 14 at 17:59
• The Lorem ipsum ... is the last row in OP's table and wider than the Random Text Random Text. – Henk Metselaar May 15 at 7:27

Let convert my comment to the answer:

\documentclass{article}
\usepackage{array}
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
\newsavebox\TB  % Table Box
\newlength\wdTB % width of TB

\usepackage{lipsum}
\begin{document}
\lipsum[11]
\begin{table}[htb]
\sbox{\TB}{\textbf{Random Text Random Text}}
\setlength{\wdTB}{\wd\TB}
\centering
\caption{Large Width Table}
\label{ch1tab:rev}
\begin{tabular}{|*{2}{>{\centering\arraybackslash}p{0.5\wdTB}|}}
\hline
\multicolumn{2}{|c|}{\usebox{\TB}}  \\
\hline
$t_1$   &   $t_1$   \\
\hline
1       &   1       \\
1       &   1       \\
1       &   1       \\
\hline
\multicolumn{2}{p{\wdTB}}{Is this some comment to table contents?}
\end{tabular}
\end{table}
\lipsum[12]
\begin{table}[htb]
\centering
\caption{Large Width Table}
\label{ch1tab:rev}
\begin{tabular}{|*{2}{C{15mm}|}}
\hline
\multicolumn{2}{|C{\dimexpr15mm+15mm+2\tabcolsep}|}{\textbf{Random Text Random Text}}  \\
\hline
$t_1$   &   $t_1$   \\
\hline
1       &   1       \\
1       &   1       \\
1       &   1       \\
\hline
\multicolumn{2}{p{\dimexpr30mm+2\tabcolsep}}{Is this some comment to table contents?}
\end{tabular}
\end{table}
\end{document}


first table use measurement of multicolumn cell, the second break content of this cell that it is not wider than sum of the spanned columns: