Hi all,
Here is a question and answer which came up while troubleshooting a
problem sent to me by private e-mail. There was a WeBWorK problem
containing a LaTeX equation which was being included in the problem
with the TEXT command. When viewed in pdf or through latex2html, the
math was being typeset. When viewed through dvipng (and tth), it was
not typeset.
The reason the math is not typeset by tth or dvipng is that
TEXT("some string with \( f(x)=x^2 \) ");
is intended to literally produce the string it is given. This is useful
if you want to avoid extra evaluation, which mainly involves
interpretation of math mode for LaTeX. However, pdf generation and
latex2html don't care that you asked for no LaTeX interpretation, and
they just typeset equations anyway. Getting typeset math from TEXT is
kind of an accident.
To get the text to be processed by latex in all modes (except text
mode), it should appear between BEGIN_TEXT and END_TEXT.
If you also are calling a perl function in the middle of things, you
can do that too using the \{ \} construct (just like for ans_rule).
Here is an example:
@answers = ("The interior of the circle \(x^2 + y^2 = $r\)", "All of the xy-plane except the circle \(x^2 + y^2 = $r\)", "The exterior of the circle \(x^2 + y^2 = $r\)"); @permutation = NchooseK(3,3);
TEXT(&beginproblem);
BEGIN_TEXT The largest set on which the function \(f(x,y) = 1/($r - x^2 - y^2)\) is continuous is \{ans_rule()\} $PAR \{ OL(@answers[@permutation]) \} END_TEXT
The typeset math from answers is included through the function OL,
which produces an ordered list. With the problem written as above, the
math will be typeset properly by dvipng, latex2html, and in pdf files.
John
<| Post or View Comments |>
|