I want to declare a custom operator op
that is supposed to use sans-serif font.
No other operator (\sin
etc.) shall use sans-serif.
I tried to use \DeclareMathOperator
which yields correct spacing but I seem unable to change the font for only this one operator.
I also tried a simple \newcommand
which allows me to use sans-serif, but messes up the spacing.
How can I combine both approaches to get a sans-serif operator with correct operator spacing while not changing the font for all operators?
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\DeclareMathOperator{\op}{op}
\newcommand\opsans{\mathsf{op}}
\begin{document}
\noindent
Correct spacing: \[a \op_k b\]
Wrong spacing: \[a \opsans_k b\]
\end{document}
Best Answer
Try
Works fine here.