17

What is the correct way of having all operator names be set in, say, sans serif? Saying

\documentclass{article}
\usepackage{amsmath}
\makeatletter
\def\operator@font{\sf}
\makeatother
\DeclareMathOperator\operator{operator}
\begin{document}
An $\operator 1$.
\end{document}

seems to do the trick, but amsopn.sty defines

\def\operator@font{\mathgroup\symoperators}

which seems to do more...

It would be nice if there were a @-free way of doing this, by the way.

1
  • 1
    You need to redefine \operator@font, which is used in other macros with that name. Either use \makeatletter and \makeatother or rewrite amsopn.sty in order not to use \operator@font. I guess that the choice is easy. :)
    – egreg
    Feb 2, 2012 at 0:02

2 Answers 2

18

You can define a new symbol font, and also redefine \mathsf to use it, otherwise you'd waste a math group and there are only 16 of them:

\DeclareSymbolFont{sfoperators}{OT1}{cmss}{m}{n}
\DeclareSymbolFontAlphabet{\mathsf}{sfoperators}

\makeatletter
\def\operator@font{\mathgroup\symsfoperators}
\makeatother
2
  • 1
    Is there any way to get this to work with unicode-math?
    – arynhard
    Feb 17, 2015 at 22:54
  • 1
    @arynhard This warrants a new question
    – egreg
    Feb 17, 2015 at 23:11
1

You ask in a comment how to get this to work in unicode-math and were asked to post a new question. For the sake of anyone searching for the answer (or flagging a duplicate question):

To set the operatorfont to something other than \mathrm, use, for example:

\setoperatorfont\mathsf

This also works with math font faces you define with \setmathfontface, not only the built-in math alphabets.

To change the \mathrm font, use \setmathrm. If you’ll be using it in \boldmath, you might also want to \setboldmathrm.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .