0

In math mode, LaTeX uses a different font for expressions such as \max than it would just for just max. Is there a way to keep this different usages of fonts, but change the font for expressions such as \max to something that is different than the default font for text?

  • \max is an operator definition with comes down to \operator@font – user31729 Nov 15 '17 at 22:27
  • The question as it is stated is too broad; in order to get meaningful instructions, you should be more specific about the fonts you would like to use for the various types of entity that can occur in a mathematical formula (operators, variables, numbers…). The answer to the question as it is currently formulated is “yes”. :-) – GuM Nov 15 '17 at 22:35
  • I tried to put \operator@sffamily in my preamble, but this did not work. – user109871 Nov 15 '17 at 22:40
1

You can re-assign the font for the operators alphabet, but note that includes digits and some punctuation by default:

enter image description here

\documentclass{article}

\SetSymbolFont{operators}{normal}{OT1}{cmr} {bx}{it}
\begin{document}


$a + \max(1,2)$ max

\end{document}

It is of course possible to change the settings for digits, but it depends what you do want, and the more changes you make the more chance that the document is incompatible with some other math package.

You can also redefine \operator@font which is the font used by \max but that requires a slight dance as math font commands are defined to take an argument that isn't wanted here, but for example to use \mathsf:

enter image description here

\documentclass{article}

\makeatletter
\renewcommand\operator@font{%
  \mathsf{\xdef\tmp{\fam\the\fam}\aftergroup\aftergroup\aftergroup\tmp}}
\makeatother

\begin{document}


$a + \max(1,2)$ max

\end{document}
  • But this would change the font of the text in a fraction. – user109871 Nov 15 '17 at 22:46
  • @user109871 not \frac{a}{b} but it would probably change more than you intend, but your question wasn't too clear about exactly what you wanted to change, the command shown is the most literal interpretation of the question, it reassigns the operator font – David Carlisle Nov 15 '17 at 22:55
  • @user109871 added a second mechanism – David Carlisle Nov 15 '17 at 23:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.