This is the suggested fresh question by the comment by @egreg in the answer to the question Align Equations Over Multiple Tabular Rows
So the starting point is following code:
\documentclass{article}
\usepackage{booktabs,array}
\newcolumntype{A}{
>{$}r<{$}
@{\extracolsep{0pt}}
>{${}} l <{$}
@{\extracolsep{\fill}}
} % A for "align"
%% (1) "r" column in math mode: >{$} r <{$}
%% (2) no space: @{}
%% (3) "l" column in math mode, with
%% an empty subformula at the start: >{${}} l <{$}
\begin{document}
\noindent
\begin{tabular*}{\textwidth}{
@{\hspace{\tabcolsep}\extracolsep{\fill}}
AAA
@{\hspace{\tabcolsep}}
}
\toprule
\multicolumn{4}{l}{Header 1} \\
\midrule
a &= \sum_j b(c) & c &= d & aaa &= bbb\\
\midrule
\multicolumn{4}{l}{Header 2} \\
\midrule
e &= fghij(y) & qr &= vwxyzstu & a &= b\\
klm(x) &= nop & abcde &< fghij & x &= 0\\
\bottomrule
\end{tabular*}
\end{document}
Current features are:
- width of the table is given by the user
- columns in math mode which are aligned
How can I add columns which are not in math mode but are handled by tabular* or tabularx to distribute remaining whitespace between the columns evenly?
Update the columntypes are: AccAAl
With the help of the comment of David Carlisle I could get a running version:
\documentclass{article}
\usepackage{booktabs,array}
\newcolumntype{A}{ >{$}r<{$} @{\extracolsep{0pt}} >{${}} l <{$} @{\extracolsep{\fill}} }
\usepackage{blindtext}
\begin{document}
\blindtext
\begin{tabular*}{\textwidth}{
@{\hspace{\tabcolsep}\extracolsep{\fill}}
A
@{\hspace{\tabcolsep}}
@{\extracolsep{\fill}}c
@{\extracolsep{\fill}}c
@{\hspace{\tabcolsep}\extracolsep{\fill}}
AA
@{\hspace{\tabcolsep}}
@{\extracolsep{\fill}}l
}
\toprule
\multicolumn{2}{l}{title 1} & title 2 (c) & title 3 (c) & \multicolumn{2}{c}{title 4} & \multicolumn{2}{c}{title 5} & title 6 (l) \\
\midrule
a &= b & cell 2 & cell 3 & c&=d & e&=f & cell6 \\
a+2 &= b & cell 2 & cell 3 & c+3&=d & e+4&=f & cell6 \\
\bottomrule
\end{tabular*}
\blindtext
\end{document}
QUESTION How to properly align column headers which are obviously text and not equations. I tried this naively. However, it is most obvious in column 1, that it is not correct!


c(or perhaps `@{\extracolsep{\fill}}c' )for your extra column? – David Carlisle Mar 21 '17 at 15:47