Freigeben über


Equation Numbering Prototype

When writing the Math in Office 2010 post back in July, I could just imagine the disappointment various people would have when they discovered no mention of equation numbering. After getting math into PowerPoint, equation numbering had been the most often requested feature. Since PowerPoint 2010 now has the math facility, equation numbering has risen to the top of the wish list. Note that there is a way to display and manage equation numbering in Word as described in the work of Dong Yu. To get a feel for a native numbering facility, I implemented a prototype in RichEdit that interfaces to the underlying Page/TableServices (PTS) math handler’s equation numbering facility. This post describes that approach. It may not be the one we ship someday, but it does work pretty well. First I describe how equation numbers are represented in the file format and in memory and then consider equation number management.

 

The file format is one area a new feature has to consider. It would be nice not to change the file format for equation numbers, since it makes backward compatibility just that much harder to deal with. For example, it would be very convenient if equation numbers from a future version of Word would display reasonably well in Word 2010 or Word 2007, admittedly with small modifications to those versions. So I examined the nooks and crannies of the Office math format, OMML, for a math object that could be used to contain an equation number.

 

Lurking in that object space is a “no-op” phantom. To understand what this object is and why no one is likely to have used it, we need to know what a phantom object is. The phantom is characterized by five Boolean flags: 1) zero ascent, 2) zero descent, 3) zero width, 4) show, and 5) transparent. You can read about it in the post on MathML and Ecma Math (OMML) and in Sec. 3.17 of the linear format paper. The “zero” flags are handy for suppressing any combination of three object dimensions. Such suppression is called “smashing” by Donald Knuth. You can “smash” the descent of a character with a descender like y so that it has the same size as one without a descender like x. To facilitate entering smashes, we have the control words \asmash, \dsmash, and \hsmash to smash the ascent, descent, and width, respectively, of the phantom argument. Smashes have the show flag on, since the idea is to show the argument, but give it one or more zero dimensions. If you have the show flag off, you have a true phantom, in that space is taken up by the argument, but nothing is displayed. The fifth flag, the transparent flag, means that the argument is treated by the surrounding environment as if no object were there. So an equals sign inside a transparent phantom has math spacing appropriate for an equal sign outside a math object, apart from changes imposed by smashing various dimensions.

 

A no-op phantom is one that displays its argument as if the phantom weren’t even there: the argument has its true dimensions and it is transparent. Since the no-op phantom doesn’t serve any purpose, we might as well give it one: house an equation number. That works for the file format. Now let’s see how it works for actual display in a document.

 

The PTS math handler which ships with Office 2007 and Office 2010 has a number of callbacks for equation numbers. We just need to answer the questions appropriately and presto; the equation number will be displayed accordingly. To make sophisticated choices such as placing the numbers on the left hand side of equations instead of the right hand side, one needs to have some document properties. Ignoring such generality for the moment, we tell the PTS math handler to display the equation number flushed to the right on the last line of an equation. An equation may take up several lines and the PTS math handler can center the equation number vertically, if desired. Secondly, we place the no-op phantom as if it were an equation itself directly following the equation to be numbered. As such the no-op phantom is the only thing inside a soft paragraph, separated from its equation by a Shift+Enter (ASCII VT character). The PTS callbacks needed to be generalized slightly to deal with this special kind of “equation”, but it’s straightforward.

 

The last thing to consider is how to manage equation numbers, namely insert, delete, and edit them. Section 3.21 of the linear format paper explains how to type in an equation number, namely enter the equation followed by a # (U+0023) followed by the desired equation number text and type a [Shift]+Enter. The numbers can be edited in place. But underneath one needs renumbering and synchronization with inline equation number references. Such management could be accessed via a context-menu or math-zone acetate drop down menu. Insert and Delete would work with a single click and edit would open a dialog with options such as whether to include chapter and section numbers and whether the resulting entries should be separated by periods or hyphens. Word would likely treat the equation numbers as bookmarks so that links to them would automatically show the current number. Alternatively, the insert/delete/edit command handler could update all inline no-op phantoms to agree with the corresponding no-op phantoms inside math paragraphs.

 

MathML doesn’t have the concept of a math paragraph, but when embedded in a parent format, the math paragraph can be emulated fairly easily. Basically a math paragraph is just one or more math zones separated by soft paragraph breaks. So the equation number for a displayed MathML math zone (<math>…</math>) would follow the math zone. MathML has an <mphantom>, which suppresses the display of its argument, but keeps its size. Since we want to show equations numbers, <mphantom> isn’t useful for housing an equation number. <mpadded> has the other attributes of the OMML <phantom> except for transparent and if it just displays its argument with no changes, it could be used to house an equation number. In addition, it’s legal to add any attributes that one wants to a MathML element provided the attributes are in a private namespace, so one can be quite precise as far as a given family of implementations go. To be interoperable, MathML would have to add its own way of representing equation numbers, but hasn’t done so in MathML 2.0 or 3.0.

