Re: linebreaking mathml

Neil Soiffer wrote:
> 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
> MathPlayer.

Hmmm... I'll have to think that through.  Michael Downes' breqn
package exactly does use TeX's line breaking to do math, after some
heuristics to determine the shape of paragraph to fit it into.
I'd expected that with appropriate indentation implied by structure
(which breqn doesn't really do, tho' it creates a good illusion)
that you'd get less linear behavior, but at any rate....

> I think your best bet is to pester companies/implementers to fully
> implement MathML. 

I suppose I can, _some_ companies seem still willing to add that :>
So, is anybody listening?!?! :>

Even so, oughtn't Presentation MathML supply a means of marking
it up explicitly when one wants?

 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.

I'm looking forward to it.

> 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.

Personally, I prefer (3) and consider (1) and (2), when properly done,
to simply be cases of (3).

> 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.
> Try
> 
> <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.

Consider the formula:
  (a + (b + c + d + e + f + g) + h)
where each parenthesized expression is an mrow,
(and assume, for whatever reason, the above structure is desirable.)

If we want to break the internal mrow  after "d"
by converting it into an mtable, with your model (3) what we
want is:
  (a + (b + c + d
        + e + f + g) + h)
but with align="baseline 1", we'd get:
  (a + (b + c + d    + h)
        + e + f + g)

That is, on the left we'd want "baseline 1", but on the right "baseline 2".
Alternatively, if we flatten the rows and use a top level table we _can_ get
  (a + (b + c + d
   >>>  + e + f + g) + h
where ">>>" essentially has to be <mphantom>(a+(</mphantom> 

I guess I'd get a similar layout if, instead of mtable, I place
an <mspace linebreak="indentingnewline"/> after the d,
except that ">>>" could end up being anything.

> Neil Soiffer
> Senior Scientist
> Design Science, Inc.
> neils@dessci.com
> www.dessci.com
> ~ 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?
> 
> --
> bruce.miller@nist.gov
> http://math.nist.gov/~BMiller/
> 


-- 
"so it goes"
--
bruce.miller@nist.gov
http://math.nist.gov/~BMiller/

Received on Tuesday, 5 June 2007 20:39:45 UTC