normal font for \text clauses

468 views
Skip to first unread message

nageh

unread,
Nov 9, 2010, 1:09:59 PM11/9/10
to MathJax Users
Would it be possible to add an option such that clauses in \text
statements are rendered in the default font used in a web page? It
would allow much smoother integration with the rest of the content. Of
course the text would have to be scaled together with the surrounding
math if a specific zoom factor is selected.

Thanks,
-nageh

Casey W. Stark

unread,
Nov 9, 2010, 2:10:53 PM11/9/10
to mathja...@googlegroups.com
Can you explain a little more about your use case? Is there a reason you don't want to split up the blocks like \(\text{math}\) normal text \(\text{more math}\)? Just trying to figure out if there's a better way to accomplish this.

nageh

unread,
Nov 9, 2010, 3:06:14 PM11/9/10
to MathJax Users
Examples where it would be awkward (or impossible) to split the text:

f(x) = \begin{cases}
1 & \text{if } x \text{ is prime}, \\
0 & \text{if } x \text{ otherwise}. \end{cases}

\mathit{COMPOSITE} = \{x\in\mathbb N:x=pq \text{ for integers } p, q >
1 \}

-nageh

On Nov 9, 8:10 pm, "Casey W. Stark" <caseywst...@gmail.com> wrote:
> Can you explain a little more about your use case? Is there a reason you
> don't want to split up the blocks like \(\text{math}\) normal text
> \(\text{more math}\)? Just trying to figure out if there's a better way to
> accomplish this.
>

Casey W. Stark

unread,
Nov 9, 2010, 5:12:09 PM11/9/10
to mathja...@googlegroups.com
Ah excellent examples. If you really want to adjust the \text content on the entire page, you could set the CSS style of .mtext (the class applied to all \text blocks using the HTML-CSS output jax), although this can break spacing.

I don't know about the feasibility of adding an option for this. It might take a lot of work to get this not to break other things, but we will think about it.

I went ahead and added an issue for this if you want to follow: https://github.com/mathjax/mathjax/issues/issue/21

Davide P. Cervone

unread,
Nov 11, 2010, 6:43:41 PM11/11/10
to mathja...@googlegroups.com
I certainly understand the desire for this, and it is something I have
thought about in the past. The technical difficulty is that the
container elements used by MathJax already reset the font settings (to
make sure that there is no "bleed through" to the mathematics) and so
when the text content is inside those containers, there is no easy way
to get it to show in the font of the surrounding text. The most
direct approach would be to allow the font used for the \text to be
configured (either through CSS as Casey suggested, or through a
MathJax configuration parameter) so that you could specify the font
you want, but that is not quite the same as having it automatically
use the font in effect at the location of the math. That would be
difficult with the current architecture.

Davide

nageh

unread,
Nov 17, 2010, 2:51:19 PM11/17/10
to MathJax Users
Setting the font family for .mtext in hub.config.styles didn't work. I
can change color and size, though. Any thoughts?

-nageh

Davide P. Cervone

unread,
Nov 19, 2010, 5:16:02 PM11/19/10
to mathja...@googlegroups.com
I was afraid it might not. If I recall correctly, the fonts are
explicitly set on the various elements, so CSS control won't work for
that.

I'll have to look further into other solutions.

Davide

nageh

unread,
Dec 3, 2010, 10:55:13 AM12/3/10
to MathJax Users
For what it's worth, I have simply overridden the font-family in the
HTML-CSS output jax mtext formatting function with the user-supplied
setting. It's a semi-hack, and you'd probably not want to access the
MathJax.Hub.config structure directly, but it works well enough.

Here is the diff:

1555a1556,1557 (MathJax/jax/output/HTML-CSS/jax.js :
MML.mtext.Augment)
> if ( typeof(MathJax.Hub.config.styles[".mtext"]) !== 'undefined' && typeof(MathJax.Hub.config.styles[".mtext"]["font-family"]) !== 'undefined' )
> span.style.fontFamily = MathJax.Hub.config.styles[".mtext"]["font-family"];

-nageh

Davide P. Cervone

unread,
Dec 17, 2010, 7:35:25 PM12/17/10
to mathja...@googlegroups.com
You can use CSS to do it, but have to make sure you override the
setting that MathJax makes. For example:

<style>
.MathJax .mtext {font-family: Helvetica ! important}
</style>

would make mtext use Helvetica. The "! important" is critical
otherwise the settings that MathJax makes will take precedence. You
can use the MathJax styles configuration block to make a similar style
available:

"HTML-CSS": {
styles: {
".MathJax .mtext": {
"font-family": "Helvetica ! important"
}
}
}

I would not recommend editing the HTML-CSS output jax in the way you
have suggested.

Davide

nageh

unread,
Dec 18, 2010, 7:53:54 AM12/18/10
to MathJax Users
Thanks! Now I definitely prefer your solution!

-nageh
Reply all
Reply to author
Forward
0 new messages