Comments

  • Anonymous
    October 15, 2009
    The comment has been removed

  • Anonymous
    October 16, 2009
    Just FYI, MathType does equation numbering and it works with all equation types: old Equation Editor, MathType, and Word 2007 OMML equations.

  • Anonymous
    October 18, 2009
    MathML would have to add its own way of representing equation numbers, The way MathML2 (and so far, MathML3) represent equation numbers is to use a one-row mtable and use mlabeledtr see the section "Equation numbering" at the following (for mathml2 and 3 respectively) http://www.w3.org/TR/MathML2/chapter3.html#id.3.5.3.3 http://www.w3.org/TR/MathML3/chapter3.html#id.3.5.3.3 MathML doesn't have any support for automatic numbering of equations throughout a document, as that depends heavily on the facility of the host document type.

  • Anonymous
    October 20, 2009
    Here is interesting alternative:   http://www.bakoma-tex.com/menu/download.php   But MS-Word is better :)

  • Anonymous
    November 24, 2009
    Ok, great, equation numbering is at the top of the list. But how is it reasonable, supposing that the next release of Office comes out in 2013, that we should have to wait 13 odd years to have such a trivial feature implemented as default? I mean, people have been asking for this for 10 years! Remember that Mathtype is a paid-for upgrade, where Equation Editor doesn't have this. And now that Word's native equations have usurped the (at least) upgradeable EqEd module, I find myself searching for work-arounds to allow me to put MathType back into Office 2010 beta. How many PhDs and Masters will go through in 13 years being told by their supervisors to use Latex? I've been promoting Word to my colleagues all along, but this is becoming distressing. I was convinced after finding the MS Research macros for adding numbering to 2007 that it would become native in 2010, but now I've lost hope again. And for that matter, I tested the Tech Preview, and the anti-aliasing bug for animated vector objects in Powerpoint is still there! and the MathType people, I know, have been complaining about that since at least Office 2000. Yup, 10 years plus to get a rendering bug fixed that makes the only reasonable solution to the equation numbering issue unacceptable in a product of the same family. I've seen ugly, blocky equations  from MathType in so many PPTs in so many conferences. And lastly, let's suppose we do finally get numbers with a bracket by 2013, then I'm guessing we'll still have only the one atypical modern math font to choose from. We need a classical math font, like Latex or MathType please. Thanks if you beared with me through that haranguing.

  • Anonymous
    November 24, 2009
    The comment has been removed

  • Anonymous
    November 25, 2009
    The comment has been removed

  • Anonymous
    November 25, 2009
    Manual Equation Numbering works in Excel 2010, OneNote 2010 and also PowerPoint 2010 (Beta)!!! Your equation must be "Display" not "Inline"! In Display Equation you must crete an "Equation array" (  eqarray ) and inside the array type your equation (e.q. E=mc^2) - so you have    eqarray(E=mc^2). After buildup array and equation, you must return cursor back into the equation array (behind your equation, e.q. E=mc^2, but "inside" the equation array) and type  #  or keyword   eqno. After that cursor automatically move to the right side of math paragraph and you can type there some text or manual number for your equation! - so your equation is centered and the equation number is on the right side of paragraph :-)   GOOD JOB FOR EXCEL, POWERPOINT AND ONENOTE!!! Unfortunatelly this manual equation numbering does not work in Word 2010 :-(   Now, equation buildup engine in Excel, PowerPoint and OneNote is better (more powerful) than equation buildup engine in Word :-(

  • Anonymous
    November 25, 2009
    ...and type  #  or keyword   eqno<space>....

  • Anonymous
    November 26, 2009
    I think that this way of equation numbering is good enough (even very good) for using in PowerPoint Presentation and OneNote :-) Yes, I know that it is described in Section 3.21 of UTN#28 - I have known it for a long time, since I have used Word 2007 - but in Word 2007/2010 it does not work :-( And moreover I always tried this manual equation numbering without using "equation array structure" (only   eqno alone), but unsuccesfully. But now I was very surprised when I see, that it works in Excel/PowerPoint/OneNote when I use equation array! :-) THANK  YOU  VERY  MUCH  FOR  THIS  NICE  AND  IMPORTANT  FEATURE!!! :-) It will be very useful in my school PowerPoint presentation. And I hope that one day you tell us step by step about all new  "math" things implemented in Word, Excel, PowerPoint and OneNote in this blog :-) I look forward to the next version of Unicode Technical Note.

  • Anonymous
    November 09, 2010
    The comment has been removed

  • Anonymous
    July 16, 2012
    I briefly looked around in Word 2013 Consumer Preview and at least couldn't find anything equation numbering related. Please don't tell us that we have to wait until Word 2016??

  • Anonymous
    July 17, 2012
    I installed the Preview of Office 2013, solely to check if there is quation numbering...i couldn't find anything either. Thats unfortunate.

  • Anonymous
    July 17, 2012
    The comment has been removed