embedding non-italic math in italic text

438 views
Skip to first unread message

Benjamin

unread,
May 21, 2011, 11:32:13 PM5/21/11
to MathJax Users
Hello, I'm embedding MathJax in some text like this

<div style="font-style: italic">
Applying the theorem, we see a magic result \(x = 42\).
</div>

I want the narrative to be italic, but not the math. How can I do
this?

Trying to style the .MathJax class with "font-style: normal" in my
style sheet doesn't seem to work. I guess this must have something to
do with font loading, since putting a <div style="font-style: normal">
around the math seems to work.

Thanks,
Benjamin

Davide P. Cervone

unread,
May 24, 2011, 1:47:39 PM5/24/11
to mathja...@googlegroups.com
MathJax sets the font and style of the individual characters itself, according to the rules of mathematical typesetting as implemented by TeX. You can not use CSS to change that, in general.  If you wish to affect the fonts within the mathematics, you would need to use one of the font commands in TeX or LaTeX, as in 

<div style="font-style: italic">
Applying the theorem, we see a magic result \(\rm x = 42\).
</div>

or 

<div style="font-style: italic">
Applying the theorem, we see a magic result \(\mathrm{x = 42}\).
</div>

Currently there is no way to have this done automatically, so it would have to be inserted by hand.

Davide

Benjamin

unread,
May 24, 2011, 2:00:51 PM5/24/11
to MathJax Users


On May 24, 12:47 pm, "Davide P. Cervone" <d...@union.edu> wrote:
> > Hello, I'm embedding MathJax in some text like this
>
> > <div style="font-style: italic">
> > Applying the theorem, we see a magic result \(x = 42\).
> > </div>
>
> > I want the narrative to be italic, but not the math. How can I do
> > this?
>
> > Trying to style the .MathJax class with "font-style: normal" in my
> > style sheet doesn't seem to work. I guess this must have something to
> > do with font loading, since putting a <div style="font-style: normal">
> > around the math seems to work.
>
> MathJax sets the font and style of the individual characters itself,  
> according to the rules of mathematical typesetting as implemented by  
> TeX. You can not use CSS to change that, in general.  If you wish to  
> affect the fonts within the mathematics, you would need to use one of  
> the font commands in TeX or LaTeX, as in

But if I can't change it with CSS, why does it inherit the italic
style of the block containing it? Either it should ignore all CSS
styling or let me change it.

>
> <div style="font-style: italic">
> Applying the theorem, we see a magic result \(\rm x = 42\).
> </div>
>
> or
>
> <div style="font-style: italic">
> Applying the theorem, we see a magic result \(\mathrm{x = 42}\).
> </div>
>
> Currently there is no way to have this done automatically, so it would  
> have to be inserted by hand.

Yes, my current hack is to write a preprocess which inserts <span
style="text-style=normal"> around every piece of math.

>
> Davide

Davide P. Cervone

unread,
May 24, 2011, 2:13:35 PM5/24/11
to mathja...@googlegroups.com
>> MathJax sets the font and style of the individual characters itself,
>> according to the rules of mathematical typesetting as implemented by
>> TeX. You can not use CSS to change that, in general. If you wish to
>> affect the fonts within the mathematics, you would need to use one of
>> the font commands in TeX or LaTeX, as in
>
> But if I can't change it with CSS, why does it inherit the italic
> style of the block containing it? Either it should ignore all CSS
> styling or let me change it.

It doesn't inherit it. Italics are used automatically for variable
names, so the "x" would be in italics no matter what the surrounding
CSS settings. Similarly the 42 will be in non-italics no matter what
the surrounding CSS.

If you are seeing such CSS effects, then THAT is a bug, and I would
appreciate a pointer to a page that shows that (and a report of the
browser and OS that you are using). The snippet you sent works for me
as expected (italic "x" and normal 42, regardless of the font-style in
the surrounding div).

>> <div style="font-style: italic">
>> Applying the theorem, we see a magic result \(\rm x = 42\).
>> </div>
>>
>> or
>>
>> <div style="font-style: italic">
>> Applying the theorem, we see a magic result \(\mathrm{x = 42}\).
>> </div>
>>
>> Currently there is no way to have this done automatically, so it
>> would
>> have to be inserted by hand.
>
> Yes, my current hack is to write a preprocess which inserts <span
> style="text-style=normal"> around every piece of math.

That should not affect the math in any way. (Also, you mean "text-
style: normal" with a colon and an equal.)

My examples show additional TeX commands that must be used as part of
the mathematics, not CSS control. As I mentioned in my response,
MathJax sets the font style itself on each character, depending on how
that character is used. Global CSS should not affect that, except in
very special cases that I won't go into here.

Davide

Reply all
Reply to author
Forward
0 new messages