# How to create text mode in DeclareMathOperator?

I have the following latex,

\documentclass{article} \usepackage{amsmath}

\DeclareMathOperator{\nin}{n_{\textrm{in}}} \DeclareMathOperator{\nout}{n_{\textrm{out}}}

\begin{document}
I want my declared math operators to look like this: $n_{\textrm{in}}, n_{\textrm{out}}$ But when I use them, they look like this: $\nin, \nout$

\end{document}


Which produces the following output

Why is it that unwrapping the declared operator gives me the math font on the n, while the Operator itself does not? How do I get the operator to give me the correct n?

• One of the effect of \DeclareMathOperator is precisely to use the "operators" Symbol Font which by default is Computer Modern upright. Are you sure you want an "operator" here. They look more like being variables, so why not \newcommand? – user4686 Apr 25 '18 at 7:58

With \mathop, you can define:
\newcommand{\nin}{\mathop{n_{\mathrm{in}}}}

or using \DeclareMathOperator (amsmath):
\DeclareMathOperator{\nin}{\mathit{n}_{in}}