8

I would like to change back and forth between two fonts. But I would like these two fonts to affect both normal text, as well as the digits and letters in maths mode. Something like this should work fine...

\documentclass{minimal}
\usepackage{unicode-math}

\newenvironment{example}{\setmathfont{Arial}\setmainfont{Arial}}{}
\newenvironment{exampletwo}{\setmathfont{Bradley Hand ITC}\setmainfont{Bradley Hand ITC}}{}

\begin{document}
\begin{example}  Prove the 33 is a factor of $2^{55}+1$ \end{example}\\
\begin{exampletwo}
 First note 33 that $2^{55}+1 &=(2^5)^{11}+1$
\end{exampletwo}
\item
\end{document}

The problem comes when I try to use something like \cdots, since the fonts I'm using don't have full maths support. I have got round this by using mathspec and something like

 \setmathfont(Digits,Latin){Bradley Hand ITC}

so all the symbols remain as the default font. But I can't get \setmathfont with the mathspec package to work in the \newenvironment command.

Any help greatly appreciated.

Many Thanks

4
  • Thankyou, any ideas re: the original post? Mar 7, 2015 at 16:58
  • Sorry, I am no expert in xelatex stuff
    – user31729
    Mar 7, 2015 at 17:18
  • 1
    you seem to be using unicode-math not mathspec, I retagged. Mar 7, 2015 at 21:15
  • Sorry for the confusion. The code post, is an almost working example of what I want. The only way I know to do what I want (change the Latin and Digits, but leave the symbols unchanged), would be using mathspec, but when I change from unicode-math to mathspec I can't get the \newenvironment to work. Mar 7, 2015 at 21:20

1 Answer 1

11

You want to do the font declarations in the preamble, and just switch math versions in the environments.

enter image description here

\documentclass{article}
\usepackage{fontspec,unicode-math}
\setmainfont{Arial}
\DeclareMathVersion{bhitc}
\setmathfont[version=normal]{Arial}
\setmathfont[version=bhitc]{Bradley Hand ITC}
\newenvironment{example}{\mathversion{normal}}{}
\newenvironment{exampletwo}{\mathversion{bhitc}}{}

\begin{document}
\begin{example}  Prove the 33 is a factor of $2^{55}+1$ \end{example}\\
\begin{exampletwo}
 First note 33 that $2^{55}+1 =(2^5)^{11}+1$
\end{exampletwo}

\end{document}
7
  • When I try and use symbols not supported in these fonts (such as \cdots) I get a square. Is there a way to do the above, but so that only the Digits and Latin are changed? Mar 7, 2015 at 21:40
  • 1
    @Tim probably is, but you'd have to undo a lot of what unicode-math does, it takes the line that it really wants to use one unicode font for the whole thing. xetex actually allows 256 fonts per math list (up from 16 in classic tex) but I'm not sure there is an existing high level interface to that. Mar 7, 2015 at 21:47
  • @Tim I found the fonts, so updated answer. Mar 8, 2015 at 14:49
  • Why, if I include alphabetic letters in the Arial math (example environment), are they presented as Latin Modern? Nov 1, 2017 at 12:11
  • @StevenB.Segletes must be a feature, related to this warning from unicode-math/fontspec * Font 'Arial' does not contain script 'Math'. * 'Latin' script used instead. Nov 1, 2017 at 13:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .