简体   繁体   中英

How to keep spaces in the formatted expression in jqMath

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.

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

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

Update: If you stumble on this, jqmath has added \\, \\: and \\; operaters that specify thin, mid, and thicker white spacing.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM