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}
3
  • I don't think this is a dupe: the proposed question is about columns, while there it's rows that are important. The approaches needed are very different.
    – Joseph Wright
    Dec 9, 2011 at 10:13
  • @JosephWright If there is a similar question about columns, could you provide the link to it?
    – student
    Dec 9, 2011 at 10:18
  • 1

1 Answer 1

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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.