EDIT: it turned out, that my real file problem was caused by another package.
(This question is closely related to a prior question of mine Package dcolumn displays different fonts as that still didn't solve my original problem (see the comments).)
Im am using the beamer
class. Hence the sans-serif font is the default in this document.
I have/want to use an OTF font, so my file relies on package fontspec
.
There is a table, which incorporates a D
-colunm from dcolumn
package, as well as regular r
or l
columns. I was very surprised to find out, that the D
column does not use sans-serif fonts!
I could boil down the problem to package fontspec
.
Here is a MWE producing a correct output:
\documentclass{beamer}
\usepackage{dcolumn}
\newcolumntype{E}{D{,}{,}{-3}}
\begin{document}
\begin{frame}
\frametitle{Correct Math Font}
\begin{center}
With PDF\LaTeX{} or Lua\LaTeX{} \\
but without package \texttt{fontspec}\\
\begin{tabular}{rE}
1,23 & 1,23
\end{tabular}
\end{center}
\end{frame}
\end{document}
And this is the output, as expected.
Now, simply add the line \usepackage{fontspec}
to that MWE and it gets weird.
EDIT: Ulrike Fischer did answer and was able to solve the problem given in that MWE above. But using that solution on my real file, did not work. It turned out, that another package requires the package unicode-math
which in turn brings up the same problem again. I edited the MWE below by inserting \usepackage{unicode-math}
as well.
\documentclass{beamer}
\usepackage{dcolumn}
\usepackage{fontspec}
\usepackage{unicode-math}
\newcolumntype{E}{D{,}{,}{-3}}
\begin{document}
\begin{frame}
\frametitle{Incorrect Math Font}
\begin{center}
With Lua\LaTeX{} and \\
with package \texttt{fontspec}\\
\begin{tabular}{rE}
1,23 & 1,23
\end{tabular}
\end{center}
\end{frame}
\end{document}
This time, you get this output:
As you can clearly see, the right column is in normal, upright roman font. Why is that and---even more important---how to fix this?
EDIT: Ulrike Fischers answer did solve my first question, before I had to edit it. So, technically speaking, her answer deserves the green check mark also (at least partially). After having upgraded my question with regard to the unicode-math
package, the answer from Davislor solves my question completely!