mathjax / MathJax-node

MathJax for Node
Apache License 2.0
616 stars 97 forks source link

Config options don't change appearance of SVG output #456

Open lizdenhup opened 4 years ago

lizdenhup commented 4 years ago

Hi!

I am using Mathjax-node v2.1.1 to render SVG output. The SVG output is too large and the font-weight is too heavy compared to its surrounding text. I've tried changing the config options to no avail. Here is an example of the typeset math compared to the text it is surrounded by:

Screen Shot 2020-02-21 at 12 29 12 PM

My configuration code looks like this:

const mjAPI = require("mathjax-node");
mjAPI.config({
  MathJax: {
    SVG : {
      minScaleAdjust: 30,
      scale: 70,
      font : "STIX-Web",
      mtextFontInherit: true,
      addMMLclasses: true,
      matchFontHeight: true
    }
  }
});

Changing the configuration has not seemed to yield any differences in rendering whatsoever. Thanks for weighing in on what I should do!

dpvc commented 4 years ago

Changing the configuration has not seemed to yield any differences in rendering whatsoever.

Not all MathJax configuration options apply to mathjax-node. One of these is the scale parameter. In the browser, MathJax handles the scale by placing a <span style="font-size:70%"> element around the <svg> element, but that is not included in the mathjax-node output, since that produces only the <svg> element. You can modify your code to include a surrounding <span> to include the needed scaling factor, if you want.

Also note that mtextFontInherit: true, while allowed, will not produce the result you may be expecting. Since mathjax-node does not have access to the surrounding font (as MathJax does in the browser), it can not know the size of the text in that font, and so doesn't know how much space to leave for it. So mathjax-node uses the monospace font, so that it can approximate the size better.

As for the darkness, I am not able to reproduce the result you are seeing. Can you link to an actual page that shows it? You might try changing the blacker option in the SVG configuration block. Its default should be 1, but try setting it to 1 or 0 and see if that helps.