possibility of same weight of fonts like in \ce{} command

29 views
Skip to first unread message

dei...@gmail.com

unread,
Dec 15, 2016, 5:57:33 AM12/15/16
to MathJax Users






I'd like to achieve same font weight like in chemical equations \ce{} (top on picture) in math (bottom on picture)
\ce{UO2^2+}
\left(\mathrm{0,5\,eV}\right)

Is it somehow possible?
Thanks.

Davide Cervone

unread,
Dec 29, 2016, 2:19:30 PM12/29/16
to mathja...@googlegroups.com
The results shown in your picture don't look like they are normal MathJax output (the fonts and spacing aren't right), so my first suspicion is that you may not be using MathJax correctly. You really haven't given us enough information to help.

Please check the User Group guidelines at https://groups.google.com/d/msg/mathjax-users/Dhk3bQgThaM/NPtq7VLv-5EJ for more tips on providing sufficient information.


Davide

dei...@gmail.com

unread,
Jan 3, 2017, 4:01:58 AM1/3/17
to MathJax Users
I'm sorry for brevity and confusion.
I'm using this custom config (sans serif font):

MathJax.Hub.Config({
  menuSettings
: {zoom: "Click"},
 
"HTML-CSS": {
    availableFonts
: ["TeX"],
   
MMLorHTML: {prefer: "HTML"},
    imageFont
: null,
    mtextFontInherit
: true,
    linebreaks
: { automatic: true }
 
},
 
CommonHTML: {
    mtextFontInherit
: true,
    linebreaks
: { automatic: true }
 
},
  SVG
: {
    mtextFontInherit
: true,
    linebreaks
: { automatic: true }
 
},
 
TeX: {
    equationNumbers
: { autoNumber: "AMS" },
    extensions
: ["mhchem.js"],
   
Macros: {
      AA
: "{\\unicode{0x212B}}",
      MR
: ["{\\mathrm{#1}}",1],
      BUDA
: "\\mathord{\\bbox[2px,border:1px solid black]{\\kern.15em\\uparrow\\downarrow\\kern.15em\\strut}}",
      BUA
: "\\mathord{\\bbox[2px,border:1px solid black]{\\kern.33em\\uparrow\\kern.33em\\strut}}",
      BDA
: "\\mathord{\\bbox[2px,border:1px solid black]{\\kern.33em\\downarrow\\kern.33em\\strut}}"
   
}
 
}
});
MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () {
   
var VARIANT = MathJax.OutputJax["CommonHTML"].FONTDATA.VARIANT;
    VARIANT
["normal"].fonts.unshift("MathJax_SansSerif");
    VARIANT
["bold"].fonts.unshift("MathJax_SansSerif-Bold");
    VARIANT
["italic"].fonts.unshift("MathJax_SansSerif-Italic");
    VARIANT
["-tex-mathit"].fonts.unshift("MathJax_SansSerif-Italic");
});
MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
   
var VARIANT = MathJax.OutputJax["HTML-CSS"].FONTDATA.VARIANT;
    VARIANT
["normal"].fonts.unshift("MathJax_SansSerif");
    VARIANT
["bold"].fonts.unshift("MathJax_SansSerif-bold");
    VARIANT
["italic"].fonts.unshift("MathJax_SansSerif-italic");
    VARIANT
["-tex-mathit"].fonts.unshift("MathJax_SansSerif-italic");
});
MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
   
var VARIANT = MathJax.OutputJax.SVG.FONTDATA.VARIANT;
    VARIANT
["normal"].fonts.unshift("MathJax_SansSerif");
    VARIANT
["bold"].fonts.unshift("MathJax_SansSerif-bold");
    VARIANT
["italic"].fonts.unshift("MathJax_SansSerif-italic");
    VARIANT
["-tex-mathit"].fonts.unshift("MathJax_SansSerif-italic");
});
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
   
MathJax.InputJax.TeX.Definitions.number =
     
