I want to create a longtabu table with a conditional number of columns: In development mode, 5 columns should be visiable. In the final version, only the first and the last column should be visible.
To achieve this, I defined a new column type "H" which is suppressed in the output (with a little help from Easiest way to delete a column? ). Hiding columns with this column type works fine.
The problem is: I can't switch conditionally between the "H" column and the "X" column. I want to use a different column definition in my longtabu table, but it doesn't work (error: "Misplaced alignment tab character").
How to make it work?
\documentclass[]{scrreprt}
\usepackage{tabu, longtable}
% Create hidden column, see: https://tex.stackexchange.com/q/16604/
\usepackage{collcell}
\makeatletter
\newcolumntype{H}{>{\collectcell\@gobble}c<{\endcollectcell}@{}}
\makeatother
\tabucolumn H
% If defined, only show first and last column
%\def\MyOnlyShowFinalTable{\relax}
\begin{document}
\ifdefined\MyOnlyShowFinalTable
\begin{longtabu} to \textwidth { X[2.0,m,m] | H | H | H | X[7.0,m,m] }
\else
\begin{longtabu} to \textwidth { X[1.3,m,m] | X[0.8,m,m] | X[0.8,m,m] | X[0.8,m,m] | X[5.0,m,m] }
\fi
A & B & C & D & E\\
A & B & C & D & E\\
A & B & C & D & E\\
A & B & C & D & E\\
\end{longtabu}
\end{document}
Some additional information: I found out, that there is some workaround when using "c" columns instead of "X" columns:
\documentclass[]{scrreprt}
\usepackage{tabu, longtable}
% If defined, only show first and last column
%\def\MyOnlyShowFinalTable{\relax}
\ifdefined\MyOnlyShowFinalTable
% Create hidden column, see: https://tex.stackexchange.com/q/16604/
\usepackage{collcell}
\makeatletter
\newcolumntype{H}{>{\collectcell\@gobble}c<{\endcollectcell}@{}}
\makeatother
\else
\newcolumntype H{c |}
\fi
\tabucolumn H
%\newcolumntype Y{c |}
%
%\tabucolumn Y
\begin{document}
\begin{longtabu} to \textwidth { X[1.3,m,m] | H H H X[5.0,m,m] }
A & B & C & D & E\\
A & B & C & D & E\\
A & B & C & D & E\\
A & B & C & D & E\\
\end{longtabu}
\end{document}
However, this is still not quite what I want, as it doesn't let me specify the different column ratios, and it forces me to use "c" columns.
However, I wonder why this doesn't work with "X" columns?

I slightly modfied your example so that I can use a globel switch for all tables, and it works perfectly now!
– arngineer Sep 11 '13 at 14:53