How to change unknown characters's style in SVG output ?

35 views
Skip to first unread message

Jinjun He

unread,
Sep 20, 2016, 6:01:26 AM9/20/16
to MathJax Users
Hello everyone,

  I use MathJax SVG processor to render equations. and find some unknown chars(chinese characters Demo ) in my equations.

  I look up the SVG output processor options document and found some useful options like 'undefinedFamily'.

  But I can't adjust the undefined character's style well. like font-size and scale. because the characters are to small for view and print out by PDF.




  Now I achieve it by change the MathJax source code like below.


 
MathJax version: 2.6.1

file: MathJax/jax/output/SVG/jax.js

line 631:

var box = BBOX.TEXT(scale*100/SVG.config.scale,c,{
    "font-family":variant.defaultFamily||SVG.config.undefinedFamily,
  "font-style":(variant.italic?"italic":""),
  "font-weight":(variant.bold?"bold":"")
})


After change:

/**
 * regex (/[\u4E00-\u9FA5]/) match all of chinese characters
 *
 * 
preferredCNScale options is perferred scale value for chinese characters.
 *
 * 
MathJax.Hub.Config({
 *    SVG: {
 *      preferredCNScale: 1,
 *    }
 * });
 *
 */

var stretchSacle = (/[\u4E00-\u9FA5]/.test(text) && scale < SVG.config. preferredCNScale) ? SVG.config.preferredCNScale : scale;

var box = BBOX.TEXT(stretchSacle*100/SVG.config.scale,c,{
    "font-family":variant.defaultFamily||SVG.config.undefinedFamily,
  "font-style":(variant.italic?"italic":""),
  "font-weight":(variant.bold?"bold":"")
})
  


  But I wonder if there is a more elegant way to achieve it.

Peter Krautzberger

unread,
Sep 20, 2016, 6:30:11 AM9/20/16
to mathja...@googlegroups.com
Hi,

Since you're using TeX input, it's advisable to use the TeX macros for sizing, e.g., \large{...} \Large{...}, \Huge{...}.

Regards,
Peter.

--
You received this message because you are subscribed to the Google Groups "MathJax Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathjax-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jinjun He

unread,
Sep 20, 2016, 7:02:38 AM9/20/16
to MathJax Users
Hi Peter,

  Thank you very much, It really works !
Peter.

To unsubscribe from this group and stop receiving emails from it, send an email to mathjax-user...@googlegroups.com.

Davide Cervone

unread,
Sep 20, 2016, 7:09:53 AM9/20/16
to mathja...@googlegroups.com
To follow up on Peter's comment, the the sizing of the characters is due to the fact that you are misusing superscripts and underlines to create the output.  You have used

^{\underline{\underline{^{高温}}}}

to create something that looks like a stretchy equal sign, but isn't.  Each of the superscript carets (^) cause the size to get smaller. You should not modify MathJax to compensate for the hack you have used to obtain this output.

You could use

^{\underline{\underline{^{\textstyle 高温}}}}}

to cause the characters to be typeset in the size of normal text (similar to Peter's suggestion), but the equal sign is still a hack.

You could use

\stackrel{\textstyle 高温}{=}

to get these characters over an equal sign (and override the size), but the equal sign will not be stretchy.

Instead, why don't you use the extpfeil package, which includes \xlongequal instead?  Add "extpfeil.js" to your TeX extensions list, and then use

\xlongequal{\textstyle 高温}

and avoid all the crazy underlining and superscripts.

I'm also not sure why you load the mhchem package, but don't use it.  It would make typesetting these equations much easier.

Davide




Reply all
Reply to author
Forward
0 new messages