# New modulo operator

I am trying to define new operator %. I tried to make it smaller but it also made spacing around it smaller. How can I reduce operator size without changing spacing around operator? Thanks for help guys

\documentclass{article}
\usepackage{graphicx}
\usepackage{relsize}
\newcommand{\modd}{\mathsmaller{\mathbin{\%}}}
\begin{document}
$x \modd y$
\end{document}

• I'd say you want \mathbin{\mathsmaller{\%}} – egreg Aug 2 '16 at 14:25
• @egreg The problem with that approach is it produces a big % when used in \displaystyle. – Steven B. Segletes Aug 2 '16 at 14:27
• @StevenB.Segletes Correct. – egreg Aug 2 '16 at 14:31

Here I use the star from of \DeclareMathOperator, so that displaystyle sub/super-scripts are above and below the operator (if needed). Use without the * if you want the subscript to remain as a subscript in style, rather than below the operator.

\documentclass{article}
\usepackage{graphicx}
\usepackage{relsize}
\usepackage{mathtools}
\DeclareMathOperator*{\modd}{\scriptstyle\%}
\begin{document}
$x \modd y$
$x \modd y$
$x \modd_1 y$
$x \modd_1 y$
\end{document}


If you need it to work in the smaller math styles, then

\DeclareMathOperator*{\modd}{%
\mathchoice{\scriptstyle\%}{\scriptstyle\%}{\scriptscriptstyle\%}{\scriptscriptstyle\%}}

• The spacing is incorrect; try $a\modd(b+c)$ – egreg Aug 2 '16 at 14:35
• @egreg Thanks for snatching defeat from the jaws of victory 8^b – Steven B. Segletes Aug 2 '16 at 14:39

You want to reverse the roles of \mathbin and \mathsmaller: However, \mathsmaller has to be used with care.

\documentclass{article}
\usepackage{graphicx}
\usepackage{relsize}
\newcommand{\modd}{\mathbin{\mathchoice
{\textstyle\mathsmaller{\%}}
{\mathsmaller{\%}}
{\mathsmaller{\%}}
{\mathsmaller{\%}}
}}

\begin{document}

$\displaystyle x \modd y$

$x \modd y$

$\scriptstyle x \modd y$

$\scriptscriptstyle x \modd y$

\end{document}