问题
I am using jqMath for Math equation formatter. I don't want to remove spaces and newline character from the expression. How can I do that? I have tried a lot but I coudn't find any solution.
回答1:
from the author ...
In general, it's best to let html handle the text, and jqMath handle the math. For example, write " using $y = (x+1)/(x+2)$", or "<td>$x+y = 2$<td>(1)" inside an html table.
You have to be able to separate user input into mathematics and non-mathematics. If a user inputs "using y=x" you don't want "using" parsed as the product of 5 variables u, s, i, n, and g. Similarly, if he inputs extra spaces that you want to keep outside the mathematics, you have to capture them using regular expressions or something, and don't pass them to jqMath. If you want the spaces to be part of the mathematics, you could make the user input \table or \sp or \text or something, though most users won't know to do that. You could tell users that they need to put $ $ around their mathematics if they want it to format, and then you could search for that.
Basically, jqMath isn't smart enough to tell what's math and what isn't, without $ $ to help.
Probably 0.2.0 will be out in a couple months, or at least I'll have a version I could send you by then.
Update : New version is out which support /text and /html
回答2:
Using \text and "" is used to give space inside the formula
HTML source : [\text"average speed" = \text"distance traveled" / \text"elapsed time"]
Result :
this example is available in http://mathscribe.com/author/jqmath.html
回答3:
Update: If you stumble on this, jqmath has added \,
\:
and \;
operaters that specify thin, mid, and thicker white spacing.
回答4:
It doesn't look like it can be done. To quote the page you provided:
spaces, tabs and newlines are ignored - jqMath formats the mathematics
来源:https://stackoverflow.com/questions/7601222/how-to-keep-spaces-in-the-formatted-expression-in-jqmath