4

I am using the default font, Computer Modern Roman, and I am trying to get \operatorname to work properly. The issue is that it appears to look identical to normal text. This question: LuaLaTeX: No kerning within \operatorname when not loading lmodern package shows a method for resolving this in LuaTex.

How can I achieve this in pdfTex?

Example

\documentclass{report}

% Math packages
\usepackage{mathtools}
\usepackage{amsfonts}
\usepackage{amssymb}

\begin{document}
    $foo$ foo $\operatorname{foo}$
\end{document}

enter image description here

In the above image the last two words should not look the same.

If you switch the default font, for example: \renewcommand*\rmdefault{bch}. You will get the following result:

enter image description here

I don't want to change the default font, I just want to make \operatorname show a distinction.

  • 1
    Welcome! This is normal. The reason the font change makes a difference is because it changes the default text font but not the default maths fonts so the maths fonts are still Computer Modern and now the default serif is different. Generally speaking, you want your maths fonts to cohere with your text fonts: the above mix would not look good which is why you would rarely simply change the default serif. – cfr Apr 7 '16 at 2:45
  • 1
    Note that the point in the question you linked is precisely that the results differ in maths mode - not that they are the same. And the problem there doesn't apply to pdfTeX - that's the point, too. It just works with TeX/pdfTeX. You don't have to do anything to get the kerning to be effective. – cfr Apr 7 '16 at 2:48
  • 1
    @cfr, I understand that you should stick with a font family. I don't want to change the font of my math, but I do want \operatorname to be typeset differently. This is for use in my thesis which has a lot of math and I need a clear distinction between text, symbols, and function names (among other things). In this context, \operatorname would be used to describe a function name, similar to how \sin is used to describe the sine function. – TehTechGuy Apr 7 '16 at 3:22
  • One can change the font used by \operatorname, but this would affect also numbers, parentheses and other math symbols. – Ulrike Fischer Apr 7 '16 at 8:03
  • How about \operatorname{\text{foo}}? – Henri Menke Apr 7 '16 at 8:58
2

amsmath macro \operatorname is designed to use the same font as the one used by \DeclareMathOperator.

It is a fact of life that this font is hardcoded in both LaTeX and AMSmath source code (more precisely fontmath.ltx or amsopn.sty) to use the so-named 'operators' math font. This happens via

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

You can customize \operator@font (package mathastext does it). But as you see you should refer to one the (16 in PDFTeX) math font family (\mathgroup in LaTeX, \fam in TeX). Besides you will thus affect all commands user-defined via \DeclareMathOperator or those pre-defined like \sin, \cos which use a more direct approach but still have \operator@font hardcoded therein.

  • 1
    This gave me just enough to come up with a working solution. I redefined \operator@font using a pre-existing math group, as suggested. For those of you interested, I placed the following after loading all of my packages: \makeatletter \def\operator@font{\mathrm} \makeatother. You'll notice that it is similar to \mathnormal, but just different enough. – TehTechGuy Apr 8 '16 at 2:45

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.