WeBWorK Problems

formatted answer blank in a tex fraction

formatted answer blank in a tex fraction

by John Travis -
Number of replies: 3
I am currently struggling with creating easy-to-understand and simple pre-algebra problems and currently want to have the student complete a ratio expression of the form:

a/b = c/d

where c is the answer blank.  Of course if the formatting is as above then things are easy.  Instead, I'd like to use \frac{ ans_rule(2) }{$d} for the right hand side.

I know I can use multianswer.pl but that seems to be overkill.  Is there some quick way to embed a single answer blank into a tex formatted question using MathJax?  I've tried tex_ans_rule and this gives

http://math.mc.edu/webwork2/PreAlgebra/C06-S02-Proportions/3/

Thanks,

JT
In reply to John Travis

Re: formatted answer blank in a tex fraction

by Arnold Pizer -
Hi John,

Not sure about MathJax but this won't work in images mode.  Do you want to write a problem that is mode dependent?

Arnie
In reply to Arnold Pizer

Re: formatted answer blank in a tex fraction

by John Travis -
No.  But wanted to find some way to make the problem simpler to read and answer.  Trying to avoid the "here's the question, now put the answer there" approach.

However I think the following using ColumnTable does the trick...stolen from the parserMultianswer.pl examples...

$exp = ColumnTable(
  "\( \displaystyle \frac{$a}{$b} = \)",ans_rule(2).$BR.$HR.$d,
  indent => 0, separation => 10, valign => "MIDDLE"
  );

I'd like to make the formatting of $d fit the rest of the stuff but this is the general idea.

JT
In reply to John Travis

Re: formatted answer blank in a tex fraction

by Davide Cervone -
This gives a somewhat more pleasing layout, and should work better in hardcopy mode.
    loadMacros("unionTables.pl");
    
    $LINE = MODES(
      TeX  => '\hrulefill ',
      HTML => '<hr size="1" style="border-style: solid; margin:1px 0 5px 0">',
    );
    
    $exp = BeginTable() .
        AlignedRow([ans_rule(2)]) .
        AlignedRow([$LINE]) .
        AlignedRow(["\($d\)"]) .
    EndTable();
    $exp = BeginTable() .
        Row(["\(\displaystyle\frac{$a}{$b} = \)",$exp],separation=>8) .
    EndTable();

Hope that helps.

Davide