Representation of fractions with a solidus

326 views
Skip to first unread message

J.R.St...@physics.org

unread,
Sep 19, 2012, 5:57:23 AM9/19/12
to mathja...@googlegroups.com
I have searched "TEX Commands available in MathJax" without finding any instance of the representation of fractions with a solidus.  It is often useful to be able to write 1/2(a+b+c) rather than (a+b+c)/2, where 1/2 is a single character with the same width as a digit, and with height contained within that of one of the words ram, cat, or dog.  It can be done approximately with something like ^1\!\!\!\!\not\,\,_2 or ^1\!\!/\!_2 and those could be named using \def.

But I think that it would be better as part of the language proper as illustrated by Carol's List, so that 1/2 could be written as (say) \fras12, giving a well-designed 1/2.   No consideration need be given to arguments which are not single digits, unless it is reasonably simple to allow for numerator or denominator in the range 10-19 - after all, 1 is visually thin.
  Code such as \fras{rhubarb}{custard} would, I suppose, then do something like ^{rhubarb}/_{custard}, but slightly squashed.


Aside : In Chrome, my default font size, characters resembling ]sometimes have their upper bar zero pixels thick - can be seen in the List, for example in \atopwithdelims.
-- 
  (c) John Stockton, near London, UK.  Using Google, no spell-check.
 Mail: J.R.""""""""@physics.org or (better) via Home Page at
 Web:  <http://www.merlyn.demon.co.uk/> (may move soon)
 FAQish topics, acronyms, links, etc.; Date, Lagrange, JavaScript, ..|

David Carlisle

unread,
Sep 19, 2012, 6:09:33 AM9/19/12
to mathja...@googlegroups.com
On 19 September 2012 10:57, <J.R.St...@physics.org> wrote:
> I have searched "TEX Commands available in MathJax" without finding any
> instance of the representation of fractions with a solidus. It is often
> useful to be able to write 1/2(a+b+c) rather than (a+b+c)/2, where 1/2 is a
> single character with the same width as a digit, and with height contained
> within that of one of the words ram, cat, or dog. It can be done
> approximately with something like ^1\!\!\!\!\not\,\,_2 or ^1\!\!/\!_2 and




In mathml you have three choices

horizontal line:
<mfrac><mn>1</mn><mn>2</mn></mfrac>

sloping line with raised and kerned 1
<mfrac bevelled="true"><mn>1</mn><mn>2</mn></mfrac>

and possibly closest to what you ask
<mn>&#189;</mn> (or <mn>&frac12;</mn>)
the half character in the font being used (unicode VULGAR FRACTION ONE HALF)

J.R.St...@physics.org

unread,
Sep 19, 2012, 8:45:40 AM9/19/12
to mathja...@googlegroups.com

Yes, but the first two are long and would be used with \def, and the third way only allows some of the possible "simple fractions".  Also, it looks slightly weird to have an "HTML font" 'one-half' character at the end of a "MathJax font" number, e.g., quoting my second transcription of Euler,  \zeta=86^\circ53&frac12;'. I think that it would be used sufficiently often to justify implementing it as, say, \fras.  But you are the expert.

Is there a description of MathML suitable for one with decades of experience of computer use but only three mornings of formal computer training  (covering the Algol 60 Report)?  So far, I've only found W3 standards, and sophomore-type material.

David Carlisle

unread,
Sep 19, 2012, 12:39:01 PM9/19/12
to mathja...@googlegroups.com
On 19 September 2012 13:45, <J.R.St...@physics.org> wrote:

>>
>>
>>
>>
>> In mathml you have three choices
>>
>> horizontal line:
>> <mfrac><mn>1</mn><mn>2</mn></mfrac>
>>
>> sloping line with raised and kerned 1
>> <mfrac bevelled="true"><mn>1</mn><mn>2</mn></mfrac>
>>
>> and possibly closest to what you ask
>> <mn>&#189;</mn> (or <mn>&frac12;</mn>)
>> the half character in the font being used (unicode VULGAR FRACTION ONE
>> HALF)
>
>
> Yes, but the first two are long and would be used with \def, and the third
> way only allows some of the possible "simple fractions".

Yes, personally I'd use the first form, perhaps just scaling down the
font size a bit, so in tex

{\scriptstyle \frac{1}{2}}

for example.



> Also, it looks
> slightly weird to have an "HTML font" 'one-half' character at the end of a
> "MathJax font" number,

