# Trying to get a full width table but with varying columns

I am trying to get a table with 3 parts to come out evenly, using tabular or tabularx, but I come out with 3 tables of different widths stacked on top of each other.

\begin{table}
\begin{tabular*}{\linewidth}[b]{lcr}
1 - 50 & \bf{The Balanced Table Header} & Sides: 44 - 1365 \\
\end{tabular*}
\begin{tabular*}{\linewidth}[b]{|c|c|c|c|c|c|}
100 & 101 & 10000000001 & 2000000002 & 3000000003 & 400000000004 \\
\end{tabular*}
\begin{tabular*}{\linewidth}[b]{lr}
BeEF - 20:7:7:16 & 20:7:7:16 - Total
\end{tabular*}
\end{table}


This is NOT what is needed, I want the table to expand to the largest width, but have the first row evenly spaced with 3 items, the second row with 6 items, and the third row with one item to the left and one item on the right.

I must NOT have any of the columns on one line smashing or enlarging the column widths on any other row, each row must not affect the rows above or below. Of course I would like to have the middle of the table with a set of identical rows.

The easiest way to me, would be to simply redefine the column layout on the fly inside the table, but I have not found a way to do this.

Any ideas how to get a table with full widths for all rows?

• PS: Using \linewidth inside the width specifier of tabularx only affects that table, and that value does NOT get passed to the other two tabular environments so that all 3 know the maximum width and adjust accordingly. In the past I had to pre-read all the data, to figure out the maximum width, then set a variable and force it into all 3, I am hoping to avoid this again. – logical Apr 22 '17 at 1:30
• Welcome! Please edit your question to provide code for a complete minimal document we can compile to reproduce the problem. – cfr Apr 22 '17 at 1:33
• You possibly need tabularx but you must use the X column specifier. However, I'm not really sure I understand what you are trying to do. – cfr Apr 22 '17 at 1:37
• \bf is a deprecated command but if you do use it, it does not take an argument so \bf xxxx not \bf{xxx} but just use \bfseries xxx – David Carlisle Apr 22 '17 at 8:48
• the difference between tabularx and tabular* is that one stretches the column widths and one stretches inter-column space, but you have allowed stretching of neither. You have to use X columns in tabularx and you have to use \extracolumnsep in tabular* – David Carlisle Apr 22 '17 at 8:50

Although hardly to be recommended, it sounds as if you want something which looks roughly like this:

Pretty ugly, I think, but seems to fulfil the desiderata.

\documentclass{article}
\usepackage{array,tabularx}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\newcolumntype{R}{>{\raggedleft\arraybackslash}X}
\begin{document}
\begin{table}
\begin{tabularx}{\linewidth}{>{\hsize=.75\hsize}L>{\hsize=1.5\hsize}C>{\hsize=.75\hsize}R}
1 - 50 & \textbf{The Balanced Table Header} & Sides: 44 - 1365
\end{tabularx}
\begin{tabularx}{\linewidth}{|l|c|*{3}{C|}R|}
100 & 101 & 10000000001 & 2000000002 & 3000000003 & 400000000004
\end{tabularx}
\begin{tabularx}{\linewidth}{LR}
BeEF - 20:7:7:16 & 20:7:7:16 - Total
\end{tabularx}
\end{table}
\end{document}


Please consider reading the booktabs manual and following its advice. In particular, note that vertical rules are rarely a wise choice.

• After more experimenting, I found out that I have to pass in a global variable into the tabular environment to properly space the top line. I have something which works now. Thanks for your reply – logical Apr 22 '17 at 6:54