# How to define an inner product argument in LaTeX

I would like to make an inner-product symbol for my math paper. I would like it to work along the lines of \frac{arg1}{arg2}. Specifically, I would like to make a function, so that I could say

\inner{arg1}{arg2},

and get something that looked like

\langle arg1, arg2 \rangle. If someone could guide me through how to do this, it would be appreciated.

• What I do is add \let\<\langle and \let\>\rangle to my preamble and then use \<a,b\> in the document. Alternatively, you could use something like\def\<#1,#2>{\langle #1,\,#2\rangle} and then \<a,b>. – Andrew May 11 '16 at 7:44

Using mathtools you can make a definition that allows resizing of the brackets when necessary.

\documentclass{article}

\usepackage{mathtools}

\DeclarePairedDelimiterX{\inp}[2]{\langle}{\rangle}{#1, #2}

\begin{document}

$$\inp{\mathbf u}{\mathbf v}$$

\begin{equation*}
\inp*{\frac1n\mathbf u}{\frac 2n\mathbf v} =
\inp[\Big]{\frac1n\mathbf u}{\frac 2n\mathbf v}
\end{equation*}

\end{document}


In this version \inp just prints standard sized brackets and \inp* uses \left...\right to scale the brackets to enclose the material. Often \inp* will produce brackets that are too big, and manual scaling can be provided by \inp[\big], \inp[\Big], \inp[\bigg], \inp[\Bigg] etc.

\newcommand\inner[2]{\langle #1, #2 \rangle}

• Thank you so much. Does this work to create any function, like these? – 9301293 May 11 '16 at 7:44
• @phatty Yes. You may read section 6.1.1 of The Not So Short Introduction to LATEX 2e. – Paul Gaborit May 11 '16 at 8:36
• Nte that this has the defect of not being able to scale the fences if you ever need to. – daleif May 11 '16 at 8:51
• @daleif You can always add \left and \right before \langle and \rangle, respectively, to get automatic scaling – Daniel May 4 '17 at 17:08
• @Daniel which, of course, is a very bad idea. Too many cases where they scale too much. – daleif May 4 '17 at 17:35