[Tex/LaTex] How to define an inner product argument in LaTeX

formattingmath-mode

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.

Best Answer

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

Sample output

\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.

Related Question