Forum archive 2000-2006

John Jones - math mode, TEXT, and dvipng

John Jones - math mode, TEXT, and dvipng

by Arnold Pizer -
Number of replies: 0
inactiveTopicmath mode, TEXT, and dvipng topic started 11/20/2002; 10:40:44 AM
last post 9/3/2003; 12:07:23 PM
userJohn Jones - math mode, TEXT, and dvipng  blueArrow
11/20/2002; 10:40:44 AM (reads: 1381, responses: 1)
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);


The largest set on which the function \(f(x,y) = 1/($r - x^2 - y^2)\)
is continuous is \{ans_rule()\}
\{ OL(@answers[@permutation]) \}

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.


<| Post or View Comments |>

userArnold K. Pizer - Re: math mode, TEXT, and dvipng  blueArrow
9/3/2003; 12:07:23 PM (reads: 1445, responses: 0)

Thanks John,

When time permits, we will try to modify the offending problems in the problem library.


<| Post or View Comments |>