Haven't checked what mathjax does in this case but there is no
particular reason to suppose the half character comes from a different
front than the full digits.

> e.g., quoting my second transcription of Euler,
> \zeta=86^\circ53&frac12;'. I think that it would be used sufficiently often
> to justify implementing it as, say, \fras


Well it would look more natural in TeX to enter the characer directly
or use \unicode{189} or something I agree.

> But you are the expert.
>
> Is there a description of MathML suitable for one with decades of experience
> of computer use but only three mornings of formal computer training
> (covering the Algol 60 Report)? So far, I've only found W3 standards, and
> sophomore-type material.
>

We did try to make the MathML spec a pleasant read:-) (You'd only need
to read chapters 2 and 3 for the present purposes).

There is http://www.dessci.com/en/reference/mathml/default.htm which
covered MathML2 but maybe that an example of the kind of basic
tutorial that you didn't want...

David

Davide P. Cervone

unread,
Sep 20, 2012, 6:30:03 AM9/20/12
to mathja...@googlegroups.com
>> Also, it looks
>> slightly weird to have an "HTML font" 'one-half' character at the
>> end of a
>> "MathJax font" number,
>
> Haven't checked what mathjax does in this case but there is no
> particular reason to suppose the half character comes from a different
> front than the full digits.

The MathJax web fonts don't include the fraction glyphs, so if you use
them, MathJax will simply insert unicode references for them, and hope
the browser can find them in some other font. So John is right that
the most likely case is to see the fraction in a different font. For
those who have STIX fonts installed, they will get the ones from the
STIX font, and that will look consistent.

Davide

Davide P. Cervone

unread,
Sep 20, 2012, 6:34:59 AM9/20/12
to mathja...@googlegroups.com
horizontal line:
<mfrac><mn>1</mn><mn>2</mn></mfrac>

sloping line with raised and kerned 1
<mfrac bevelled="true"><mn>1</mn><mn>2</mn></mfrac>

and possibly closest to what you ask
<mn>&#189;</mn>  (or <mn>&frac12;</mn>)
the half character in the font being used (unicode VULGAR FRACTION ONE HALF)

MathJax doesn't have method to specify the bevelled attribute on mfrac directly from TeX, but you could define your own macro that would accomplish that.  For example

<html>
<head>
<title>Add Bevelled Fraction Macro</title>
<script type="text/x-mathjax-config">
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
  var MML = MathJax.ElementJax.mml,
      TEX = MathJax.InputJax.TeX;
  TEX.Definitions.macros.bfrac = "myBevelFraction";
  TEX.Parse.Augment({
    myBevelFraction: function (name) {
      var num = this.ParseArg(name),
          den = this.ParseArg(name);
      this.Push(MML.mfrac(num,den).With({bevelled: true}));
    }
  });
});
</script>
<script type="text/javascript"
  src="../MathJax/unpacked/MathJax.js?config=TeX-AMS_HTML">
</script>
</head>
<body>
<p>A bevelled fraction: \(\bfrac{1}{2}\)</p>
</body>
</html>

adds a \bfrac macro that you can use to get a bevelled fraction.  The spacing will be better than trying to use \! and super and subscripts to manage it by hand.

Davide

J.R.St...@physics.org

unread,
Sep 20, 2012, 7:12:28 AM9/20/12
to mathja...@googlegroups.com


On Wednesday, September 19, 2012 5:39:02 PM UTC+1, DavidC wrote:
On 19 September 2012 13:45,  <J.R.St...@physics.org> wrote:
 
> Yes, but the first two are long and would be used with \def, and the third
> way only allows some of the possible "simple fractions".

Yes, personally I'd use the first form, perhaps just scaling down the
font size a bit, so in tex

{\scriptstyle \frac{1}{2}}

for example.
 
That gives 1 over minus over 2, which is not what I am suggesting.  My 1 over solidus over 2 allows larger digits in the same overall size.


 
>  Also, it looks
> slightly weird to have an "HTML font" 'one-half' character at the end of a
> "MathJax font" number,

Haven't checked what mathjax does in this case but there is no
particular reason to suppose the half character comes from a different
front than the full digits.

I was writing in the knowledge of what it does do, in one or two browsers.  Attached, what it does in 5 browsers, all latest public full release for WinXP sp3.


>  e.g., quoting my second transcription of Euler,
> \zeta=86^\circ53&frac12;'. I think that it would be used sufficiently often
> to justify implementing it as, say, \fras


