Partilhar via


User Spaces in Math Zones

Spacing in mathematical expressions involves well defined rules. For example, in the expression a+b=c, a good math display engine automatically inserts 4/18 em on each side of the binary operator + and 5/18 em on each side of the relational operator =. Proper spacing between two characters depends on the properties of each character. Section 3.15 of the linear format paper summarizes the rules for the most common situations.

Users often realize that there should be extra spacing around operators but generally they don’t know how much and they don’t realize that a good display engine inserts the correct amount automatically. So they type in spaces thereby compromising the quality of the typography. This really upsets authors of fine math display engines like TeX and the engine used by Word 2007 and RichEdit. The authors of these engines prefer to ignore such user spacing altogether in order to reduce the user’s chances to create ugly typography that reflects badly on the layout program. The authors want to limit any user spacing to that entered explicitly using control words like \thinsp (\, in TeX). In fact, in TeX the ASCII space U+0020 is used only to terminate control words like \alpha. All other spaces are ignored.

In Word 2007 spaces are used to terminate control words or to build up expressions, but it seems unfriendly to categorically ignore all other spaces. In some scenarios, the space can even be used to control which kind of behavior a particular character may have. For example, the single number 10,100 is entered with no space following the comma, but the sequence 10, 100 has a space after the comma and means two numbers instead of one. (In TeX, it works the other way around: 10,100 displays as two numbers and 10{,}100 displays as one).

We did come up with a nice compromise to handle the knee-jerk tendency of some users to mess up the typography by sticking unnecessary space around binary and relational operators. Basically when a user types something like a<space>+<space>b, the autobuild up program checks to see if the layout engine would automatically insert space where the user has typed space. If so, the user space is deleted. The user can choose to go back and insert more space anyway, but the typical case looks essentially the same as the user expected and the results look great instead of embarrassing. Of course if the user navigates across the expression with left/right arrow keys, s/he can easily see that such spaces were deleted.

The moral of all this is that you shouldn’t type spaces into a math zone unless you’re building something up, choosing a different behavior for a character like comma, or because you really do need more space than that automatically provided by the math engine. It’s a lesson one needs to learn, much as people who used to use typewriters had to learn not to type the return key at the end of every line.

Comments