styles: {
".MathJax_MathML": {
"font-weight": "inherit"
}
}
--
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.
> 1. Should I use CommonHTML or NativeMML?Neither will change this much. But we should probably advise not to use NativeMML because it is effectively deprecated.
> 2. MathJax applies a custom style to math elements. But I would like it to inherit from the parent element.That's not possible in general (and probably not advisable). In this specific case (TeX input, bold), there's the autobold extension to help.
MathJax.Hub.Queue(
['setRenderer', MathJax.Hub, 'CommonHTML'],
['Typeset', MathJax.Hub, elements],
['setRenderer', MathJax.Hub, 'SVG']
);
["Require", MathJax.Ajax, "[MathJax]/extensions/TEX/autobold.js"]
The larger problem is that traditionally (in particular in print), equational content ignores/resets the stylistic choices of the surrounding textual content. Since mathematical notation has a long tradition of re-purposing stylistic tools (font face/variant/weight) for semantics, that's usually sensible. As such, it is deeply ingrained in MathML but clashes with CSS's cascade.
So far I have only been using the MathJax' SVG renderer in SVG drawings. Now I need to render some elements in an HTML table that should resemble as close as possible the parent element's style.
1. Should I use CommonHTML or NativeMML?
2. MathJax applies a custom style to math elements. But I would like it to inherit from the parent element. Here is a simple example:
https://jsfiddle.net/xnc09a1n/
I have tried to use add styles to the configuration but with no success. For example,
styles: {
".MathJax_MathML": {
"font-weight": "inherit"
}
}
Any tips much appreciated.
Daniel
--
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.
Great. Since all I actually need for now is bold, this seems to work fine for me. But then I have a quick follow up questions. I am switching to CommonHTML from SVG with
MathJax.Hub.Queue(
['setRenderer', MathJax.Hub, 'CommonHTML'],['Typeset', MathJax.Hub, elements],
['setRenderer', MathJax.Hub, 'SVG']
);
Now, if I have understood correctly, I probably need to add the require command. I tried
["Require", MathJax.Ajax, "[MathJax]/extensions/TEX/autobold.js"]
But it fails to load the extension.
Also I would have to unload the extension before rendering in SVG again. But I could not find any command to unload an extension. (http://docs.mathjax.org/en/latest/api/ajax.html)
Maybe it would be nice to (have an option to) render text, e.g. \(\text{...}\), in the surrounding style?
Great. Since all I actually need for now is bold, this seems to work fine for me. But then I have a quick follow up questions. I am switching to CommonHTML from SVG with
MathJax.Hub.Queue(
['setRenderer', MathJax.Hub, 'CommonHTML'],['Typeset', MathJax.Hub, elements],
['setRenderer', MathJax.Hub, 'SVG']
);
Now, if I have understood correctly, I probably need to add the require command. I tried
["Require", MathJax.Ajax, "[MathJax]/extensions/TEX/autobold.js"]
But it fails to load the extension.You need to use "TeX" not "TEX" (the capitalization will cause the loading to fail).
Also I would have to unload the extension before rendering in SVG again. But I could not find any command to unload an extension. (http://docs.mathjax.org/en/latest/api/ajax.html)The extension is about the input processing, not the output processing, so it has nothing to do with the difference between CommonHTML and SVG.The purpose of the extension is to detect whether the math being processed is within a container that has a bold-weight font, and if so, the math is set to use a bold font by default. If the surrounding font is not bold, the math is processed as normal. So I don't see why you would need to remove the extension, or why you would want one action for the CommonHTML output and a different for SVG. Perhaps you can explain your situation further?
Maybe it would be nice to (have an option to) render text, e.g. \(\text{...}\), in the surrounding style?There already is one for that. Set mtextFontInherit to true in the CommonHTML and SVG configuration blocks:MathJax.Hub.Config({CommonHTML: {mtextFontInherit: true},SVG: {mtextFontInherit: true}});and that should do it.
The purpose of the extension is to detect whether the math being processed is within a container that has a bold-weight font, and if so, the math is set to use a bold font by default. If the surrounding font is not bold, the math is processed as normal. So I don't see why you would need to remove the extension, or why you would want one action for the CommonHTML output and a different for SVG. Perhaps you can explain your situation further?
Thanks. Now autobold does not fail to load but still nothing gets set in bold. Probably I have misunderstood how it is supposed to work:
https://jsfiddle.net/9q14h5mo/
<script type="text/x-mathjax-config">MathJax.Hub.Register.StartupHook("TeX boldsymbol Ready",function () {var MML = MathJax.ElementJax.mml,TEX = MathJax.InputJax.TeX;TEX.Parse.Augment({Boldsymbol: function (name) {var boldsymbol = this.stack.env.boldsymbol,font = this.stack.env.font;this.stack.env.boldsymbol = true;this.stack.env.font = MML.VARIANT.BOLD;var mml = this.ParseArg(name);this.stack.env.font = font;this.stack.env.boldsymbol = boldsymbol;this.Push(mml);}});});</script>
Maybe it would be nice to (have an option to) render text, e.g. \(\text{...}\), in the surrounding style?There already is one for that. Set mtextFontInherit to true in the CommonHTML and SVG configuration blocks:MathJax.Hub.Config({CommonHTML: {mtextFontInherit: true},SVG: {mtextFontInherit: true}});and that should do it.
It does not, at least not what I expected:
In general, MathJax does not support typesetting math inside containers with display:none, even though the CommonHTML output usually works. As you have seen, there are still some situations that don't work in that setting.
MathJax.Hub.Register.StartupHook("TeX boldsymbol Ready",function () {var MML = MathJax.ElementJax.mml,
TEX = MathJax.InputJax.TeX,STACKITEM = TEX.Stack.Item;
TEX.Parse.Augment({Boldsymbol: function (name) {var boldsymbol = this.stack.env.boldsymbol,font = this.stack.env.font;this.stack.env.boldsymbol = true;this.stack.env.font = MML.VARIANT.BOLD;var mml = this.ParseArg(name);this.stack.env.font = font;this.stack.env.boldsymbol = boldsymbol;this.Push(mml);
},InternalMath: function (text,level) {var def = (this.stack.env.font ? {mathvariant: this.stack.env.font} : {});var env = (this.stack.env.boldsymbol ? {font: this.stack.env.font, boldsymbol:true} : {});var mml = [], i = 0, k = 0, c, match = '', braces = 0;if (text.match(/\\?[${}\\]|\\\(|\\(eq)?ref\s*\{/)) {while (i < text.length) {c = text.charAt(i++);if (c === '$') {if (match === '$' && braces === 0) {mml.push(MML.TeXAtom(TEX.Parse(text.slice(k,i-1),env).mml()));match = ''; k = i;} else if (match === '') {if (k < i-1) mml.push(this.InternalText(text.slice(k,i-1),def));match = '$'; k = i;}} else if (c === '{' && match !== '') {braces++;} else if (c === '}') {if (match === '}' && braces === 0) {mml.push(MML.TeXAtom(TEX.Parse(text.slice(k,i),env).mml().With(def)));match = ''; k = i;} else if (match !== '') {if (braces) braces--;}} else if (c === '\\') {if (match === '' && text.substr(i).match(/^(eq)?ref\s*\{/)) {var len = RegExp["$&"].length;if (k < i-1) mml.push(this.InternalText(text.slice(k,i-1),def));match = '}'; k = i-1; i += len;} else {c = text.charAt(i++);if (c === '(' && match === '') {if (k < i-2) mml.push(this.InternalText(text.slice(k,i-2),def));match = ')'; k = i;} else if (c === ')' && match === ')' && braces === 0) {mml.push(MML.TeXAtom(TEX.Parse(text.slice(k,i-2),env).mml()));match = ''; k = i;} else if (c.match(/[${}\\]/) && match === '') {i--; text = text.substr(0,i-1) + text.substr(i); // remove \ from \$, \{, \}, or \\}}}}if (match !== '') TEX.Error(["MathNotTerminated","Math not terminated in text box"]);}if (k < text.length) mml.push(this.InternalText(text.slice(k),def));if (level != null) {mml = [MML.mstyle.apply(MML,mml).With({displaystyle:false,scriptlevel:level})];} else if (mml.length > 1) {mml = [MML.mrow.apply(MML,mml)];}return mml;}});var INIT = STACKITEM.array.prototype.Init,CLEARENV = STACKITEM.array.prototype.clearEnv;STACKITEM.array.Augment({Init: function () {this.copyEnv = true; this.env = {};return INIT.apply(this,arguments);},clearEnv: function() {var bold = this.env.boldsymbol;CLEARENV.call(this);if (bold) {this.env.boldsymbol = bold; this.env.font = "bold"}}});});