I place the same table multiple times in my main document. For that, the content of the table is placed in a file called model-values.tex. On every \input, I alter the part of the table to be displayed by hiding columns with a \newcolumntype. I use this solution because I work with a huge Gnumeric table (TeX exporting) and I don’t want to split it only for formatting reasons.
Hiding does not work anymore if I have \multicolumns in the table. The text of these is still displayed, no matter if the columns are hidden. I have already tried different solutions for the H type column (see TeX SE link in the comments) but the problem persists.
One solution: take the header out of the file and put it into the several occurences of the table. However, if I add or drop columns in model-values.tex then, the whole head of the table needs to be changed. This is 2 more rows to be changed vs. only 1 'row' (= column definition) when the header is included in the external file.
Is it worth it or should I stuck with changing-the-whole-head solution? I think the problem is because of the column type c in the \multicolumn. It should 'inherit' the table’s one or something.
\documentclass{scrartcl}
\usepackage{booktabs}
\usepackage{tabularx}
% Hidden column type - different solutions on http://tex.stackexchange.com/questions/16604/easiest-way-to-delete-a-column
\newcolumntype{H}{>{\setbox0=\hbox\bgroup}c<{\egroup}@{}}
\begin{filecontents}{model-values.tex}
% Header
Model
& Param a
& \multicolumn{3}{c}{Param set A}
& \multicolumn{2}{c}{Param set B}
\\\cmidrule{3-5}\cmidrule{6-7}
&
& Param A1
& Param A2
& Param A3
& Param B1
& Param B2
\\\midrule
% Data
1 & 5 & 6 & 9 & 11 & 2 & 4\\
\end{filecontents}
\begin{document}
\section{Comparison of param set A}
Here, param set A of all models are compared, refer the table.
\begin{table}[t]
\begin{tabular}{
l % Model
c % Param a
c % Param set A: A1
c % Param set A: A2
c % Param set A: A3
H % Param set B: B1
H % Param set B: B2
}
\toprule
\input{model-values.tex}
\bottomrule
\end{tabular}
\end{table}
\clearpage
\section{Comparison of param set B}
Here, param set B of all models are compared, refer the table.
\begin{table}[t]
\begin{tabular}{
l % Model
c % Param a
H % Param set A: A1
H % Param set A: A2
H % Param set A: A3
c % Param set B: B1
c % Param set B: B2
}
\toprule
\input{model-values.tex}
\bottomrule
\end{tabular}
\end{table}
\end{document}