Closed hjy1210 closed 7 years ago
how to setup mathjax.js path?
You generally don't. MathJax is installed from npm and loaded by mathjax-node.
In mathjax-node, how to configure it to support chemical equations, such as \ce{H2SO4}.
You can specify extension when you call config
, cf. https://github.com/mathjax/MathJax-node#configoptions
Specifying it in extensions as below
const mj = require('mathjax-node')
mj.config({
extensions: 'mhchem.js'
})
mj.start()
mj.typeset({math:'\\ce{Hg^2+ ->[I-] HgI2 ->[I-] [Hg^{II}I4]^2-}', html:true}, (r)=>{
console.log(r.html)
})
is giving this
File load error: file:///k:/mj-node/node_modules/mathjax/unpacked/extensions/mhchem.js
@pkra Thanks a lot, now I know we do not need to configure mhchem at all, it seems mathjax-node auto load mhchem.js if it need process command \ce. @RagibHasin Thanks a lot, my stupid mistake is: we need to type '\\ce{H2SO4}' instead of '\ce{H2SO4}'. I just forgot to escape backslash in javascript string.
@hjy1210 You missed to escape that again! 😬 But thank you for that suggestion. Only the thing that annoys me is the error message. Why this appears though mathjax-node
loaded mhchem.js
, @pkra ?
@hjy1210: it seems mathjax-node auto load mhchem.js if it need process command \ce.
Oh, I should not reply on the weekend.
Yes, it's autoloaded via the autoload extension, cf. https://github.com/mathjax/MathJax-node/blob/master/lib/main.js#L147
@RagibHasin Only the thing that annoys me is the error message.
It the path is not correct. It needs to be extensions: 'TeX/mhchem.js'
.
In html head section, we can use following two script elements to support chemical equations.
In mathjax-node, how to configure it to support chemical equations, such as \ce{H2SO4}. how to setup mathjax.js path?