/^(?:[0-9]+(?:\.[0-9]{3})*(?:,[0-9]*)*|,[0-9]+)/
});

MathJax.Ajax.loadComplete("[MathJax]/config/local/mathjax_sans_mhchem_cz.js");


Davide Cervone

unread,
Jan 4, 2017, 9:37:31 AM1/4/17
to mathja...@googlegroups.com
OK, it turns out that it is the mtextFontInherit that is causing the difference in size, since the upright letters are being obtained by \text{} macro calls.  The mhchem package has been rewritten, and you can use the new version by setting

MathJax.Hub.Config({TeX: {mhchem: {legacy: false}}});

The new version uses \mathrm instead, so that should prevent the font change.

Note that this will load the mhchem package from the third-party repository on the CDN, so if you are hosting your own copy for use off-line, you would ned to get the mhchem.js file from the third-party repository and replace the one in extensions/TeX with the new copy.

Davide



--
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-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

dei...@gmail.com

unread,
Jan 5, 2017, 12:24:14 PM1/5/17
to MathJax Users
OK, I'll give it a try.
I've racked one's brains over difference between live demo on MJ's site and mine. Now I see I use Verdana font which have other properties. Live demo seems also better smoothed because it uses dark gray color (#333).

Thank you :-)

dei...@gmail.com

unread,
Jan 7, 2017, 4:45:02 AM1/7/17
to MathJax Users
When I add:
mhchem: {legacy: false},
after
extensions: ["mhchem.js"],
It loads mhchem v.3.x.x from CDN but when I replace older mhchem.js with new one, page writes that it could not load mhchem.js and it takes time. Finally it loads it from my hosting. For now solved to let it on CDN (with older mhchem.js in my hosted version).

I see progress in new mhchem.js but I was happy when I saw font to be so close to surrounding text in page in older version (as you wrote due \text{}).
I'd be happy if I could control font weight somehow to be as close to surrounding text as possible.
I'm sorry that I'm not providing example, so I'll try to prepare some soon.
I'm looking forward to see what I'm doing wrong :-)

dei...@gmail.com

unread,
Jan 7, 2017, 5:44:47 AM1/7/17
to MathJax Users, dei...@gmail.com

Davide Cervone

unread,
Jan 7, 2017, 11:04:46 AM1/7/17
to mathja...@googlegroups.com
On Jan 7, 2017, at 4:45 AM, dei...@gmail.com wrote:

When I add:
mhchem: {legacy: false},
after
extensions: ["mhchem.js"],
It loads mhchem v.3.x.x from CDN but when I replace older mhchem.js with new one, page writes that it could not load mhchem.js and it takes time. Finally it loads it from my hosting. For now solved to let it on CDN (with older mhchem.js in my hosted version).

Sorry, I forgot to mention one thing:  when you copy the new version of mhchem, you will need to edit the last line of the file to be the same as the last line of the original version:

MathJax.Ajax.loadComplete("[MathJax]/extensions/TeX/mhchem.js"); 


rather than the line referring to [Contrib].


I see progress in new mhchem.js but I was happy when I saw font to be so close to surrounding text in page in older version (as you wrote due \text{}).
I'd be happy if I could control font weight somehow to be as close to surrounding text as possible.
I'm sorry that I'm not providing example, so I'll try to prepare some soon.
I'm looking forward to see what I'm doing wrong :-)

MathJax adjusts the font size in order to match the ex-height of the math fonts to the ex-height of the surrounding font.  In some cases, that means the math fonts are scaled up and that can cause an increase in apparent font weight of the math.  You can add

matchFontHeight: false

to the HTML-CSS, CommonHTML, and SVG blocks to prevent that.  This may mean the math height does not match the surrounding font height very well, but may make the weights more consistent.  You will have to decide which of the two problems is least objectionable to you.

Davide

Reply all
Reply to author
Forward
0 new messages