Stacking symbols in html / unicode

104 views
Skip to first unread message

Benoit

unread,
Apr 13, 2020, 6:52:39 AM4/13/20
to Metamath
Many symbols used in math are obtained by stacking symbols.  For instance, an isomorphism is often denoted by an arrow with a tilde above it:

  $\overset{\sim}{\longrightarrow}$

Is there a simple way to display something close to it in HTML with unicode encoding ? This would fill the dots in

  althtmldef "isomorphism" as " ............. ";

Actually, I recently entered in set.mm the lines

  htmldef "-Set->" as " -Set-> ";
    althtmldef "-Set->" as " &#x27F6;<sub>Set</sub> ";
    latexdef "-Set->" as "\longrightarrow_{\mathrm{Set}}";

(see ~ df-bj-fset) but I would prefer to be able to display something close to:

  $\overset{\text{Set}}{\longrightarrow}$

Any ideas ?

Thanks,
Benoît

André L F S Bacci

unread,
Apr 13, 2020, 9:32:36 AM4/13/20
to meta...@googlegroups.com
This is a HTML abuse, but...

<ruby>&#x27F6;<rt style='font-size: 1rem;'>Set</big></ruby>

André 

André L F S Bacci

unread,
Apr 13, 2020, 9:45:09 AM4/13/20
to meta...@googlegroups.com
This is long, but somewhat modern and a bit less of abuse:

<div style='display: table; text-align: center;'>
<div style='display: table-row;'><div style='display: table-cell;'>Set</div></div>
<div style='display: table-row;'><div style='display: table-cell;'>&#x27F6;</div></div>
</div> 

André

Norman Megill

unread,
Apr 13, 2020, 9:50:58 AM4/13/20
to Metamath
On Monday, April 13, 2020 at 9:32:36 AM UTC-4, andrebacci.listas wrote:

Unfortunately we are currently using HTML 4.01 transitional, and <ruby> was added in HTML 5.  So it fails validator.w3.org:

Line 238, Column 26: element "RUBY" undefined


                    <ruby>&#x27F6;<rt style='font-size: 1rem;'>Set</big></ruby>

Norm

Benoit

unread,
Apr 13, 2020, 10:30:05 AM4/13/20
to Metamath
Thanks André.  Indeed, the <ruby> solution looks a bit abusive (not withstanding the fact that it is currently not supported, as Norm noted).  And the <div> solution looks a bit verbose.

Does unicode have negative spaces ?  An idea would be to mimic in unicode the following LaTeX code:

 $A \longrightarrow^{\!\!\!\!\!\!\!\!\!\!\text{Set}} B$

By the way, Norm: is upgrading to HTML 5 among your plans ?  I can't estimate how much work it would be (both for the pages generated by the metamath program and for the other pages, which can be done independently).  I'm not advocating always updating to the most recent version of anything, but HTML 5 is both more semantic and probably more future proof.

Benoît

Norman Megill

unread,
Apr 13, 2020, 12:29:01 PM4/13/20
to Metamath
On Monday, April 13, 2020 at 10:30:05 AM UTC-4, Benoit wrote:
By the way, Norm: is upgrading to HTML 5 among your plans ?  I can't estimate how much work it would be (both for the pages generated by the metamath program and for the other pages, which can be done independently).  I'm not advocating always updating to the most recent version of anything, but HTML 5 is both more semantic and probably more future proof.

There are currently no plans to do that.  It would be a big project.  I played with it several years ago, and it was difficult to get it to pass validation because of so many deprecated elements that would have to be moved to CSS among other things.  The main thing, though, is that I didn't see any HTML 5 feature that would offer an advantage for our pages, which are simple, clean, and fast loading.  It seemed like make-work without enough benefit to justify it.

(As an aside, it is very rare that I find a web page on other sites that isn't riddled with validation errors.  I've never understood why professional web developers tolerate this - imagine ignoring warnings from a compiler and depending on unpredictable code that might be generated.  Validation has found many mistakes in our pages like malformed hrefs that otherwise would have to wait until someone noticed them.)

