This has most likely been asked before, but I wasn't able to articulate the question in a way that yielded relevant search results.

How do you declare a math operator to simplify an expression such as \langle x, y \rangle? I want to be able to define something like \innerproduct{x, y} instead.


I suggest you load the mathtools package and use its \DeclarePairedDelimiter macro to define a macro called, say, \inprod. This method automatically declares a companion macro called \inprod*, which auto-sizes the angle brackets. The size of the "fences" can be controlled directly as well, by writing \inprod[\big]{...}, \inprod[\Big]{...}, etc.

enter image description here


$\displaystyle \inprod*{\frac{a}{b},\frac{c}{d}}$


A variant of the mathtools solution, which takes care of empty arguments, with the xparse and etoolbox packages. It uses two arguments, separated by a comma; if some argument is empty, it is replaced with a dot:

\usepackage{mathtools, nccmath}
\usepackage{xparse, etoolbox}

{\ifblank{#2}{\,\cdot\,{,}\,\cdot\,}{{\,\cdot \,}{,}{\mkern2mu#2}}}%


\[ \innerp{x, y}, \quad \innerp[\big]{\tfrac{1}{2}x, y} \quad \innerp*{\frac{x}{2}, y}\quad\innerp{x , }\quad \innerp{ , y}\quad \innerp{ , }\]


enter image description here


In fact I remember a conversation about precisely this, but it may take me a while to find it. In the meantime:

  • \def\iprelay#1,#2\relax{\langle#1,#2\rangle} \def\ip#1{\iprelay#1\relax} would be much safer. – Manuel Mar 13 '18 at 0:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.