Inherit text-decoration from context

32 views
Skip to first unread message

tj.sch...@gmail.com

unread,
Oct 4, 2016, 3:49:59 PM10/4/16
to MathJax Users
Hi

Is there a CSS way to inherit the CSS text-decoration property from the context (surrounding elements)?

<span class="underline">some text <span class="math">\(EG\)</span> and some other text</span>

The class underline is associated to the statement "text-decoration:underline". However, with my current config (TeX to HTML-CSS, inline math, version 2.6) the underline ist not visible for the formula (the rendered formula seems to overlay it).

This got me already closer (I got the idea from here: https://groups.google.com/forum/#!topic/mathjax-users/hs0ShgNvTqk/discussion):

"HTML-CSS": {
                            preferredFont
: "TeX",
                            styles
: {
                               
"span.underline .MathJax *":  {
                                   
"text-decoration": "underline"
                               
},
                               
"span.strike .MathJax *":  {
                                   
"text-decoration": "line-through"
                               
}
                           
}
                       
},

But now, every element inside .MathJax gets rendered as underlined or struck because of the * resulting in very thick strike-throughs or underlines which is ugly. Also this looks different in different browsers.

Is there a way to underline the formula as a whole or strike it through?

I also have cases, where only a part of the formula is struck through or underlined. But this works fine with the macros \underline or \enclose{horizontalstrike}.

Thx.

Peter Krautzberger

unread,
Oct 5, 2016, 4:33:00 AM10/5/16
to mathja...@googlegroups.com
Hi,

There's unfortunately not really a solution for this; not all CSS can be inherited right now. 

Most obviously, this won't work with SVG output (where text-decoration would simply not apply); the best chance would be the CommonHTML output (it is "simpler" than the HTML-CSS output), but even there, the inheritance is not really possible.

The "normal" way would be to solve this on the input end, (e.g., \underline{EG}) but a) that's probably not what you're after and b) it still won't look good since MathJax's output will be different enough for the underling not to match. For the CommonHTML, you could do something like \( \class{underline}{E}\class{underline}{G}\), but is messy and naturally can't work beyond simple cases (e.g., what to do with a fraction?)

This boils down to a fundamental question regarding math layout, i.e., how much should math layout be influenced by its surrounding context. One side of the argument would consider your case improper since it might change the meaning of the expression. Personally, I don't feel that way (resets are easy) but again there are obvious limitations.

In any case, for MathJax, it's currently mostly a technical limitation.

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.

tj.sch...@gmail.com

unread,
Oct 5, 2016, 9:00:18 AM10/5/16
to MathJax Users
Hi

Thank you very much for your answer.

Actually, I saw the same problem occurring with MathML.

We are working on a project that deals with historical math and we are transcribing early modern manuscripts that contain both text and math.
So there is no way of separating text and math completely from one another which brings in the issue of the context math appears in.

I thought about simply wrapping LaTeX-formulae that appear in a certain context inside a macro. You would not really need to put that in your LaTeX-source but could add that in an XSL-transformation (we use XML to record the source and some elements may contain LaTeX).

And you are right: the underline MathJax generates does not look the same as the underline the HTML context provides.

I am trying to better understand MathJax's HTML structure.

regards

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

Peter Krautzberger

unread,
Oct 5, 2016, 9:15:51 AM10/5/16
to mathja...@googlegroups.com
Hi Tobias,

Thanks for the background. Sounds quite interesting. I suspect you're going to run into many use cases that cannot be realized on the web today.

I am trying to better understand MathJax's HTML structure.

Generally speaking, that's a bad idea. Given the limitations of today's CSS, MathJax's output is highly convoluted which makes it not very amenable to hacks from the outside. It is also prone to change without notice (to adapt to the ever evolving browser ecosystem). And unless you prevent users from accessing alternative rendering options, your hack is likely fail on other output mechanisms.

I also forgot one other alternative -- border-bottom instead of text-decoration. That is only specific to the wrapper span and does not require interaction with MathJax. But math content might push the border away.

Regards,
Peter.


To unsubscribe from this group and stop receiving emails from it, send an email to mathjax-users+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages