# unicode-math and sans serif font with LuaTeX and MacTeX

Using unicode-math I was able to use a sans serif font with LuaTeX in math-mode in pgfplots. It still works with TeXLive 2016 but it doesn't with MacTeX 2017 and 2018.

Solution to my original question:

\documentclass{scrartcl}
\usepackage{unicode-math}
\setmainfont[%
BoldFont={MinionPro-Bold}%
,ItalicFont={MinionPro-It}%
,BoldItalicFont={MinionPro-BoldIt}%
,Numbers=OldStyle%
]{MinionPro-Regular}
\setsansfont[%
Scale=MatchLowercase%
,Numbers=OldStyle%
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xbar,
xlabel={a--d},
symbolic y coords={a,b,c,d},
ytick=data,
nodes near coords, nodes near coords align={horizontal},
]
(45,a)
(20,b)
(1,c)
(5,d)
};
\end{axis}
\end{tikzpicture}
\end{document}


On TeXLive 2016 it results in the following plot:

On MacTeX 2017 and 2018 it results in the following plot that uses Latin Modern Math for x ticks and nodes:

Any ideas where these differences result from?

• Do you receive any complaints that some font was not found (and got replaced)? – marmot Aug 22 '18 at 10:39
• On both distributions (TeXLive and MacTeX) fontspec warns that MyriadPro-Regular does not contain script 'Math' and that OpenType feature 'Style=MathScript' (ssty) is not available for font MyriadPro-Regular. – typokurz Aug 22 '18 at 10:49
• I see. I think it is fair to say that this is not a problem with pgfplots then. Most likely you could work around it by typesetting the ticks and nodes near coords in text mode rather than math mode. – marmot Aug 22 '18 at 10:52
• It would be great if this was possible. But even after consulting pgfplots.pdf I don't know how to achieve it. I even thought this was impossible … Doesn't nodes near coords need \pgfmathprintnumber to properly interpret \pgfplotspointmeta? – typokurz Aug 22 '18 at 11:23
• \pgfmathprintnumber is not necessarily in math mode. See e.g. on p. 75 how to set the options for the ticks globally. – marmot Aug 22 '18 at 11:26

Using a text font as math font is simply wrong.

If your ticks allows it the simplest solution is to type the ticks in text mode (I use TeX Gyre Heros as I don't have your font):

\documentclass{scrartcl}
\usepackage{unicode-math}
\setsansfont[]{TeX Gyre Heros}
\setmathfont{Latin Modern Math}

\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
tick label style={/pgf/number format/assume math mode=true},
font=\sffamily,
xbar,
xlabel={a--d},
symbolic y coords={a,b,c,d},
ytick=data,
nodes near coords, nodes near coords align={horizontal},
]