# Change main font without affecting the math environment

I changed my document font from the default one to Akkurat with setmainfont from fontspec:

\usepackage[no-math]{fontspec}
% ...
\setmainfont{}[
Path = fonts/AkkuratPro/,
UprightFont = AkkuratLightPro-Regular.otf,
BoldFont = AkkuratPro-Bold.otf,
ItalicFont = AkkuratLightPro-Italic.otf,
BoldItalicFont = AkkuratPro-BoldItalic.otf]


However, I find that the math mode also ends up using this font for all the \text/upright entries. Setting package option no-math did solve part of the problem and used the proper math font for \min, \log, \sin, and the like. However, Akkurat is still used if I use \text or \textbf.

For symbols that are in bold, using the \bm command does solve the problem (it displays the math font) but in other cases I don't know how to do it. E.g.

$$\min{\bm{J}\left(\bm{x}, \bm{p}\right)} \quad\text{if}\quad\bm{x} = \log 2$$


In the example above, "min", and "log" use the math font, whereas "if" still uses Akkurat. Is there a way to circumvent this?

NB. This happens in all math modes (equation, align, $...$, $$...$$, etc).

• Please could you add your complete MWE? Thank you very much. – Sebastiano Feb 5 at 12:47
• \textXX commands are for text, and so use the text font. Use e.g. \mathrm{if} if you want to stay inside math. – Ulrike Fischer Feb 5 at 12:56
• @Sebastiano I would, but you'll require some font files that might not be available in your system, precluding you from compiling the source. What it is exactly that you would you like to see in the MWE? Perhaps I can expand some parts of the code, 'cause the MWE would end up being just a simple document with what I posted. – Carles Araguz Feb 5 at 12:56
• Thanks @UlrikeFischer, that was the mistake. – Carles Araguz Feb 5 at 12:59
• @CarlesAraguz Don't worry. :-) I have understood and appreciated your comment. Excuse me for my request (often I understand the question with a full code or with a picture). My regards. – Sebastiano Feb 5 at 13:00