[Tex/LaTex] Split long expression inside bmatrix environment

matrices

I am new to this and so please excuse my ignorance.

I have an equation Ax = b, where A is a 3 x 3 matrix. Because some of the elements in the matrix A contain long expressions, latex is not able to fit the equation neatly across the page (it causes the equation number to overspill, see image below). I wish to avoid splitting the matrix A over two rows. Instead, I would like to split the (long) elements over two lines if possible such that the equation fits on one row across the page. Any help would be greatly appreciated. My code is as follows:enter image description here

\documentclass[11pt]{book}
\usepackage{amsmath,amsfonts,amssymb,amsthm, bm}

\begin{document}

\begin{equation}
\begin{bmatrix}
\mathbf{i}_{w}\\ 
\mathbf{j}_{w}\\ 
\mathbf{k}_{w}
\end{bmatrix} = \begin{bmatrix}
\cos\gamma \cos\chi & \cos\gamma \sin\chi & -\sin\chi \\ 
\sin\mu \sin\gamma \cos\chi - \cos\mu \sin\chi & \sin\mu \sin\gamma \sin\chi + \cos\mu \cos\chi & \sin\mu \cos\gamma \\ 
\cos\mu \sin\gamma \cos\chi + \sin\mu \sin\chi & \cos\mu\sin\gamma\sin\chi-\sin\mu\cos\chi & \cos\mu\cos\gamma
\end{bmatrix}  \begin{bmatrix}
\mathbf{i}_{h}\\ 
\mathbf{j}_{h}\\ 
\mathbf{k}_{h}
\end{bmatrix}
\end{equation}

\end{document} 

Best Answer

You can nest matrix, giving some more room between the main rows.

\documentclass[11pt]{book}
\usepackage{amsmath,amssymb,amsthm, bm}

\begin{document}

\begin{equation}
\begin{bmatrix}
\mathbf{i}_{w}\\ 
\mathbf{j}_{w}\\ 
\mathbf{k}_{w}
\end{bmatrix} = \begin{bmatrix}
\cos\gamma \cos\chi & \cos\gamma \sin\chi & -\sin\chi \\[1ex]
\begin{matrix}
  \sin\mu \sin\gamma \cos\chi \\
  \hfill{}- \cos\mu \sin\chi
\end{matrix}
 & 
\begin{matrix}
  \sin\mu \sin\gamma \sin\chi \\
  \hfill{}+ \cos\mu \cos\chi
\end{matrix}
 & \sin\mu \cos\gamma \\[2.5ex]
\begin{matrix}
  \cos\mu \sin\gamma \cos\chi \\
  \hfill{}+ \sin\mu \sin\chi
\end{matrix}
 &
\begin{matrix}
  \cos\mu\sin\gamma\sin\chi \\
  \hfill{}- \sin\mu\cos\chi
\end{matrix}
 & \cos\mu\cos\gamma
\end{bmatrix}  \begin{bmatrix}
\mathbf{i}_{h}\\ 
\mathbf{j}_{h}\\ 
\mathbf{k}_{h}
\end{bmatrix}
\end{equation}

\end{document} 

enter image description here

You can also align the columns, by replicating the contents with phantoms:

\documentclass[11pt]{book}
\usepackage{amsmath,amssymb,amsthm, bm}

\begin{document}

\begin{equation}
\begin{bmatrix}
\mathbf{i}_{w}\\[1ex]
\mathbf{j}_{w}
\vphantom{\begin{matrix}
  \sin\mu \sin\gamma \cos\chi \\
  \hfill{}- \cos\mu \sin\chi
  \end{matrix}
}
\\[2.5ex]
\mathbf{k}_{w}
\vphantom{\begin{matrix}
  \cos\mu \sin\gamma \cos\chi \\
  \hfill{}+ \sin\mu \sin\chi
  \end{matrix}
}
\end{bmatrix} = \begin{bmatrix}
\cos\gamma \cos\chi & \cos\gamma \sin\chi & -\sin\chi \\[1ex]
\begin{matrix}
  \sin\mu \sin\gamma \cos\chi \\
  \hfill{}- \cos\mu \sin\chi
\end{matrix}
 & 
\begin{matrix}
  \sin\mu \sin\gamma \sin\chi \\
  \hfill{}+ \cos\mu \cos\chi
\end{matrix}
 & \sin\mu \cos\gamma \\[2.5ex]
\begin{matrix}
  \cos\mu \sin\gamma \cos\chi \\
  \hfill{}+ \sin\mu \sin\chi
\end{matrix}
 &
\begin{matrix}
  \cos\mu\sin\gamma\sin\chi \\
  \hfill{}- \sin\mu\cos\chi
\end{matrix}
 & \cos\mu\cos\gamma
\end{bmatrix}  \begin{bmatrix}
\mathbf{i}_{h}\\[1ex]
\mathbf{j}_{h}
\vphantom{\begin{matrix}
  \sin\mu \sin\gamma \cos\chi \\
  \hfill{}- \cos\mu \sin\chi
  \end{matrix}
}
\\[2.5ex]
\mathbf{k}_{h}
\vphantom{\begin{matrix}
  \cos\mu \sin\gamma \cos\chi \\
  \hfill{}+ \sin\mu \sin\chi
  \end{matrix}
}
\end{bmatrix}
\end{equation}

\end{document} 

enter image description here

Now judge yourself about the aesthetics.