Math in Office

User, developer, and accessibility info on math editing/display in Microsoft Office and Windows. New features and specifications of the RichEdit editor. Getting OfficeMath onto web apps

Latest posts

It’s been so fine!
Apr 6, 2023
Post comments count 4
Post likes count 13

It’s been so fine!

Murray Sargent
Murray Sargent

TL;DR I’m 51₁₆ long past the usual retirement age. So, after more than 30 years working with super talented, fun people at the best software company in the world, I’m retiring from Microsoft 😊. Stephen Chua now owns Math in Office. It all started in 1988 when I had a summer job getting Microsoft’s CodeView debugger running in protected mode up out of the MS-DOS 640 KB address space. My SST debugger could load and run real-mode DOS programs in protected mode with access to all the memory on Intel 286 and 386 CPUs. It could also execute backwards, quite handy for debugging. CodeView was cool, but Windows 2.1 see...

Math Dictation
Apr 5, 2023
Post comments count 0
Post likes count 3

Math Dictation

Murray Sargent
Murray Sargent

You can dictate faster than you can write or type it, so math dictation can be handy for anyone working with math, notably on mobile devices. It can also make math more accessible. Math speech is similar to UnicodeMath, which you can use to enter equations into Word, PowerPoint, and other apps. Accordingly, we translate English math speech as recorded via Office dictation into UnicodeMath and build it up into OfficeMath. Currently we can dictate equations in English from algebra, trigonometry, and calculus into OneNote and PowerPoint. Examples of math dictation and the resulting OfficeMath are If you know ...

ITextDocument2 SetProperty and GetProperty
Mar 26, 2023
Post comments count 0
Post likes count 2

ITextDocument2 SetProperty and GetProperty

Murray Sargent
Murray Sargent

These methods allow programmers to set and get document properties for RichEdit controls. There is some documentation on the web, but more detail can be helpful and new properties have been added. This post describes the current set of properties except for the math properties, which are described in the post Default Document Math Properties.

Displaying Math in WordPress
Feb 27, 2023
Post comments count 0
Post likes count 0

Displaying Math in WordPress

Murray Sargent
Murray Sargent

The Microsoft devblogs are hosted by WordPress. Until recently, we haven’t been able to display equations using traditional math typography in our blogs except in images. Now we can embed LaTeX math which is a lot more accessible. One syntax for this is [ℒ]…[/ℒ], where the “…” has the desired LaTeX and the ℒ is the literal string “latex” (I can’t use the string “latex” itself since it would be interpreted as part of a LaTeX delimiter). Another syntax is "$ latex ...$" except leave out the space I added following the $ to prevent it from turning into LaTeX. On web pages viewed in FireFox and Safari as well as in t...

Math Speech Strings and Localization
Jan 28, 2023
Post comments count 1
Post likes count 1

Math Speech Strings and Localization

Murray Sargent
Murray Sargent

This post describes how OfficeMath speech is localized into multiple (~18) languages. The facility doesn’t handle all Unicode math symbols or all math notations. But it handles the most common symbols and notations. There are two tables that need to be translated into the supported languages: a Unicode math symbol speech table and a math function table. Unicode Math Symbol Speech Table To localize the speech for Unicode characters, perform a binary search by character code in the math symbol speech table for the desired language. The table for English follows. Notably missing are speech strings for U+002D ‘–‘, ...

Using RichEdit for Text Processing
Dec 31, 2022
Post comments count 1
Post likes count 5

Using RichEdit for Text Processing

Murray Sargent
Murray Sargent

Suppose you’re writing a program that needs to process rich text. You could write your own functions. Alternatively, you could have RichEdit do the processing. For example, you might want to search for mathematical expressions in an RTF or HTML file or convert text in one math format to another format. Or change the kind of list numbering. Or recognize URLs, telephone numbers, etc. These manipulations don’t need a display. This post describes how to create a RichEdit instance to do the processing. Load the RichEdit dll The first thing is to load the RichEdit dll. You can use the system \windows\system32\msftedi...

Default Math Properties
Nov 29, 2022
Post comments count 0
Post likes count 2

Default Math Properties

Murray Sargent
Murray Sargent

