Previous Topic

Next Topic

Book Contents

Book Index

Line-breaking and Indentation

MathML 3 introduces significant control over line-breaking and indentation functionality. It also leaves some attributes unspecified by stating that the behavior should follow renderer-specific rules (thus having an "auto" value). The latest version of MathFlow allows you to control what happens when "auto" is used, along with additional line-breaking/indenting styles. Several of these attributes are based on the notion of an expression tree. In an expression such as

y = ax + b

the expression tree is either explicitly written into the MathML (via mrow nesting) or inferred based on the operators present or implicit (e.g., implicit multiplication). For the example above, the expression tree looks like this:

Expression tree

It's easy to see y is at depth 1 in the tree and a is at depth 3 The expression tree is used for automatic line-breaking and indentation.

Line-breaking

MathFlow has two styles of automatic line-breaking, both of which are controlled by the "linebreak" attribute.

linebreak="auto"

Lines are filled based on an algorithm that balances filling the line with keeping mathematical sub-expressions such as "ax + b" together on a line.

linebreak="dsi-linebreakop"

<mo>'s that have dsi:linebreakop="true" have special breaking behavior. Typically, relational symbols (such as "=") should be marked with dsi:linebreakop="true" in the operator dictionary. For the purposes of description, assume that all occurrences of "=" are marked as being dsi:linebreakop="true".

The behavior of line-breaking is as follows:

  1. If the expression fits on a line, it is not broken.
  2. The expression is broken on the second and subsequent occurrences of a "=". Typically linebreakstyle="before" so that the "=" starts the next line.
  3. If the part of the expression between "="'s is longer than what fits on a line, then "auto" line-breaking is used to break that part of the that expression.
  4. If the first occurrence of "=" is too far to the right (currently 30% of linewidth), then line will be broken before the first "=". If the part of the expression before the first "=" is longer than what fits on a line, then "auto" line-breaking is used to break that part of the expression.
  5. After a linebreak, the next line is indented.

Indenting

MF has two styles of automatic indenting, both of which are controlled by the "indentalign" attribute.

indentalign="auto"

The indentation is depth*dsi:indentamount. If this amount exceeds half of the line width, indentation is limited to half of the line width.

indentalign="dsi-linebreakop"

Typically used with linebreak="dsi-linebreakop" (refer to description above). For the purposes of description, assume that all occurrences of "=" are marked as being "dsi:linebreakop='true'".

The behavior of indentation is as follows:

  1. If some previous line contained an '=', then indent to the first '='. If this line does not start with an '=', indent an extra level of indentation.
  2. If no previous line contained an "=", then indent one level of indentation (the tree depth is not used). If this line does not start with an "=", indent an extra level of indentation.

Attribute Descriptions and Accepted Values

Attribute

Description

Values

dsi:linebreakop

Legal for <mo>, <mstyle>, <math>, but only sensible on <mo>. If true, the operator is used when linebreak="dsi-linebreakop" to control line-breaking behavior and when indentalign="dsi-linebreakop" to control indenting behavior. This attribute is typically set in the operator dictionary.

Boolean (default: false)

dsi:linebreakfillpenalty

Legal for <mo>, <mstyle>, <math>. It controls the relative amount of influence that keeping mathematical structure together should have versus how full a line should be. Smaller values favor keeping structure together on a line. Higher values favor filling the line.

A value between 0.0 and 1.0 (default: 0.2).

To fill as much as possible, use 1.0. To keep math structures together as much as possible, use 0.0.

dsi:indentamount

Legal for <mo>, <mstyle>, <math>. If the attribute indentalign="auto", MathFlow will indent based upon the depth of the expression in the expression tree at the point of the linebreak. The total amount of indentation is depth*dsi:indentamount. If this amount exceeds half of the line width, it is limited to half of the line width.

A dimensioned attr (eg, "0.83em"). Default 1.0em

Previous Topic

Next Topic

Book Contents

Book Index


[Design Science Home]
Copyright © 1996-2016 Design Science, Inc. All rights reserved.