# [Tex/LaTex] fit a very wide matrix

matrices

I'm tring to fit a 4×4 matrix that has long formulas as elements to A4 width.

\documentclass[]{scrbook}
\usepackage{amsmath}

\begin{document}
\begin{math}
\begin{bmatrix}
cos(a1)*cos(a4) - sin(a4)*(cos(a2)*cos(a3)*sin(a1) - sin(a1)*sin(a2)*sin(a3)) & cos(a4)*(cos(a2)*cos(a3)*sin(a1) - sin(a1)*sin(a2)*sin(a3)) - cos(a1)*sin(a4) & cos(a2)*sin(a1)*sin(a3) + cos(a3)*sin(a1)*sin(a2) & - b*sin(a1) - d*(cos(a2)*cos(a3)*sin(a1) - sin(a1)*sin(a2)*sin(a3)) - e*(cos(a2)*sin(a1)*sin(a3) + cos(a3)*sin(a1)*sin(a2)) - c*cos(a2)*sin(a1) \\
sin(a4)*(cos(a1)*cos(a2)*cos(a3) - cos(a1)*sin(a2)*sin(a3)) + cos(a4)*sin(a1) & cos(a4)*(cos(a1)*cos(a2)*cos(a3) - cos(a1)*sin(a2)*sin(a3)) - sin(a1)*sin(a4) & cos(a1)*cos(a2)*sin(a3) - cos(a1)*cos(a3)*sin(a2) & b*cos(a1) + d*(cos(a1)*cos(a2)*cos(a3) - cos(a1)*sin(a2)*sin(a3)) + e*(cos(a1)*cos(a2)*sin(a3) + cos(a1)*cos(a3)*sin(a2)) + c*cos(a1)*cos(a2) \\
sin(a4)*(cos(a2)*sin(a3) + cos(a3)*sin(a2)) & cos(a4)*(cos(a2)*sin(a3) + cos(a3)*sin(a2)) & cos(a2)*cos(a3) - sin(a2)*sin(a3) & a + d*(cos(a2)*sin(a3) + cos(a3)*sin(a2)) + e*(sin(a2)*sin(a3) - cos(a2)*cos(a3)) + c*sin(a2) \\
0 & 0 & 0 & 1
\end{bmatrix}
\end{math}
\end{document}


Is there a way to wrap the text?
Please be patient, I'm new to this.

This is how I will do it.

\documentclass[a4paper]{article}
\usepackage{amsmath}
\usepackage[margin=1in]{geometry}

\begin{document}
$\begin{bmatrix} A_{11} & A_{12} & A_{13} & A_{14} \\ B_{11} & B_{12} & B_{13} & B_{14} \\ C_{11} & C_{12} & C_{13} & C_{14} \\ 0 & 0 & 0 & 1 \end{bmatrix}$
where
\begin{align*}
A_{11} &= \cos(a1)*\cos(a4) - \sin(a4)*(\cos(a2)*\cos(a3)*\sin(a1) - \sin(a1)*\sin(a2)*\sin(a3)) \\
A_{12} &= \cos(a4)*(\cos(a2)*\cos(a3)*\sin(a1) - \sin(a1)*\sin(a2)*\sin(a3)) - \cos(a1)*\sin(a4) \\
A_{13} &= \cos(a2)*\sin(a1)*\sin(a3) + \cos(a3)*\sin(a1)*\sin(a2) \\
A_{14} &= {}-{} b*\sin(a1) - d*(\cos(a2)*\cos(a3)*\sin(a1) - \sin(a1)*\sin(a2)*\sin(a3)) \\
&\phantom{{}={}} - e*(\cos(a2)*\sin(a1)*\sin(a3)+ \cos(a3)*\sin(a1)*\sin(a2)) - c*\cos(a2)*\sin(a1) \\
B_{11} &= \sin(a4)*(\cos(a1)*\cos(a2)*\cos(a3) - \cos(a1)*\sin(a2)*\sin(a3)) + \cos(a4)*\sin(a1) \\
B_{12} &= \cos(a4)*(\cos(a1)*\cos(a2)*\cos(a3) - \cos(a1)*\sin(a2)*\sin(a3)) - \sin(a1)*\sin(a4) \\
B_{13} &= \cos(a1)*\cos(a2)*\sin(a3) - \cos(a1)*\cos(a3)*\sin(a2) \\
B_{14} &= b*\cos(a1) + d*(\cos(a1)*\cos(a2)*\cos(a3) - \cos(a1)*\sin(a2)*\sin(a3)) \\
&\phantom{=} + e*(\cos(a1)*\cos(a2)*\sin(a3) +
\cos(a1)*\cos(a3)*\sin(a2)) + c*\cos(a1)*\cos(a2) \\
C_{11} &= \sin(a4)*(\cos(a2)*\sin(a3) + \cos(a3)*\sin(a2)) \\
C_{12} &= \cos(a4)*(\cos(a2)*\sin(a3) + \cos(a3)*\sin(a2)) \\
C_{13} &= \cos(a2)*\cos(a3) - \sin(a2)*\sin(a3) \\
C_{14} &= a + d*(\cos(a2)*\sin(a3) + \cos(a3)*\sin(a2)) + e*(\sin(a2)*\sin(a3) \\
&\phantom{=}- \cos(a2)*\cos(a3)) + c*\sin(a2)
\end{align*}
\end{document}


Also, please use \sin, \cos instead of sin and cos.