12
$\begingroup$

The current TeXification function is too aggressive. The current behavior is that,

  1. any text between two dollar signs in a single element will be formatted as a TeX formula.
  2. this excludes any elements in <head>, <script>, <iframe>, <style>, <title>, <meta>, <textarea> and <object>.

However, this simplistic matching algorithm

  1. causes TeXification in unsuitable places, e.g. inside code blocks

    like $this$
    

    while it's rare to write code here, it is still usable for ASCII art.

  2. makes it impossible to use a raw dollar sign. Not even &#x24; works. In MathOverflow we can escape a dollar sign by prefixing a backslash (\$), but even this won't work here.

To see the mess it caused, see https://math.meta.stackexchange.com/questions/398#398.

Problem 1 can be fixed simply by also excluding the <pre> element in Behavior 2, just like MathOverflow. To solve problem 2, the whole goGoGadgetMath() function has to be rewritten, or just use jsMath/MathJax.

$\endgroup$
3
$\begingroup$

We just deployed MathJax 1.1 with escaping enabled, so this should be possible.

Let's see:

"if ten apples cost \$5.00 and six oranges are for \$3.50, how much is ..."

"if ten apples cost \$5.00 and six oranges are for \$3.50, how much is ..."
$\endgroup$
  • 3
    $\begingroup$ Actually, the example you just typed looks broken to me. everything between 5.00 and "are for" are rendered as mathematical text. $\endgroup$ – Willie Wong Mar 29 '11 at 14:18
  • $\begingroup$ @Willie Wong, it looks ok for me. Chrome 10 on Mac OS X 10.6.6 $\endgroup$ – mpiktas Mar 29 '11 at 14:20
  • $\begingroup$ @Willie Wong, after submitting the comment the behaviour changed to the one you described. $\endgroup$ – mpiktas Mar 29 '11 at 14:21
  • $\begingroup$ In Firefox 4, the behaviour is inconsistent. Hard-refreshing sometimes produces math text, sometimes dollar signs. It seems as though, as long as the text is in view when MathJax processes the page, the dollar signs appear as expected. $\endgroup$ – Rahul Mar 29 '11 at 15:20
  • 2
    $\begingroup$ I have asked a question in the MathJax forums: sourceforge.net/projects/mathjax/forums/forum/948701/topic/… - hopefully we will get a response soon. $\endgroup$ – Geoff Dalgas Mar 29 '11 at 17:47
  • 2
    $\begingroup$ @Geoff: thanks! JFYI: they moved the discussion over to groups.google.com/group/mathjax-users/browse_thread/thread/… as the development forum is closed now. $\endgroup$ – Willie Wong Mar 29 '11 at 18:57
1
$\begingroup$

Now MathJax is deployed, problem 1 no longer exists, but it still TeXify in unnecessary places (see Editing a question containing formulae will remove the formulae).

The dollar sign can be escaped with \$, but the leading \ should not present.

$\endgroup$
9
$\begingroup$

Algebra questions may periodically appear, that have multiple dollar signs. Compare:

"if ten apples cost $5.00 and six oranges are for $3.50, how much is ..." [using dollar symbol]

"if ten apples cost USD 5.00 and six oranges are USD 3.50, how much is ..." [avoid dollar signs]

"if ten apples cost \$ 5.00 and six oranges are for \$ 3.50, how much is ..." [using backslack-dollar]

"if ten apples cost $\$$ 5.00 and six oranges are for $\$$3.50, how much is ..." [render each dollar sign in TeX as dollar-backslash-dollar-dollar]

Same for postings of compound interest (loan amortization) calculations or anything with data in dollar currency.

Such questions are likely to be posted by people who may not know what TeX is, so some dollar-sign FAQ may be in order.

$\endgroup$
3
$\begingroup$

From the MathJax documentation on the tex2jax preprocessor:

When [processEscapes is] set to true, you may use \$ to represent a literal dollar sign, rather than using it as a math delimiter. When false, \$ will not be altered, and the dollar sign may be considered part of a math delimiter. Typically this is set to true if you enable the $ ... $ in-line delimiters, so you can type \$ and tex2jax will convert it to a regular dollar sign in the rendered document.

Is there a reason this option is not enabled? T..'s other workaround of rendering a dollar symbol inside the TeX (using dollar-backslash-dollar-dollar) is quite non-obvious.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .