I am trying to use \if within a tabularx environment. This works:
\documentclass{scrlttr2}
\usepackage{tabularx}
\begin{document}
\newcounter{x}
\setcounter{x}{0}
\begin{tabularx}{\linewidth}{c|l}
\stepcounter{x}
\ifnum\value{x}=20
it is 20
\else
it is not
\fi
\\
\end{tabularx}
\end{document}
But of course has no columns. When I try to add them like this:
\documentclass{scrlttr2}
\usepackage{tabularx}
\begin{document}
\newcounter{x}
\setcounter{x}{0}
\begin{tabularx}{\linewidth}{c|l}
\stepcounter{x}
\ifnum\value{x}=20
it is & 20
\else
it is & not
\fi
\\
\end{tabularx}
\end{document}
I get this error:
Incomplete \ifnum; all text was ignored after line 18. \end{tabularx}


it is & \ifnum\value{x}=20\relax 20\else not\fi\\? – Jagath Jun 27 '16 at 15:21\TestX{20}{20}{not}. Where\def\TestX#1#2#3{\ifnum\value{x}=#1\relax #2\else #3\fi}. – Jagath Jun 27 '16 at 15:24