As for future-proofing, I may be wrong, but I don't see any point in the future where HTML 4 would no longer be supported by browsers.  There are simply too many web pages using it.  Even if everyone converted, there are still historical pages on archive.org, intended to last "forever", that would become unreadable.  I would guess the amount of extra browser code to support HTML 4 isn't that great, and it is already written and mostly bug free.  So there is no reason to stop supporting it.

Norm

David A. Wheeler

unread,
Apr 13, 2020, 1:20:26 PM4/13/20
to Benoit, Metamath
Unicode has *some* of what you want.

Unicode has combining characters, see:
https://en.m.wikipedia.org/wiki/Combining_character

In some cases (primarily emoji) you can a zero width joiner (zwj):
https://stackoverflow.com/questions/52938779/combining-arbitrary-unicode-symbols-or-unicode-characters-with-negative-width
https://en.m.wikipedia.org/wiki/Zero-width_joiner


--- David A.Wheeler

Jens-Wolfhard Schicke-Uffmann

unread,
Apr 13, 2020, 4:26:24 PM4/13/20
to meta...@googlegroups.com
On Mon, Apr 13, 2020 at 07:30:05AM -0700, Benoit wrote:
> Does unicode have negative spaces ?  An idea would be to mimic in unicode the
> following LaTeX code:
>  $A \longrightarrow^{\!\!\!\!\!\!\!\!\!\!\text{Set}} B$

There are ways (e.g. with right-to-left marker), but it's pretty brittle as
suddenly the layout depends a lot on the exact widths of glyphs.

I'd rather look to \rlap of LaTeX: https://jsfiddle.net/1akxz47v/1/

<html>
<style>
.rlap {
overflow: visible;
width: 0px;
height: 0px;
display: inline-block;
}
.atop {
overflow: visible;
width: 0px;
height: 0px;
display: inline-block;
font-size: 70%;
position: relative;
top: -1.3ex;
}
</style>
<body>
<span class="rlap">abc</span>&#x27f6;
<span class="atop">abc</span>&#x27f6;
</body>
</html>


Still a pretty ugly hack, but as long as the font is specified exactly,
it should render consistently.


Regards,
Drahflow
signature.asc

Jon P

unread,
Apr 13, 2020, 6:05:59 PM4/13/20
to Metamath

Benoit

unread,
Apr 14, 2020, 6:37:57 AM4/14/20
to Metamath
Thanks to all.  I had looked at these pages on combining characters and zero-width, but I could not find a way to use them to suit my purpose.

For the moment, drahflow's solution looks best. Using a more compact form, I could write in set.mm

  althtmldef "-Set->" as " <span style="overflow: visible; width: 0px; height: 0px; display: inline-block; font-size: 70%; position: relative; top: -1.3ex;">Set</span>&#x27f6; ";

I'll give it a try and see if it passes Travis.

Benoît

David A. Wheeler

unread,
Apr 14, 2020, 10:33:50 AM4/14/20
to Benoit, Metamath
On April 14, 2020 6:37:57 AM EDT, Benoit <benoit...@gmail.com> wrote:
>For the moment, drahflow's solution looks best. Using a more compact
>form,
>I could write in set.mm
>
> althtmldef "-Set->" as " <span style="overflow: visible; width: 0px;
>height: 0px; display: inline-block; font-size: 70%; position: relative;
>top: -1.3ex;">Set</span>&#x27f6; ";

You have double quotes inside double quotes in there, so you may need to do some tweaking. But the basic approach seems sound.

--- David A.Wheeler

Jim Kingdon

unread,
Apr 14, 2020, 11:08:09 AM4/14/20
to meta...@googlegroups.com
On 4/14/20 3:37 AM, Benoit wrote:

>
>   althtmldef "-Set->" as " <span style="overflow: visible; width: 0px;
> height: 0px; display: inline-block; font-size: 70%; position:
> relative; top: -1.3ex;">Set</span>&#x27f6; ";
>
That seems like a good solution. The fancier the layout you are trying
to do, the greater the chance that the solution will need to be some
some flavor of style tags (rather than unicode having an answer or using
tags like SUP).


Reply all
Reply to author
Forward
0 new messages