# Using \textstyle with \pmod

If I'm in a displayed equation but I want the \sum symbol to appear as it does in inline formulas, I can just put \textstyle in my equation. I thought that writing \textstyle would also force \pmod to use the spacing it uses for inline formulas, but for some reason it won't work. Why is that, and how can I force \pmod to use the non-display style spacing when I'm in a displayed equation?

MWE:

\documentclass[12pt]{article}
\usepackage[english]{babel}
\usepackage{amsmath}

\begin{document}

This is inline math: $\sum {a\pmod b}$

This is display math: $\sum {a\pmod b}$

This is display math with $\backslash$textstyle: $\textstyle \sum {a\pmod b}$

\end{document}


• The amsmath display environments set \if@display to true, but \textstyle has no influence over it, so you get the \mkern18mu nonetheless. You either want to modify the definition of \pod or to define a variant \tpmod command. By the way it should be \sum a\pmod{b}. – egreg Nov 29 '15 at 22:56
• @egreg okay, so you're suggesting I use a \mathchoice command? – justin Nov 29 '15 at 23:01
• Not at all; I suggest using \tpmod defined like \newcommand{\tpmod}[1]{\mkern 8mu({\operator@font mod}\mkern 6mu#1)} – egreg Nov 29 '15 at 23:08
• @egreg that looks like an answer:-) – David Carlisle Jan 30 '16 at 21:20

The amsmath package sets \if@display to true in displays; the primitive \textstyle has no influence over it. Since the standard definition of \pmod checks \if@display, you get the additional space nonetheless.

You have two strategies available. First strategy: redefine \pod (which \pmod depends on) so it doesn't add the space. This can be done with

\renewcommand{\pod}[1]{\allowbreak\mkern 8mu(#1)}


You should also change \mod to be consistent:

\makeatletter
\renewcommand{\mod}[1]{\allowbreak\mkern 12mu{\operator@font mod}\,\,#1}
\makeatother


Second strategy. If you want to be able to choose between the standard spacing and the reduced one, define a new command

\makeatletter
\newcommand{\tpmod}[1]{\mkern 8mu({\operator@font mod}\mkern 6mu#1)}
\makeatother