I am trying to create a TextField whose value is conditional on a boolean. If the boolean is true, the default value in the TextField is some value; if it is false, the TextField starts blank (the value is empty).
Here's my attempt:
\documentclass{article}
\usepackage{hyperref}
\usepackage{ifthen}
\newboolean{withcorrect}
\setboolean{withcorrect}{false}
\newcommand{\correctAnsBlankPlain}[1]{%
\ifthenelse{\boolean{withcorrect}}{%
#1%
}{}%
}
\begin{document}
\correctAnsBlankPlain{5.0}
\TextField[name=H%
,value=\correctAnsBlankPlain{5.0}%
]{}
\end{document}
which yields the error "./exam.tex:21: Argument of \boolean has an extra }."
I know the \correctAnsBlankPlain
command works, because when I comment out the line containing the value, it compiles fine. I can also make the withcorrect
boolean true
and see the 5.0 printed as expected before the TextField.
So, I assume that I'm doing something wrong by including a command within the optional argument of TextField, but I'm not sure 1) what or 2) how to best get around it.