3

I am interested in making matrices like this:

enter image description here

I have tried like this:

    \documentclass{article}
\usepackage{amsmath}
\begin{document}
    $\langle\mkern-1.5mu
    \begin{matrix}
        1\\2\\3
    \end{matrix}
    \mkern2mu\rangle
    $
\end{document}

which produces

enter image description here How do I make a matrix with \rangle and langle?

Alezigl
  • 375

1 Answers1

3

As a basic element, \left and \right can be used to automatically adjust the size of delimiters such as brackets, braces etc. to the material in between. This also works with \left\langle\begin{matrix}...\end{matrix}\right\langle:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
$\left\langle
  \begin{matrix}
    1\\2\\3
  \end{matrix}
\right\rangle$
\end{document}

enter image description here

As can be seen in the image, the angles do not quite reach over the digits. This can be changed with the help of the yhmath package:

\documentclass{article}
\usepackage{amsmath}
\usepackage{yhmath}
\begin{document}
$\left\langle
  \begin{matrix}
    1\\2\\3
  \end{matrix}
\right\rangle$
\end{document}

or just

\documentclass{article}
\usepackage{amsmath}% not needed in this case
\usepackage{yhmath}
\begin{document}
$\begin{amatrix}
    1\\2\\3
  \end{amatrix}$
\end{document}

Both result in:

enter image description here

If you like the angles of the amsmath example more, but also like the idea of a amatrix you can define it similar to, e.g., bmatrix from amsmath.sty:

\documentclass{article}
\usepackage{amsmath}
\makeatletter
\newenvironment{amatrix}{\left\langle\env@matrix}{\endmatrix\right\rangle}
\makeatother
\begin{document}
$\begin{amatrix}
    1\\2\\3
  \end{amatrix}$
\end{document}

The result is the same as shown in the first example.

Note: Sometimes the size decision of \left and \right is not the best. In such cases using an explicit size with \big, \bigg, \Big, \Bigg can help, but for matrices these sizes are very limited. But for matrices IMHO the sizes with \left and \right are mostly suitable.

cabohah
  • 11,455