5

Is it possible to show or hide rows of a table by setting a global boolean variable?

\documentclass{minimal}

% some boolean variable X

\begin{document}

\begin{tabular}{ccc}
A & B & C \\
A & B & C \\
A & B & C \\ %show this row iff X is true
A & B & C \\
A & B & C \\ % show this row iff X is true
\end{tabular}

\end{document}
Moriambar
  • 11,466
student
  • 29,003

1 Answers1

6

etoolbox provides an easy syntax for this: \ifbool{FLAG}{IF-TRUE}{IF-FALSE}:

\documentclass{minimal}
\usepackage{etoolbox}

\newbool{extrarows}
\booltrue{extrarows}

\begin{document}

\begin{tabular}{ccc}
A & B & C \\
A & B & C \\
\ifbool{extrarows}{D & E & F \\}{}
A & B & C \\
\ifbool{extrarows}{D & E & F \\}{}
\end{tabular}

\end{document}
Moriambar
  • 11,466
Chel
  • 6,110