Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
    
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 '11 at 10:13
    
@JosephWright If there is a similar question about columns, could you provide the link to it? –  student Dec 9 '11 at 10:18
1  
add comment

1 Answer

up vote 6 down vote accepted

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}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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