{"id":377,"date":"2021-12-10T16:57:11","date_gmt":"2021-12-11T00:57:11","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/math-in-office\/?p=377"},"modified":"2021-12-10T16:58:07","modified_gmt":"2021-12-11T00:58:07","slug":"unicodemath-color","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/math-in-office\/unicodemath-color\/","title":{"rendered":"UnicodeMath Color"},"content":{"rendered":"<p>In slide presentations and elsewhere, it can be handy to have math text color and math background color. In fact, Presentation MathML has the <a href=\"https:\/\/www.w3.org\/TR\/MathML3\/chapter3.html#presm.commatt\">attributes<\/a> \u201cmathcolor\u201d and \u201cmathbackground\u201d. This post describes the operators Noah Doersing added to his <a href=\"https:\/\/github.com\/doersino\/UnicodeMathML\">UnicodeMathML<\/a> implementation to enter text and background color using UnicodeMath. I subsequently added them to the RichEdit math converters.<\/p>\n<p>Inputting math using UnicodeMath into Word and other applications typically doesn\u2019t require special text and background color syntax since these applications have user interfaces (UI) to color text. But UnicodeMath is a useful format for persisting math in files and in plain-text scenarios that don\u2019t have rich UI. I use UnicodeMath to represent math in many math tests because it\u2019s so much easier to input and read than MathML, LaTeX, RTF, and OMML. So, it\u2019s valuable to be able to include text coloring in UnicodeMath.<\/p>\n<p>Following the UnicodeMath tradition of using non-math UnicodeMath symbols to represent operations, Noah chose \u270e (U+270E) as the text color operator and \u2601 (U+2601) for background color. The syntax is like that for <em>n<\/em><sup>th<\/sup> root \\root(n&amp;x). For example, \u201ca+\u270e(red&amp;q^2)+\u2601(lime&amp;r^2)\u201d converts to OfficeMath in RichEdit as<\/p>\n<p style=\"text-align: center;\"><a href=\"https:\/\/devblogs.microsoft.com\/math-in-office\/wp-content\/uploads\/sites\/65\/2021\/12\/MathColor-e1639184052822.png\"><img decoding=\"async\" class=\"alignnone size-medium wp-image-379\" src=\"https:\/\/devblogs.microsoft.com\/math-in-office\/wp-content\/uploads\/sites\/65\/2021\/12\/MathColor-300x102.png\" alt=\"Image MathColor\" width=\"300\" height=\"102\" \/><\/a><\/p>\n<p>You can specify a color using the #RRGGBB or #RGB syntax or by the name of a standard HTML color (\u200faqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive, purple, red, silver, teal, white, yellow). We still need to implement the <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/tom\/nf-tom-itextfont-setforecolor\">ITextFont::SetForeColor<\/a>() and SetBackColor() methods in Word and OfficeArt to get the UnicodeMath color operators to work in Word, PowerPoint and Excel. The color operators work now in OneNote since OneNote uses RichEdit\u2019s TOM implementation.<\/p>\n<p>The TeX-like names for foreground and background color operators are \\color and \\backcolor, respectively. The latter is easier to enter with <a href=\"https:\/\/docs.microsoft.com\/en-us\/archive\/blogs\/murrays\/math-autocomplete\">math autocomplete<\/a>.<\/p>\n<p>Noah also added the delimiters \u2af7 and \u2af8 to hide text appearing inside the delimiters, and the monospace operator \uffd7 to use monospace characters within \uffd7(\u2026). I haven\u2019t added these to the RichEdit implementation yet. Also, we need an operator for the forthcoming MathML \u201cintent\u201d attribute, since UnicodeMath should be interoperable with Presentation MathML.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 \u201cmathcolor\u201d and \u201cmathbackground\u201d. 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 [&hellip;]<\/p>\n","protected":false},"author":40611,"featured_media":55,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-377","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-math-in-office"],"acf":[],"blog_post_summary":"<p>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 \u201cmathcolor\u201d and \u201cmathbackground\u201d. 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 [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/math-in-office\/wp-json\/wp\/v2\/posts\/377","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/math-in-office\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/math-in-office\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/math-in-office\/wp-json\/wp\/v2\/users\/40611"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/math-in-office\/wp-json\/wp\/v2\/comments?post=377"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/math-in-office\/wp-json\/wp\/v2\/posts\/377\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/math-in-office\/wp-json\/wp\/v2\/media\/55"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/math-in-office\/wp-json\/wp\/v2\/media?parent=377"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/math-in-office\/wp-json\/wp\/v2\/categories?post=377"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/math-in-office\/wp-json\/wp\/v2\/tags?post=377"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}