Well it would look more natural in TeX to enter the characer directly
or use \unicode{189} or something I agree.

That would do for 1/2 , but I am suggesting something for the full range from 0/0 to 9/9 or 19/19, guaranteed to match the font-face which would be used for digits 0-9 and to fit in the same bounding-box, and to use a solidus style so that the digits could be as large as possible - and, hopefully, looking just about right.

My example, of in-line maths, could of course be done well in pure HTML; but its style would then differ from that of other in-line maths.

>   But you are the expert.
 
Maybe not - I'm not sure whether DavidC is or is not also David Cervone - and I don't want to have to remember that.
 
> Is there a description of MathML suitable for one with decades of experience
> of computer use but only three mornings of formal computer training
> (covering the Algol 60 Report)?  So far, I've only found W3 standards, and
> sophomore-type material.

We did try to make the MathML spec a pleasant read:-) (You'd only need
to read chapters 2 and 3 for the present purposes).

NO W3 spec is a pleasant read.  They are no doubt excellent for implementors; but normal people need to memorise the whole of a standard and then work out the full consequences before attaining adequate understanding of the whole.


 
There is http://www.dessci.com/en/reference/mathml/default.htm  which
covered MathML2 but maybe that an example of  the kind of basic
tutorial that you didn't want...

It looks useful (link noted) - but why do they impose a font face and size different from my selected preference?  That's mindless arrogance.
untitled.PNG

Davide P. Cervone

unread,
Sep 20, 2012, 7:50:50 AM9/20/12
to mathja...@googlegroups.com
> > But you are the expert.
>
> Maybe not - I'm not sure whether DavidC is or is not also David
> Cervone - and I don't want to have to remember that.

DavidC is David Carlisle, and he very much IS the expert on MathML.
Certainly more so than I. And my name is "Davide Cervone" (note the
"e" on my first name). I'm sorry our names are a source of confusion
for you, but we are different people. Note that David Carlisle signs
"David" while I sign "Davide". Perhaps that can help you keep us
straight.

Davide

William F Hammond

unread,
Sep 20, 2012, 10:25:57 AM9/20/12
to mathja...@googlegroups.com
Note to Davide:

Consistent with gellmu the insertion of an attribute with values on a
command in generalized LaTeX is done with a first argument delimited
by brackets inside which the first character is a colon. Thus,

\frac[:bevelled="true"]{1}{2}

Of course, prior to that one can do

