Gaps between overbars and square roots in exported graphics in some fonts

I make my slides in LaTeX and my pictures in Mathematica. I want to keep the fonts the same throughout, so when I have an image with text in it, I convert the text to "CMU Bright" font in Mathematica before I export the image as a pdf.

If my image includes an overbar or a square root, it looks like this:

Image = Graphics[Text[Style[{OverBar[x] Sqrt[x],"Overscript[x, _],Sqrt[x]"}, FontFamily->"CMU Bright"], {1, 3}]]


But when I export it as a pdf there are big gaps between the x and the bar.

Export[NotebookDirectory[] <> "image.pdf", Image ]


Does anyone know what's causing this or how to fix it?

• I can't reproduce the behavior you see in v.11. After exporting to PDF and opening in Adobe Acrobat, this is what I see, i.e. no extraneous spacing. Notice also that you have extra " in your code which I think are not intended. You also should not use Image since it's a built-in symbol. – MarcoB Nov 15 '16 at 20:39
• Don't use Image =.... Image is a builtin symbol. Export[..., Image] is also invalid. It should be Export[..., "PDF"]. – Szabolcs Nov 20 '16 at 11:54

1 Answer

I have seen this very problem before. Typesetting does sometimes change when exporting to PDF, and the result may change slightly from version to version.

I recommend that you simply use LaTeX to typeset these, through the MaTeX package.

This problem was the actual reason why I wrote MaTeX. Coincidentally, I was annoyed by precisely a square root and an overbar, just like you ...

<<MaTeX

MaTeX[OverBar[x] Sqrt[x]]


MaTeX["\\bar x \\sqrt{x}"]
`