4
$\begingroup$

When I create an equation in MS Office, it uses Cambria Math, and I get the following when I use variable 'a'.

enter image description here

When I try to use Mathematica to create graphics for my files, I can try to use Text[] with Style["a",{Large,"Graphics"}] and it gives the following.

enter image description here

Well, that's no good. Let me use the same Font Face, so things look consistent.
Style["a",{Large,"Graphics",FontFamily -> "Cambria Math"}] gives:

enter image description here

Uhhhhhh.... I get that Mathematica uses this archaic style for the letter a, but how do I tell it to give me the same thing one would expect from using the same font face in two different places?


Edit: I turned off italic in the MS Office equation environment and it reverted from the script style to the antique style, so I tried turning on Italic in Mathematica, but that didn't work.
Style["a", {Large, Italic, "Graphics", FontFamily -> "Cambria Math"}]

enter image description here

$\endgroup$
3
  • 2
    $\begingroup$ MS Office clearly uses the italic version. Try this: Style[..., {FontSlant -> Italic, FontFamily -> "Cambria"}] You can also try using "Times" to make it swoopier. I like "Times" as a math font if I don't have the CMU fonts. $\endgroup$
    – b3m2a1
    Commented Mar 20, 2019 at 21:31
  • 1
    $\begingroup$ I don't think Mathematica is finding (or using) the correct font when you specify "Cambria Math" $\endgroup$
    – chuy
    Commented Mar 20, 2019 at 21:54
  • $\begingroup$ Looking at the fonts on my system, I don't see an italic version of CM. I wonder then, when I ask for CM Italic, if MS Office is using Cambria Italic and Mathematica is going with some other fallback. Edit: Nope. Cambria Italic looks slightly different than what the MS equation environment is giving. $\endgroup$ Commented Mar 20, 2019 at 23:26

2 Answers 2

3
$\begingroup$

When I look up Cambria Math on the web, it has a double-storey a, not a single-storey ɑ, for the regular letter "a." In my Mathematica (MacOS), there is no Cambria Math in $FontFamilies. Hacking MS Word file failed to reveal anything to me. So it's hard for me to check, but the following seems likely: The character being used is probably from the Mathematical Alphanumeric Symbols, Unicode 1D44E (MATHEMATICAL ITALIC SMALL A): 𝑎.

You can get it in Mathematica:

mathA = FromCharacterCode[{16^^1D44E}, "Unicode"]

Mathematica graphics

The glyph is mishandled by Mathematica (in V12, MacOS). Here is the input form and how it is typeset:

"\|01d44e"

Mathematica graphics

There is a lot of extra space following the letter. From the FE editor's point of view, there is an insertion point in the middle (sorry, don't know how to show that). One can delete part of the space, but it changes the Unicode character to one that sometimes CRASHES the kernel when you evaluate it. BEWARE!

Using the character is difficult because of this. It is not centered:

Graphics[{
  Text[Style[mathA, 64]]
  }, Frame -> True, Axes -> True]

Mathematica graphics

Adding some spaces on the left can get it close to centered:

Graphics[{
  Text[Style[StringPadLeft[mathA, 7], 64]]
  }, Frame -> True, Axes -> True]

Mathematica graphics

Add a "\[ThinSpace]" will get it very close. Of course, it all depends on the font used.

$\endgroup$
4
  • $\begingroup$ TraditionalForm[a] in a regular output cell looks like the math a, but in Graphics, it is typeset as a double-storey a. $\endgroup$
    – Michael E2
    Commented Dec 17, 2019 at 13:43
  • $\begingroup$ I got a FromCharacterCode::notunicode: A character code, which should be a non-negative integer less than 65536, is expected at position 1 in {119886}. >> error, which make me realize for the first time that the Unicode set in v10.1 is out of date. Do you know if there is a way to extend this? $\endgroup$
    – Mr.Wizard
    Commented Dec 17, 2019 at 14:37
  • 1
    $\begingroup$ @Mr.Wizard I recall that at some point M supported unicode up to "U+FFFF" ( = character code 65535). It seems V12 now supports the full unicode character set (but not perfectly, it seems from the above). I don't know how to extend earlier versions of M. I recall trying to do so, because there was some character I wanted to use. But I failed to find a solution. $\endgroup$
    – Michael E2
    Commented Dec 17, 2019 at 14:54
  • $\begingroup$ The mentioned bug has been fixed at least since v13.3. (Maybe earlier. ) $\endgroup$
    – xzczd
    Commented Jul 30, 2023 at 7:19
2
$\begingroup$

If you look at the fonts installed in Windows there is "Cambria Italic" font and "Cambria Math" which is not italic and very different. Try the code

Style["abcdefghijklmnopqrstuvwxyz", {Large, FontFamily -> "Cambria Italic"}]

which looks almost exactly the same as equation mode in Word. I did notice that in Word there is a gap between "f" and "g" and the serifs are slightly different and curvier. This is most noticeable in the "v" in Word. Other than that they are very close. An expert in fonts will be able to detect the difference right away, so there is still some mystery here. Where is the font that Word uses for equation variables?

I made a test document with "a" through "z" equation variables and saved it as a "docx" file. I looked at the XML files inside it and found reference to a few fonts but none of them looked exactly like ones used for Word equation variables. Still a mystery to me.

$\endgroup$
3
  • $\begingroup$ That code gives the same as ...{Large,Italic,FontFamily->"Cambria"}], which I've been using instead. You're right, it's close, but not the same. As to the font used in Word, all I can say is in this pic: i.sstatic.net/lv5v4.png $\endgroup$ Commented Mar 21, 2019 at 12:43
  • $\begingroup$ @TravisBemrose Any luck after a v12 update and/or using "Cambria Italic"/"Cambria Math" in place of "Cambria"? Also, what does evaluating $FontFamilies give you? $\endgroup$ Commented Apr 20, 2019 at 21:22
  • $\begingroup$ Comparison: i.sstatic.net/LTbW0.png | $FontFamilies: i.sstatic.net/5ip5f.png $\endgroup$ Commented Aug 12, 2023 at 3:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.