Comments (6)
If you do
npm list mathjax
you should get the version of MathJax that you have installed. Because the package.json
file has the version set at ^2.7.2
, you should get the latest 2.7.x version, which is 2.7.9, automatically. If you don't have that version, then
npm install [email protected]
should update the version that you have. If you want to force it to 2.7.5, then use
npm install [email protected]
MathJax does not have a message "missing open brace on subscript", but there are messages that say "Extra close brace or missing open brace", so perhaps that is what you are getting. That indicates a misbalanced brace, so there may be something wrong with the bracing in your expression. If that changes from one version to another, it may be because you haven't braced an argument to a macro properly. If you post the expression that is giving you trouble, we may be able to point out what is causing the issue.
from mathjax-node.
Yes,as you said,Mathjax-node parser worked well without error. It happened on rendering the svg labels to the web,even through postman.
Let me show an example:
\\(∠AOB=50^{\circ}\\),\\(∠AOC=\\) ______ .
as shown, underline in the end is a blank position to fill by the answer student.
it would occurs "Undefined control sequence \\(
",but I've set \\(
as inlineMath(shown in the following picture, but doesn't work at all.
and then I remove '\(':
∠AOB=50^{\circ},∠AOC= ______ .
it would occr "Missing open brace for subscript" which cased by the underline in the end.
Thank you for your help.
from mathjax-node.
The mathjax-node typeset()
command takes a TeX string as its input, not arbitrary text containing math delimiters an other text. So when you do something like
mathjax.typeset({
math: "\\(∠AOB=50^{\circ}\\),\\(∠AOC=\\) ______ .",
... (other parameters) ...
});
MathJax is treating the math string as TeX code to be processed. Note that for javascript strings, the backslash, \
is an escape character that can be used to produce things like newlines (\n
), tabs (\t
), and other special characters, so in order to have an actual backslash within the string, you use \\
. So when \\(
appears in a javascript string literal, the actual string that is produces only contains \(
. Since MathJax is taking your string as a TeX string (without the need for delimiters), it tries to process \(
as a TeX macro. But since that is not defined, you get the "Undefined control sequence error", which is the correct result.
When you remove the delimiters and try to do
mathjax.typeset({
math: "∠AOB=50^{\circ},∠AOC= ______ .",
... (other parameters) ...
});
The entire string is considered to be TeX code, including the underscores at the end. It is those underscores that are producing the error, as they are being interpreted to mean "produce a subscript", as that is the meaning of underscores in TeX's math mode. The first underscore starts a subscript, and then the second tries to make a second subscript, and that is not allowed (you need to use braces after the first underscore in order to have a second underscore with no preceding base character). So that is the source of the error you are getting, which is the correct result.
Note also that the \circ
will end up being just circ
in the string, as the backslash will be interpreted by javascript as trying to produce a special character, but \c
does not stand for anything special, so you just get c
from it. You would need to use \\circ
in the string literal in order to get \circ
in the resulting internal string.
So there is no problem with the MathJax version or with mathjax-node, it is just that you are not providing the right input for MathJax to process.
On a side note, most of your configuration is unnecessary for mathjax-node. The in-line and display delimiters are never used, since the string you pass mathjax.typeset()
does not use delimiters. Similarly, skipTags
is never used, since mathjax-node is not processing an HTML page. The menu gets turned off automatically, so there is no need for the showMathMenu
setting. The jax are already loaded, so no need to specify those. Finally, mathjax-node uses the CommonHTML output jax, not the HTML-CSS one (as CommonHTML output is browser-independent, while HTML-CSS's is not), so your HTML-CSS
configuration is ignored. That means that there is nothing in your configuration that is useful, so you can remove it entirely.
from mathjax-node.
/
As you said,the underscore is a special charactor to Mathjax. and I'v tried to remove or replace them to its html code _ to avoid such error.
eg.
It does work. but underscores are missing. Could you tell me how to keep them in the result?
from mathjax-node.
It's easy to convert underline(_) to backslash and underline(\_) to avoid parsing error.
but, how many characters should be converted before parsing? Is there a list for the special characters?
from mathjax-node.
Are the underscores really supposed to be part of the math expression? Or should that be part of the surrounding HTML? You need to process the math separately from plain text, in general. So I would expect you to process ∠AOB=50^{\circ}
separately, and ∠AOC=
separately, as you originally had them delimited by \(
and \)
, and then insert the results into the larger HTML string.
Alternatively, you could use \text{____________}
or \verb|______________|
.
Is there a list for the special characters?
The main special characters are _
, ^
, {
, }
, \
, %
, #
, &
, and ~
. Depending on what packages are loaded, some others may have special meaning, but most will produce something reasonable, whereas these 9 are used by TeX fin ways that don't produce those characters in the output. There are back-slashed versions of all of them except for ^
, \
, and ~
that produce the given character in the output.
from mathjax-node.
Related Issues (20)
- tex2svg converted image further rendering problem HOT 1
- how to set it to a transparent background? HOT 1
- Do mathjax-node support MathJax@3 HOT 2
- Mathjax- node:Latex Error converting latex to SVG with "\ \ [" HOT 3
- Cannot read property 'childNodes' of null HOT 3
- Rendering problems of latex $$\cong$$ in SVG HOT 5
- '\nolimits is allowed only on operators' which render right in mathjax v3 HOT 2
- width of svg is too small HOT 2
- Unknown node type "mstack" HOT 1
- Cannot get the same result with mathjax-node as with MathJax on the browser HOT 7
- Undefined control sequence even after defining it HOT 2
- "Error: TeX parse error: Missing \end{array}" HOT 2
- MathJax on Linkedom.. HOT 2
- Vercel - Error: Could not load script: "file:///var/task/node_modules/mathjax/unpacked/jax/element/mml/jax.js?V=2.7.9" HOT 5
- Correct mapping for prime symbol HOT 3
- MathJax node does not work with HTML HOT 4
- Cannot read properties of null (reading 'childNodes') HOT 4
- use 'tex2svg' cannot generate formula correctly HOT 1
- Setting background-color style to SVG element HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mathjax-node.