# Changing font of mathematical functions (ln, exp, etc.)

SOLVED: see edits #1 and #2 below.

I'm trying to set up a XeLaTeX document that uses a sans-serif math font (Myriad Pro) with a serif text font (Arno Pro). Because Myriad Pro does not have full math support, I'm using the MdSymbol package to access mathematical symbols. However, when calling built-in mathematical functions such as \ln or \exp (and presumably \cos etc.), the font reverts to Computer Modern.

Is there a way I can get these built-in functions correctly displayed in Myriad Pro?

As an additional question, I would like to have in-line math in the main text font (Arno Pro) rather than the math font (Myriad Pro). Can anyone suggest a convenient way of doing this?

MWE below.

\documentclass[11pt]{article}
\usepackage{mathspec}
\setmainfont{ArnoPro-Regular.otf}
\usepackage{mdsymbol}

\begin{document}

$$\begin{split} j_0 = \frac{j_{kin}}{\exp{\frac{- \alpha_c F \eta}{RT}}} \\ \alpha_c = - \frac{RT}{F \eta} \ln{\frac{j_{kin}}{j_0}} \end{split}$$

\end{document}


EDIT #1: the \ln issue can be resolved by adding the following:

\setmathrm{MyriadPro-Regular}


The answer was found here: XeTeX/mathspec math environment font

EDIT #2: the in-line font issue can be solved using the instructions in this page: Use different math font in inline-style and display-style formulas

However, the discussion there, and the comments on this thread, have convinced me that it is better to write mathematical expressions in the same font whether they are in-line or in dedicated environments. Since switching between serif and sans-serif in a line of text is jarring, I have opted for just using serif font throughout.

• I'm not sure you can have math displays in Myriad and inline math in Arno and it would make little sense anyway. – egreg Oct 20 '20 at 9:17
• It makes perfect sense from a display point of view - maybe not this specific pairing of fonts, but it's a work in progress. – PGratrex Oct 20 '20 at 9:20
• Sorry, but from a mathematical point of view a serif eta and a sans serif eta mean different things. – egreg Oct 20 '20 at 9:24
• Okay, fair point, it makes sense in certain contexts. For my purposes, I think it makes sense, as eta is referring to overpotential, and this is not affected by serifs. For a strictly mathematical paper, it could cause problems; thank you for pointing that out. – PGratrex Oct 20 '20 at 9:28
• @egreg, thanks for your input. The suggestion is incorporated into the edited question above. – PGratrex Oct 20 '20 at 10:01

Although @egreg gave one method, \setmathrm, it is also possible to change the operator font to something other than mathrm.
In unicode-math, this is the \operatorfont command, for example
\operatorfont\mathsfup

In classic LaTeX, you can redefine the \operator@font command to a different font than \mathrm. Remember to \makeatletter before using a command name with @ in it, and \makeatother when you are done.