[Tex/LaTex] \mathbbm{1} not working well with XeLaTeX/mathspec

blackboard;fontsmathspec

it seems that \mathbbm{1} doesn't display with double lines when one changes to a different font using mathspec in XeLaTeX. For example, the MWE below uses Palatino, but I couldn't get it to work with any other font (Times New Roman, etc.).

The problem occurs when I try to specify that the math font be applied to numbers: \setmathsfont(Digits){Palatino} in the preamble. The \mathbbm{1} symbol displays correctly if you remove the (Digits), but then numbers in a math environment don't match those in the text.

If this is a font issue, is there a way to change font temporarily in a math environment so that I could call something like \LatinModern{ \mathbbm{1} }?

As a separate but related issue, I don't even know how to include the Latin Modern (or whatever the default LaTeX font is) using XeLaTeX since it's not a font in my library.

Thanks for any help you can provide. MWE below.

Minimal Working Example:

\documentclass{article}
\usepackage{bbm, dsfont}
\RequirePackage{mathspec} 

\setmathsfont(Digits){Palatino} % causes problem

\begin{document}

This blackboard bold $\mathbbm{1}$ isn't double lined. 
Doublestroke package doesn't work either, $\mathds{1}$.

\end{document}

Best Answer

Interaction of mathspec with font packages is not really predictable. You can fool the package with this trick:

\documentclass{article}
\usepackage{amsmath}
\usepackage{mathspec}

\setmainfont{Palatino}
\setmathsfont(Digits){Palatino}

\newcommand{\mathbbm}[1]{\text{\usefont{U}{bbm}{m}{n}#1}} % from mathbbm.sty

\begin{document}

This blackboard bold $\mathbbm{1}$ is double lined.

\end{document}

enter image description here

The similar definition for dsfont would be

\newcommand{\mathds}[1]{\text{\usefont{U}{dsrom}{m}{n}#1}}

or with dsss instead of dsrom if the sans serif version is preferred.

A different approach would be to use unicode-math and the TG Pagella Math font:

\documentclass{article}
\usepackage{amsmath}
\usepackage{bbm}
\usepackage{unicode-math}

\setmainfont{Palatino}
\setmathfont{TG Pagella Math}


\begin{document}

This blackboard bold $\mathbbm{1}$ is double lined.

\end{document}