Consider the following MnotWE:
\documentclass[12pt,letterpaper]{article}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{calc}
\newcommand{\scaleandcenter}[2]{\vcenter{\hbox{\scalebox{#1}{$#2$}}}}
\newcommand{\binscaled}[2]{\mathbin{\scaleandcenter{#1}{#2}}}
\newcommand{\smallbin}[1]{\binscaled{0.5}{#1}}
\newcommand{\setbinprecedence}[2]{\setlength{\medmuskip}{(1 + #1)*1mu plus (1 + #1)*1mu minus (1 + #1)*1mu} {#2}}
\let\origtimes\times
\renewcommand{\times}{\setbinprecedence{0}{\smallop{\origtimes}}}
\begin{document}
\begin{equation*}
a\times b + c\times b = 0
\end{equation*}
\end{document}
It produces errors, because it doesn't like how I am using arguments in the arithmetic within the \setlength command. How do I properly pass an argument as a number for use within a calc package command?
Purpose: I would like to set up a kind of "visual precedence" style, where operands for my custom \times are tighter around it than the operands around the +, because \times should have "higher precedence" than +. Another way to say it: "visually" the operands around times should be grouped tightly around it, to pass on intuitively the notion that times should be performed first. So I was hoping to set custom medmuskips (including stretches and shrinks) depending on the precedence level of the operator.


\setvaluesimply because\setvaluehas not been defined. thecalcpackage is not involved in the error. – David Carlisle Sep 17 '17 at 22:14\setlengthcommand worked (it doesn't withmulengths with thecalcpackage), this would not do: TeX uses a single value for\medmuskipin the whole formula, namely the one in force at the end of the formula. Besides,\timesshould be a\mathbin, not a\mathop. – egreg Sep 17 '17 at 22:17\setvaluenot being defined, it is not clear what the intention of\setbinprecedenceis, it makes a{..}group so will always be a mathord and the inner setting of\mathopwill be lost. – David Carlisle Sep 17 '17 at 22:18\medmuskipjust for a particular command. – bzm3r Sep 17 '17 at 22:27Illegal unit of measurebut this is unrelated to passing arguments through\newcommandyou can not use calc syntax with mu units, and in anycase changing\medmuskipat that point would have no effect. – David Carlisle Sep 17 '17 at 22:27