# Using mathbb fonts from other packages

I am currently using a combination of mathpazo and mathspec for my maths typesetting. To be specific, my preamble contains the following:

\usepackage{amssymb}

\usepackage{mathrsfs}
\usepackage{mathpazo}

\usepackage{mathtools}

\usepackage{mathspec}

\usepackage{xltxtra,xunicode}
\defaultfontfeatures{Mapping=tex-text}

\setmainfont[Numbers=OldStyle]{Palatino Linotype}
\setsansfont{Optima}
\setmonofont{Consolas}
\setmathsf{Optima}
\setmathfont(Greek){Palatino Linotype}

\exchangeforms{phi}

However, I would like the option of using, say, the AMS blackboard bold fonts for mathbb, or the ones provided by STIX (or any other Unicode maths font) instead of the ones provided by mathpazo. So far nothing I've tried with \setmathbb has worked.

I have a similar problem with \setmathcal, and I notice that if I use calrsfs instead of mathrsfs there is no effect whatsoever.

-

I'd go directly to unicode-math:

\documentclass[a4paper]{article}
\usepackage{mathtools} % loads amsmath that should go before unicode-math
\usepackage{unicode-math}
\setmainfont[Numbers=OldStyle]{Palatino Linotype}
\setsansfont{Optima}
\setmonofont{Consolas}
\setmathfont{Asana Math}


Asana Math is based on the MathPaZo fonts.

If you really need brackets and parentheses from the MathPaZo fonts, it's doable:

\DeclareSymbolFont{brackets}       {OT1}{zplm}{m}{n}
\SetSymbolFont{brackets}{bold}     {OT1}{zplm}{b}{n}
\DeclareSymbolFont{largebrackets}  {OMX}{zplm}{m}{n}
\SetSymbolFont{largebrackets}{bold}{OMX}{zplm}{m}{n}
\DeclareMathDelimiter{(}{\mathopen} {brackets}{"28}{largebrackets}{"00}
\DeclareMathDelimiter{)}{\mathclose}{brackets}{"29}{largebrackets}{"01}
\DeclareMathDelimiter{[}{\mathopen} {brackets}{"5B}{largebrackets}{"02}
\DeclareMathDelimiter{]}{\mathclose}{brackets}{"5D}{largebrackets}{"03}


For the Knuth calligraphic font, add

\setmathfont[range={\mathcal,\mathbfcal},StylisticSet=1]{XITS Math}


For a "better" \vDash symbol, add

\setmathfont[range=\vDash]{XITS Math}


The "not belonging to" symbol should always be specified with \notin rather than with \not\in.

Finally, for the AMS blackboard bold:

\DeclareSymbolFont{AMSb}{U}{msb}{m}{n}
\protected\def\mathbb#1{{\mathchar\numexpr256*\symAMSb+#1\relax}}

-
The results are ugly (particularly all the brackets), and I would have to set the calligraphic range to something else since I want to use both rsfs-like and eucal-like symbols. – Zhen Lin Jun 27 '11 at 19:36
Add \setmathfont[range={\mathcal,\mathbfcal}]{Neo Euler} The font can be downloaded at github.com/khaledhosny/euler-otf; then \mathscr will give the rsfs font, \mathcal the Euler Calligraphic. What's the problem with brackets? – egreg Jun 27 '11 at 20:30
The brackets (all types — round, square, curly, etc.) are generally too large (e.g. when enclosing symbols with ascenders or descenders) and spaced unusually compared to the typesetting of mathpazo. Some of the symbols are also particularly ugly, such as \vDash. \not\in is entirely broken, requiring the use of \notin instead. The command you suggested isn't what I meant — I want the default \mathcal font, not the Euler font. Thanks for the link, however. – Zhen Lin Jun 27 '11 at 21:21
Thank you for your edit. However, this seems very cumbersome. Isn't there a way to do the reverse and use unicode-math only for, say, \mathbb, and mathspec for the rest? – Zhen Lin Jul 18 '11 at 4:29
I followed your method to use AMS blackboard with Pagella Math. However it doesn't work with $\hat\mathbb{Z}$. The error is  Internal error: bad native font flag in map_char_to_glyph' . The same error appears here. Is there any better workaround? Thank you. – striving Nov 29 '14 at 13:48