SVG from TeX Math Expression
Install Node.js
Install Node.js from https://nodejs.org or via your distrubution's package manager. So e.g. for Debian based distros like Ubuntu:
sudo apt install npm
and for Ubuntu to properly install some packages also
sudo apt install nodejs-legacy
Create a Simple MathJax Converter
Create a folder Tex2Svg and open a command prompt here to install mathjax-node:
npm install mathjax-node
And then create tex2svg.js:
#!/usr/bin/env node
var mjAPI = require("mathjax-node");
if (process.argv.length != 3) {
console.log("No expression given!\n");
console.log("Usage: " + process.argv[0] + " " + process.argv[1] + " <TeX expression>");
process.exit(1);
}
mjAPI.start();
var yourMath = process.argv[2];
mjAPI.typeset({
math: yourMath,
format: "TeX",
svg:true,
}, function (data) {
if (!data.errors)
console.log(data.svg);
});
Usage
node ./tex2svg.js "f(x) = x^2" > parabola.svg