I would like to define custom text operators in math mode, such as "if", "then", "catch". These operators should always be preceded and succeeded by some space. Surrounding my operators with \mathrel brings me already quite close to what I want to achieve; however, when there is an equals sign (=) before an operator, there is no space between the two.
MWE:
\documentclass{minimal} \usepackage{amsmath} \begin{document} \newcommand{\relname}[1]{\mathrel{\operatorname{#1}}} \newcommand{\ite}[3]{\relname{if} #1 \relname{then} #2 \relname{else} #3} $\ite{a}{b}{c}$ (good) $x = \ite{a}{b}{c}$ (bad --- insufficient space after "=") % https://tex.stackexchange.com/questions/680197/no-spacing-after-binary-operator-after-math-operator \renewcommand{\relname}[1]{\mathop{}\!\mathrel{\operatorname{#1}}} $\ite{a}{b}{c}$ (bad --- too much space before "if") $x = \ite{a}{b}{c}$ (good) % https://tex.stackexchange.com/questions/46402/defining-a-prefix-operator-with-space-before-its-argument \renewcommand{\relname}[1]{\mathinner{\operatorname{#1}}} $\ite{a}{b}{c}$ (too cramped) $x = \ite{a}{b}{c}$ (too cramped) \end{document} 
