[Tex/LaTex] Getting the right font for text in math mode

fontsmath-mode

I'm using the following commands in my preamble to get the fonts I want:

\usepackage{cmbright}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{pxfonts}

I recently found that, in math mode, when I use the command \log or \exp (as opposed to \text{log} or \text{exp}), the logarithmic and exponential functions get resolved in the math font I want to use (pxfonts). However, I often use other functions such as "logit" and "expit", for example:

\begin{equation}
\text{logit} \Bigg \{ P(Y = 1| X = x) \Bigg \} = \beta_0 + s(x), 
\end{equation} 

In this case, "logit" resolves in the font used in the main text (cmbright), which stands out as somewhat of an eyesore. Is there a way I can create functions \logit and \expit that, in math mode, will return "logit" and "expit" using the desired math font (pxfonts) and not the main text font (cmbright)?

Best Answer

You can use \DeclareMathOperator from amsmath; this will also give you the right spacing:

\documentclass{article}
\usepackage{cmbright}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{pxfonts}

\DeclareMathOperator{\logit}{logit}

\begin{document}

\begin{gather}
\text{logit} \Bigg \{ P(Y = 1| X = x) \Bigg \} = \beta_0 + s(x)\\
\logit \Bigg \{ P(Y = 1| X = x) \Bigg \} = \beta_0 + s(x)
\end{gather} 

\end{document}

enter image description here

Related Question