Skip to content
A replacement for but instead of LaTeX, it uses MathJax.
Branch: dev
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin Init May 29, 2019
routes Refactor, trying to stabilize Jun 28, 2019
src Fix STIX-Web patch Jul 4, 2019
test Use bugfix branch, put back race condition checker Jun 28, 2019
views Init May 29, 2019
.gitignore Remove claudia.json file Jul 7, 2019
LICENSE Initial commit May 29, 2019 Fix typo in README Jul 7, 2019
app.js Patch STIX-Web wrong offset Jul 2, 2019
lambda.js Install a font on AWS Lamba Jul 4, 2019


This is a replacement for but instead of LaTeX, it uses MathJax.

Auttomatic's open-source Jetpack plugin has a LaTeX feature that is hardcoded to call

It works like this:



If we squint real hard, we can break down img src into $_GET parameters:

latex.php ? latex=<LaTeX> & fg=<ForegroundColor> & ...

Such a URL returns a PNG containing math rendered by LaTeX.

Hot Swap

Prior to the existence of this microservice, we called for our math needs. (Thanks WordPress!)

Pressbooks users wanted a MathJax solution.

MathJax's CommonHTML output works great in webbooks, but not in PDFs, EPUBs, MOBIs, ...

Nowadays, Pressbooks uses CommonHTML output in webbooks, SVGs in PDFs, and PNGs in MOBI/EPUBs.

The SVGs and PNGs are generated as follows:



  • http://localhost:3000/latex?latex=<LaTeX>
  • Foreground color: http://localhost:3000/latex?latex=<LaTeX>&fg=00ff00
  • Font: http://localhost:3000/latex?latex=<LaTeX>&font=Gyre-Pagella
  • DPI: http://localhost:3000/latex?latex=<LaTeX>&dpi=300

Mix and match fg=<RRGGBB>, font=<string> and dpi=<number> as needed.


  • http://localhost:3000/latex?latex=<LaTeX>&svg=1
  • Foreground color: http://localhost:3000/latex?latex=<LaTeX>&fg=00ff00&svg=1
  • Font: http://localhost:3000/latex?latex=<LaTeX>&font=Gyre-Pagella&svg=1

Ie. same as PNG above with svg=1 added. Because SVGs are vector images, DPI is not used.

AsciiMath and MathML

Same as LaTeX above but instead of latex?latex=<LaTeX> do:

  • AsciiMath: http://localhost:3000/asciimath?asciimath=<AsciiMath> ...
  • MathML: http://localhost:3000/mathml?mathml=<MathML> ...


Install Node.js 10.x LTS, Then:

git clone
cd pb-mathjax
npm install
npm start

Finally, go to: http://localhost:3000/

Deploy to a Production Server

Install PM2 on your server, then:

cd ~/code/github/pressbooks/pb-mathjax
npm install --only=prod
pm2 start bin/www --name pb-mathjax

Pb-mathjax will be available at http://YOURSERVER:3000/ and will run forever (or until you kill PM2.) Use in Pressbooks as the value for PB_MATHJAX_URL

More info:

Deploy to AWS Lambda

Install Claudia.js, then:

cd ~/code/github/pressbooks/pb-mathjax
claudia create --handler lambda.handler --deploy-proxy-api --region us-east-1 --timeout 15 --memory 256 --profile yourself

Where us-east-1 is your AWS region and yourself corresponds to an identity in your ~/.aws/credentials file.

If everything goes well, the above command will finish after a few moments and print a response with a URL. Use in Pressbooks as the value for PB_MATHJAX_URL

More info:

You can’t perform that action at this time.