# fontspec/mathspec ruins my parentheses with beamer

My problem appears to be related to this earlier post:

Parentheses differ (XeLaTeX, fontspec, newtxmath, libertine)

but mine seems even simpler. My problem is that when I compile a simple beamer presentation and use the fontspec or mathspec packages, the parentheses are spaced poorly. As an MWE, when I compile the following with XeLaTeX:

\documentclass{beamer}
%\usepackage{fontspec}
\begin{document}
\frame{
Hello!  $f(x)=x^2$
}
\end{document}


I get just what I would want:

However, when I uncomment the fontspec bit,

\documentclass{beamer}
\usepackage{fontspec}
\begin{document}
\frame{
Hello!  $f(x)=x^2$
}
\end{document}


I see the following:

Does anyone know what can be causing this? I don't see mention of parentheses in the documentation.

• I think the problem is beamer+fontspec, not with fontspec. In fact beamer sets all the text (including math) in sans serif and this causes the problem. I guess I've seen similar threads in this site, but at the moment I can't find one... – karlkoeller Sep 11 '13 at 19:50
• BTW: It's not a good practice to load fontenc when compiling with xetex, but adding the line \usepackage[T1]{fontenc} seems to solve the problem, until you get a better answer... – karlkoeller Sep 11 '13 at 20:01

XeTeX fails to set the correct italic correction in math (http://tug.org/pipermail/xetex/2011-March/020318.html) when open type fonts are used. I would suggest to use the normal T1-encoded font for the letters_

\documentclass{beamer}

\usepackage{fontspec}
\AtBeginDocument{%
\DeclareSymbolFont{pureletters}{T1}{lmss}{\mddefault}{it}%
}

\begin{document}

$f(x)$

\end{document}


## Edit 2017

With the new latex format which uses opentype fonts by default with xelatex you will get the wrong spacing without any external packages like fontspec:

\documentclass{beamer}

%\AtBeginDocument{%
%      \DeclareSymbolFont{pureletters}{T1}{lmss}{\mddefault}{it}%
%      }

\begin{document}

\begin{frame}
$f(x)$
\end{frame}

\end{document}


• If you use the mathserif option and want to stay with classical Computer Modern, do \DeclareSymbolFont{pureletters}{OT1}{cmr}{\mddefault}{it}. – Henri Menke Jul 8 '14 at 12:42