I've got a workaround for this problem, but maybe someone knows a cleaner way to fix it. I'm using the standard packages in TexLive 2009.
Here's the code that doesn't work:
\documentclass{article}
\usepackage{ifthen}
\newboolean{test}
\setboolean{test}{false}
\newcommand{\testval}{\ifthenelse{\boolean{test}}{yes}{no}}
\begin{document}
\begin{tabular}{ll}
Should be no & \testval \\
Change value & \setboolean{test}{true} \\
Shoule be yes & \testval \\
\end{tabular}
\end{document}
I haven't seen any mention of this behavior in the ifthen package description. I've also noticed that, for instance, you can't use \newcommand and \isundefined to work around this.
My workaround so far is to use a counter, and then test \value{counter}=0. The only difficulty was that there's no \providecounter the way there is with booleans or commands, so I wrote providecounter.sty:
\NeedsTeXFormat{LaTeX2e}[1994/12/01]
\ProvidesPackage{providecounter}
[2010/11/16 my hack to implement a providecounter command]
\def\providecounter#1{\@ifundefined{c@#1}{\newcounter{#1}}\relax}
So, two questions: a. why do \setboolean and \newcommand not work inside a tabular environment, and b. do counters more or less not care where they are defined?
\newcommand{\testval}), and if the backslash is added, your code works for me (it yields "no" in the first and "yes" in the second table row). – lockstep Nov 16 '10 at 20:33