11

How to change the default font of math operators? The problem is that if I use the command \DeclareMathAlphabet\mathrm{U}{eur}{b}{n}, only new defined operators will be changed in terms of its font. For the operators like \sin or \sup, no changes will take place.

\documentclass[english]{report}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amsthm,amssymb}
\DeclareMathAlphabet\mathrm{U}{eur}{b}{n}

\begin{document}
$$\sin,\sup$$

\end{document}
Qian
  • 317
  • 1
    Please post a minimal working example (MWE) demonstrating the issue. Right now, I'm a bit confused about what you are really trying to do. Computer Modern is the default font. You seem to be trying to produce bold operators but, if so, this is not a good way to do it... – cfr Dec 25 '14 at 03:36
  • Thanks for adding an example. What are you trying to do exactly? Note that this font is not intended to be used for \mathrm. It is a symbol font which uses a 'raw' encoding (U). Also, you should not define the normal version using the b series. But it is hard to say what you should do without knowing what you are trying to do. Does \usepackage{amsfonts} do what you want? – cfr Dec 25 '14 at 03:53
  • ...just like I said. I wonder if it is possible to change the default font of math operators. I remember \mathrm defines the font of math operators – Qian Dec 25 '14 at 03:57
  • Yes, you can change it. But what do you want to change it to? You cannot change it to a font which doesn't include the right characters. Also, $$ ought not be used - it is obsolete. Use \[...\] instead. (In LaTeX.) – cfr Dec 25 '14 at 03:58
  • Sorry I don't know what right characters you are referring to. I presumed that only upright latin alphabets are required. – Qian Dec 25 '14 at 04:02
  • Normally, \mathrm uses a font in the OT1 encoding. But, in any case, you'd use \SetSymbolFont{operators}{normal}{OT1}{lmr}{m}{n}, say, to set a non-default font for this. And then you'd set the bold variant separately. But, generally, you ought not do this in your document. Packages exist to do it for you. In this case, just look at amsfonts and choose the options you want. – cfr Dec 25 '14 at 04:08

2 Answers2

13

The usual definition of \sin is

\mathop{\operator@font sin}\nolimits

while \operator@font means

\mathgroup\symoperators

You won't find a definition place for \symoperators, because this is a byproduct of a

\DeclareSymbolFont{operators}...

instruction. So what you need is a new symbol font rather than a math alphabet.

\documentclass{article}

\DeclareSymbolFont{euleroperators}{U}{eur}{m}{n}
\SetSymbolFont{euleroperators}{bold}{U}{eur}{b}{n}

\makeatletter
\renewcommand{\operator@font}{\mathgroup\symeuleroperators}
\makeatother

\begin{document}
$\sin(\pi/2-\alpha)=\log 1+\cos\alpha$
\end{document}

enter image description here

This will also work when amsmath is loaded and \operatorname or \DeclareMathOperator are used.

If you also want to define a new \matheul command, add

\DeclareSymbolFontAlphabet{\matheul}{euleroperators}

to the commands above. Note that \mathrm will continue to act as before.

egreg
  • 1,121,712
1

In fontspec, you can download the Neo Euler OpenType font and change the \mathrm font with

\setmathrm{Neo Euler}[Scale=MatchLowercase]

Unless something else in your preamble breaks it, this should change your operator font as well. In unicode-math, you can set the operator font to something different than \mathrm with:

\setmathfontface\matheur{Neo Euler}[Scale=MatchLowercase]
\setoperatorfont\matheur

The excellent answer by @egreg already tells you how to do it with NFSS.

Davislor
  • 44,045