Matrix in Equation – How to Include a Matrix within an Equation in LaTeX

equationsmath-modematricessetspace

I am having some difficulty getting this to display properly.

 \begin{equation}
{\bf H} = -{\bf \mu} \cdot {\bf B} = - \gamma B_o {\bf S}_z = -\frac{\gamma B_o\hbar}{2} 
\begin{bmatrix} 1&0\\0&-1 \end{bmatrix}.
\end{equation}

Which appears as,

Ugly looking equation

I would like the matrix height to be consistant with the rest of the equation.

Best Answer

\documentclass{article}
\usepackage{amsmath}
\usepackage[nodisplayskipstretch]{setspace}
\doublespacing
\everydisplay\expandafter{\the\everydisplay\setstretch{1}}% return to singlespacing

\begin{document}
\begin{equation}
\mathbf{H} = -\mathbf\mu \cdot \mathbf{B} = -\gamma B_o \mathbf{S}_z = -\frac{\gamma B_o\hbar}{2} 
\begin{bmatrix} 1&0\\0&-1 \end{bmatrix}.
\end{equation}

\end{document} 
Related Question