W3C home > Mailing lists > Public > www-math@w3.org > June 2007

RE: linebreaking mathml

From: Neil Soiffer <neils@dessci.com>
Date: Tue, 5 Jun 2007 10:36:44 -0700
Message-ID: <D1EFB337111B674B8F1BE155B01C6DD601EAD7A0@franklin.corp.dessci>
To: "Bruce Miller" <bruce.miller@nist.gov>, <www-math@w3.org>

Funny you should mention line breaking MathML -- I just added support
for it to MathPlayer last week. I can't say when a new release of
MathPlayer will happen, but when it does, it will do automatic and
forced line breaks.

The algorithm for linebreaking, even "optimal" line breaking (aka TeX's
*text* line breaking) is only slightly greater than linear (it's a
function of line width and number of "words").  The time it takes to
line break a math expression is not a problem.  If you have Mathematica,
which does optimal line breaking of its output, you can change the
window width and watch it re-line break multi-screen long expressions in
real time.  The same is true for the line breaking I've added to

I think your best bet is to pester companies/implementers to fully
implement MathML.  Letting the browser do the line breaking is really
the right way to go.  Hopefully you'll be pleased with the line breaking
that I've added to MathPlayer once it sees the light of day.

Onto some of your comments...

> The first strategy I found is to insert
>  <m:mspace linebreak="newline"/>
> Or even better, linebreak="indentingnewline", although the spec
doesn't (yet ! :> ) indicate what it should indent _to_  (a fixed
amount, to the begin of the containing row, something else ? ).

The spec is very silent on indenting.  I thought it was because when
linebreaking got moved to mspace (it used to be specified by &LineBreak;
character or some such name), the text got omitted.  However, it was not
really specified in the earlier versions of MathML either.

There are various kinds of indenting that are used in practice:
1.  indenting that matches the same "operator" on the previous line.
Eg, aligning "="s.  If a "=" line is too long, then the next line indent
further than the "="s.
2.  indenting that keeps the insides of parens to the right of the
opening paren
3.  indenting that tries to make clear the relationship of the current
line's nesting depth to other lines (ie, tries to make it obvious that a
line is more or less deeply nested than another line

The first form of indenting is pretty common in textbooks, with the
caveat that the second line is only "arbitrarily" indented (since it
would be the first occurrence of a "=" sign.  The third form will
typically mimic the first one because the operators (eg, "=") will be at
the same nesting depth.

The second form is nice *if* the open paren is near the left side of the
screen.  If not, it wastes a lot of space.

Both the first and third option don't say how much to indent.  For the
first option, this matters for the second line -- the remainder of the
lines, they will follow that indentation.  Perhaps mspace should specify
this (IndentPerLevel), and allow it on mstyle so it can be inherited.

> ...[comments on aligning mtable]

mtable does allow you to align the first row of the table with the
surrounding baseline.  In fact, your suggestion is nearly what is legal.

<mtable align='baseline 1'> ... </mtable>

I'm unclear about what you mean about "align with the last row" when you
also want alignment with the first line.  I'm clearly missing some
'bigger picture' context.

Neil Soiffer
Senior Scientist
Design Science, Inc.
~ Makers of Equation Editor, MathType, MathPlayer and MathFlow ~

-----Original Message-----
From: www-math-request@w3.org [mailto:www-math-request@w3.org] On Behalf
Of Bruce Miller
Sent: Monday, June 04, 2007 10:50 PM
To: www-math@w3.org
Subject: linebreaking mathml

Hi all;
  I suppose that when MathML was originally developed, the authors
imagined that the browser would be responsible for line breaking.  After
all, it _does_ seem like the right place; who else knows the font sizes,
window width and such?
  Alas, apparently linebreaking is a bit too demanding for real time;
rendering MathML is slow enough as it is.
Mozillae will linebreak only at the topmost level, under very limiting
circumstances.  I haven't (re)checked exactly what MathPlayer does.

So, I set out to pre-linebreak my mathml to at least a not-unreasonable
width, and started looking for the right markup bits (we're talking
presentation MathML here).

The first strategy I found is to insert
  <m:mspace linebreak="newline"/>
Or even better, linebreak="indentingnewline", although the spec doesn't
(yet ! :> ) indicate what it should indent _to_  (a fixed amount, to the
begin of the containing row, something else ? ).
Unfortunately, Mozilla doesn't implement that.

OK, second strategy: split a row into rows of an mtable. Which almost
works, but the align attribute of mtable seems to miss a useful value
for this case.  Namely, I would like to align the table so that the 1st
row's baseline aligns with the baseline of material on the left (like
align="baseline1" ).
However, I would like the following material to align with the last row
(like align="baseline<n>" ).
Like this:
   a + (b + c + d
         + e + f + g) + h

Lacking that, I've got to assure that the broken mrow is the last on
it's line (move the "+ h" to the next line), and/or be very careful (&
somewhat contrived) when nesting mrows.

Would such an alignment value be useful?
(and would it ever be implemented? )

Or have I overlooked a better linebreaking strategy?

Received on Tuesday, 5 June 2007 17:36:40 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:27:39 UTC