Quite a few math properties have document default values. These default values are used if you don’t override them, which you can do usually by invoking a math context-menu option or programmatically by calling the ITextDocument2::SetProperty or ITextDocument2::SetMathProperties methods. Most properties pertain to “displayed” math zones, that is, math zones that begin either at the start of the document or a hard/shift Enter (CR/VT) and end at the following hard/shift Enter. The options determine math indents and characteristics such as whether integral limits are positioned below and above the integral or as sub...

RichEdit Hyperlinks
Oct 29, 2022
Post comments count 2
Post likes count 3

RichEdit Hyperlinks

Murray Sargent
Murray Sargent

RichEdit has two kinds of hyperlinks: automatic hyperlinks (autoURLs) and friendly-name hyperlinks. As its name suggests, the autoURL is automatically recognized by RichEdit as a hyperlink and is displayed as a URL. A friendly name hyperlink has a name, which is displayed, and a hidden instruction part that contains the URL. This post describes these hyperlinks and explains how to manipulate them programmatically. The descriptions include some features that have been added recently. Automatic URLs The first autoURLs appeared in RichEdit 2.0, which shipped with Office 97, and have the usual web form, such as, ht...

Setting and Getting Text in Various Formats
Sep 29, 2022
Post comments count 1
Post likes count 1

Setting and Getting Text in Various Formats

Murray Sargent
Murray Sargent

You can get and set text from/into RichEdit in a variety of formats including RTF, HTML, MathML, OMML, UnicodeMath, Nemeth Braille, and speech. This post documents RichEdit options for a general way to access text using ITextRange2::SetText2(options, bstr) and ITextRange2::GetText2(options, pbstr). As such, this post is for programmers. All options work in the current Microsoft Office RichEdit (riched20.dll in an Office subdirectory) and many work in the Windows RichEdit (msftedit.dll). The options are defined in the following table in which s/g stands for SetText2/GetText2, respectively. Mutually exclusive op...

Computers I have known
Aug 29, 2022
Post comments count 0
Post likes count 5

Computers I have known

Murray Sargent
Murray Sargent

A friend recommended that since I got into computers a long time ago, I should post about how computers have changed over the years. Well, here goes a trip down memory lane! Analog and button pushing The first computer I ever used was an Electronics Associates analog computer at the Perkin Elmer Corporation where I worked as an intern in the summers of 1961—1963. I wired up the machines to simulate aspects of the response of control systems that guided the balloon-borne Stratoscope II telescope. The telescope could be pointed to an accuracy of 0.1 arc seconds, which is the angle subtended by a dime at two miles...

Microsoft 365 Modern Comments
Jul 26, 2022
Post comments count 1
Post likes count 3

Microsoft 365 Modern Comments

Murray Sargent
Murray Sargent

The new Modern Comments facility aims to give a similar commenting experience on the web and in native apps. On the desktop in Windows and the Mac, the editor component is RichEdit. The facility is a work in progress, and it is getting very nice. This post gives some background on incorporating RichEdit into the Microsoft 365 commenting experience. The most powerful commenting experience to date was in desktop Word, which used Word text boxes for comments. This allowed users to use most Word features in Word comments. Meanwhile, RichEdit lacks many advanced Word features. So, some Word power users have found t...

RichEdit Autoformatting
Jun 29, 2022
Post comments count 0
Post likes count 1

RichEdit Autoformatting

Murray Sargent
Murray Sargent

RichEdit and Word have had the most elaborate autoformatting ever since Office 2007, namely math formula auto-buildup. A UnicodeMath expression builds up into OfficeMath as soon as it is unambiguous. Word and other programs have also had less ambitious autoformatting since late in the last century. Such functionality includes auto conversion of some simple numeric fractions to composed Unicode numeric fractions, e.g., 1/2 to ½, ordinal superscripts, e.g., 1st to 1st, double dash to long dash, e.g., ab to a—b, smart quotes, e.g., to “word”, and automatic bulleted/numbered lists. Such autoformatting is available i...

Rounded Rectangles and Ellipses
May 22, 2022
Post comments count 0
Post likes count 2

Rounded Rectangles and Ellipses

Murray Sargent
Murray Sargent

