I would like to toggle on/off complete rows of a longtabu or longtable table. The following post:
hide/show complete row of tabular
provides elegant working solutions (which I presume are roughly identical) for a tabular environment table.
Unfortunately, when used with a longtabu or longtable table or, indeed, even just the tabu table environment, I get the following error:
ERROR: Paragraph ended before \rowswitch was complete.
--- TeX said ---
<to be read again>
\par
l.208 \end{longtabu}
--- HELP ---
A blank line occurred in a command argument that shouldn't contain
one. You probably forgot the right brace at the end of an argument.
My table is very long, so I would seem to need to use either the longtabu or longtable environments.
I'm using the memoir class, but I seem to get the same error with the article class.
The following is a MWE (using the Carlisle solution) that does not work in just the above way.
\documentclass[a4paper,landscape,10pt,oneside,english]{memoir}
% memoir set margins
\setlrmarginsandblock{1.5cm}{1.5cm}{*} % left-right
\setulmarginsandblock{2.5cm}{1.5cm}{*} % upper-lower
\checkandfixthelayout
\usepackage{comment}
\usepackage{lipsum}
\usepackage{longtable,tabu}
\usepackage{rotating}
\usepackage{blindtext}
%% toggle switches to hide/unhide rows of table:
% \def\rowswitch#1\\{#1\\} %On = Unhide
\def\rowswitch#1\\{} %Off = Hide
\begin{document}
\begin{longtabu} to\textwidth{
| X[2,l]
| X[2,l]
| X[15,l]
| X[15,l]
| X[2,l]
| }
\hline \hline
\textbf{Ref} &
\textbf{Ref} &
\textbf{Summary} &
\textbf{Summary} &
\textbf{Ref}
\\ \hline \hline \hline \hline
&
&
\blindtext
&
&
\\ \hline
\rowswitch
&
Hidden row
&
Hidden row
\blindtext
&
Hidden row
&
\\ \hline
&
&
\blindtext
&
&
\\ \hline
\end{longtabu}
\end{document}
For longtable, one can substitute:
\begin{longtable}{
| p{1cm}
| p{1cm}
| p{10cm}
| p{10cm}
| p{1cm}
| }
and
\end{longtable}
to get the same error.
\rowswitch
by\long\def
)\long\def\rowswitch#1\\{}
etc works much better and remains very elegant.