I need to toggle on/off full rows of a tabular via changing my preamble. My workflow only permits me to alter the first cell of each table in order to make it toggleable.
My idea was to use the accepted answer to this post \def taking rest of the line as argument and define a command \rowswitch
that either swallows the whole row or displays it normally:
\documentclass{article}
\begin{document}
\newcommand*{\newlinecommand}[2]{%
\newcommand*{#1}{%
\begingroup%
\escapechar=`\\%
\catcode\endlinechar=\active%
\csname\string#1\endcsname%
}%
\begingroup%
\escapechar=`\\%
\lccode`\~=\endlinechar%
\lowercase{%
\expandafter\endgroup
\expandafter\def\csname\string#1\endcsname##1~%
}{\endgroup#2\space}%
}
%toggles:
\newlinecommand{\rowswitch}{#1} %on
%\newlinecommand{\rowswitch}{} %off
\begin{tabular}{cc}
normal & row\\
\rowswitch toggle & row\\
normal & row
\end{tabular}
\end{document}
Unfortunately I keep receiving Forbidden control sequence found while scanning use of \\rowswitch
is there anything I can do about this or is this doomed to fail?