\newcommand{\bfrac}[2]{\frac[:bevelled="true"]{#1}{#2}}

(And I should get around to adding "bevelled" as an attribute to frac
in the gellmu
didactic production system. But what is the going preferred way to
render bevelled
fractions in regular LaTeX?)

-- Bill

--
William F Hammond
http://www.albany.edu/~hammond/
Email: gel...@gmail.com

Davide P. Cervone

unread,
Sep 20, 2012, 10:46:59 AM9/20/12
to mathja...@googlegroups.com
> Consistent with gellmu the insertion of an attribute with values on a
> command in generalized LaTeX is done with a first argument delimited
> by brackets inside which the first character is a colon. Thus,
>
> \frac[:bevelled="true"]{1}{2}
>
> Of course, prior to that one can do
>
> \newcommand{\bfrac}[2]{\frac[:bevelled="true"]{#1}{#2}}

MathJax doesn't currently provide this functionality.

> (And I should get around to adding "bevelled" as an attribute to frac
> in the gellmu didactic production system. But what is the going
> preferred
> way to render bevelled fractions in regular LaTeX?)

I don't know of one. A quick Google search suggests the "nicefrac"
package (which might be part of "units" package?), but I've never used
it. It doesn't seem that there is an accepted standard for this at
the moment.

Davide

David Carlisle

unread,
Sep 20, 2012, 2:25:34 PM9/20/12
to mathja...@googlegroups.com
On 20 September 2012 12:12, <J.R.St...@physics.org> wrote:

>> Yes, personally I'd use the first form, perhaps just scaling down the
>> font size a bit, so in tex
>>
>> {\scriptstyle \frac{1}{2}}
>>
>> for example.
>
>
> That gives 1 over minus over 2, which is not what I am suggesting. My 1
> over solidus over 2 allows larger digits in the same overall size.

Yes I know. That's why I said that was the form I would use. the
1/2(x+y) form has a danger of looking like 1/(2(x+y)) however mfrac
bevelled is the way to get the slash form, and Davide (with an e) has
shown how to add a TeX syntax for that if you are using TeX rather
than mathml input syntax.
>
>
>>
>> > Also, it looks
>> > slightly weird to have an "HTML font" 'one-half' character at the end of
>> > a
>> > "MathJax font" number,
>>
>> Haven't checked what mathjax does in this case but there is no
>> particular reason to suppose the half character comes from a different
>> front than the full digits.
>
>
> I was writing in the knowledge of what it does do, in one or two browsers.
> Attached, what it does in 5 browsers, all latest public full release for
> WinXP sp3.

As Davide noted it depends on which font you are using more than which browser.
the stix fonts have the fraction characters. (I wouldn't really
recommend them for mathematical use anyway I just gave them to
complete the list of options in MathML.
>
>
.
>
>
> NO W3 spec is a pleasant read.

That's a sweeping statement. Different specs are written by different
people for different purposes.
The MathML spec is (more than most) targeted as much or perhaps more
at the user rather than the MathML implementer.
I leave it for others to say how successful it is in that regard, but
that is the intention.


>> There is http://www.dessci.com/en/reference/mathml/default.htm which
>> covered MathML2 but maybe that an example of the kind of basic
>> tutorial that you didn't want...
>
>
> It looks useful (link noted) - but why do they impose a font face and size
> different from my selected preference? That's mindless arrogance.

Well the main author of that paper died, so it's not an answerable question.
>


David (without an e)

J.R.St...@physics.org

unread,
Sep 20, 2012, 2:32:44 PM9/20/12
to mathja...@googlegroups.com

Apologies for the missing "e".

The maths in  <http://www.merlyn.demon.co.uk/euler304.htm>  has come out nicely (though I could do some more alignment).
If any of the buttons above the main bilingual text is pressed, a new layout appears in a new tab or window, in which the maths looks largely good but different.  The square and cube roots, however, are less good.  That, there, is of no importance to me; I only mention it as something that you might wish to fix.  The buttons just take the innerHTML of the main table cells and push it into an array, which is then joined for display. Evidently some form of MathJax is carried over.

The important problems lie in the translation of Euler's Latin to Standard English to Astronomers' English, which another group is
helping with - and in debugging the transcription in the first column.

Regards,

J.R.St...@physics.org

unread,
Sep 21, 2012, 8:26:16 AM9/21/12
to mathja...@googlegroups.com
On Thursday, September 20, 2012 7:25:35 PM UTC+1, DavidC wrote:
On 20 September 2012 12:12,  <J.R.St...@physics.org> wrote:

 
> That gives 1 over minus over 2, which is not what I am suggesting.  My 1
> over solidus over 2 allows larger digits in the same overall size.

Yes I know. That's why I said that was the form I would use. the
1/2(x+y) form has a danger of looking like 1/(2(x+y))  however mfrac
bevelled is the way to get the slash form, and Davide (with an e) has
shown how to add a TeX syntax for that if you are using TeX rather
than mathml input syntax.

As I indicated in the first paragraph of my opening article, the three-character "1/2"  in this thread is a mere coarse representation of what I am suggesting, which is something sized as a single character with a "1" in its NW quadrant, a "2" in its SE quadrant, and a variety of "/" in between.  With that, there is no ambiguity.  I also gave two possible TeX representations, which in the tester in Carol's List gives an appearance like what I am suggesting would be useful, but inplemented by an inebriated or hung-over font designer.  The first of those failed in the actual page (use of unavailable character).  The second, reduced, as \small{^1\!\!/\!_2}, is good enough for use, tested in 5 browsers.

I was not asking how to do it; I was suggesting that introducing to the MathJax TeX language \fras{}{} (or other name) might well be popular.  Whether it is worthwhile is a matter of how much effort it would take to implement it well, and how often it would actually be used ; I am not able to judge those.




As Davide noted it depends on which font you are using more than which browser.
the stix fonts have the fraction characters. (I wouldn't really
recommend them for mathematical use anyway I just gave them to
complete the list of options in MathML.

I use the browser's defaults, as set or accepted by the reader; and MathJax's defaults.

> NO W3 spec is a pleasant read.

That's a sweeping statement. ...

Perhaps you may be mollified if I ask that the "W3" be disregarded, and say that in using "pleasant" I have the standards of "Huntingtower" and/or "The Thirteen-Gun Salute", chapter 7, final third, in mind?
Reply all
Reply to author
Forward
0 new messages