In Word, PowerPoint, OneNote and RichEdit, you can enclose text in a rectangle by putting the text into a math “boxed formula” object. To try this out, type alt+= to enter a math zone and then \rect(a+b)<space>. This displays as as The “\rect(a+b)” is the UnicodeMath representation of this boxed formula. In MathML, the boxed formula object is represented by the <menclose notation=”box”> element. The <menclose> documentation mentions other notations as well, notably “roundedbox” and “circle” (which is actually an ellipse). Up through Office 2013, only the “box” option, along with hiding sides an...

OfficeMath
Apr 28, 2022
Post comments count 0
Post likes count 1

OfficeMath

Murray Sargent
Murray Sargent

Microsoft Word 2007 and RichEdit 6.0 introduced the native Office math facility. PowerPoint, Excel, and OneNote followed suit in 2010, and Mac Word followed in 2011. But ironically the native math facility didn’t have a recognizable name. “Microsoft Equation Editor” (MEE) seemed natural, but that's the name of the Design Science math editor that shipped first in Office on Windows and the Mac in 1992 and was discontinued due to security problems. In fact, the post Converting Microsoft Equation Editor Objects to OfficeMath needed a name for the native math facility since it describes how you can convert MEE OLE mat...

Two Phonetic Scripts: Vietnamese and Korean
Mar 2, 2022
Post comments count 3
Post likes count 0

Two Phonetic Scripts: Vietnamese and Korean

Murray Sargent
Murray Sargent

A few years ago, I visited two very interesting countries, Vietnam and South Korea. Being actively involved in writing software (mostly RichEdit) for editing the world’s scripts, I was naturally fascinated to see Vietnamese and Korean text displayed in profusion. The Vietnamese and Korean scripts were designed with a common purpose in mind: enable the languages to be read and written easily by all members of their respective countries. Earlier on, people tried to write Vietnamese and Korean by customizing the Chinese script. But while the Chinese script is well suited to Chinese languages, it’s considerably less ...

Windows 11 Notepad
Feb 22, 2022
Post comments count 55
Post likes count 1

Windows 11 Notepad

Murray Sargent
Murray Sargent

The new Windows 11 Notepad uses RichEdit and runs on up-to-date Windows 11 installations. In addition to a Windows 11 look with rounded corners and a dark-theme option, the new Notepad includes several standard RichEdit editing enhancements, such as Alt+x for entering Unicode characters, Ctrl+} for toggling between matching brackets/parentheses, multilevel undo, drag & drop, color emoji, and autoURL detection. You might guess that using a RichEdit plain-text control in Notepad would be a slam dunk. RichEdit has had plain-text controls ever since Office 97 (last century!) and they’ve been used myriad times. Bu...

Function to get Unicode Fractions
Jan 22, 2022
Post comments count 5
Post likes count 1

Function to get Unicode Fractions

Murray Sargent
Murray Sargent

Do you know that Unicode includes the fraction characters ↉ ½ ⅓ ¼ ⅕ ⅙ ⅐ ⅛ ⅑ ⅒ ⅔ ⅖ ¾ ⅗ ⅜ ⅘ ⅚ ⅞? Well thanks to existing character standards, ½ ⅓ ¼ ⅕ ⅙ ⅛ ⅔ ⅖ ¾ ⅗ ⅜ ⅘ ⅚ ⅞ were added in Unicode 1.1 in 1993, and ↉ ⅐ ⅑ ⅒ were added in Unicode 5.2 in 2009. Programs like Microsoft Word have an “Autoformat as you type” option to convert the linear fractions 1/2, 1/3, 1/4, and 3/4 into the corresponding Unicode fraction ½ ⅓ ¼ and ¾. This post gives a simple C++ function that converts the linear form of all Unicode fractions into the Unicode fraction characters. The function is relatively easy to read and understand, at lea...

UnicodeMath Color
Dec 10, 2021
Post comments count 1
Post likes count 1

UnicodeMath Color

Murray Sargent
Murray Sargent

In slide presentations and elsewhere, it can be handy to have math text color and math background color. In fact, Presentation MathML has the attributes “mathcolor” and “mathbackground”. This post describes the operators Noah Doersing added to his UnicodeMathML implementation to enter text and background color using UnicodeMath. I subsequently added them to the RichEdit math converters. Inputting math using UnicodeMath into Word and other applications typically doesn’t require special text and background color syntax since these applications have user interfaces (UI) to color text. But UnicodeMath is a useful ...