## LaTeX forum ⇒ General ⇒ Problem using conditionals inside tabular & changing columns

LaTeX specific issues not fitting into one of the other forums of this category.
EmilioLazo
Posts: 15
Joined: Sat Jul 16, 2011 1:59 am

### Problem using conditionals inside tabular & changing columns

Hello!

I wrote this code to expose the issue I'm facing:

\documentclass[test]{article} \makeatletter  \DeclareOption{test}{\@testtrue}  \ProcessOptions  \newcommand{\Item}{\if@test t&t&t&t \else 21&22&23&24 \fi}\makeatother \begin{document}\begin{tabular}{cccc}11 & 12 & 13 & 14 \\\Item\end{tabular}\end{document}

I would expect that if option 'test' is supplied to the class, a row with one 't' in every cell will be written, and nothing more; but it isn't the case, the 'else' condition is also evaluated. (?)

The errors were:
! Incomplete \iftrue; all text was ignored after line 12.
! Extra alignment tab has been changed to \cr
! Extra \fi.
! Missing \cr inserted.
...

The problem here is the presence of '&' inside \if conditional, but with ifthen or etoolbox the issue disappears:


What is happening here? How this can be fixed using \if@test-construct? I did try inserting braces for both 'then' and 'else', and the whole \if inside braces but nothing changes!

Thanks.