BEGIN_TEXT To find the area under the curve \( y=x^2 \) for \(2 \le x \le 3 \), we can calculate \( \int_\{ans_rule(20)\}^\{ans_rule(20)\} \{ans_rule(20)\} dx \) END_TEXT ANS(num_cmp(2)); ANS(num_cmp(3)); ANS(fun_cmp("x^2"));
I'd like to provide answer blanks within mathematical displays. For example, is something like the following possible?
Because mathematics is usually displayed as an image, it is not possible to put answer rules within the mathematics in a way that would work in all viewing modes. (If you wanted to force your students to use jsMath mode it could be done, but there is no current mechanism for it.)
To do this sort of thing properly you need to use a table. I have attached a problem file that does this. The key section is the following:
if ($displayMode eq 'TeX') { $integral = '\[\int_{'.ans_rule(4).'}^{'.ans_rule(4).'}'. ans_rule(35).'\,dx\]'; } else { $integral = $PAR. $BCENTER. BeginTable(). Row(['\(\displaystyle \int\)', ans_rule(4).$BR.$BR.ans_rule(4), ans_rule(35), '\(dx\).'],separation=>2). EndTable(). $ECENTER; }which uses the Union library's table macros to set up an integral with answer rules like you suggest. When hardcopy is requested ('TeX' mode), the layout is done without the table so that it formats a bit better.
Later, when you do the output of the problem, you simply use the variable $integral where you want this integral to appear.
Hope that helps.
Davide