Splitting a formula
I think this is one of those problems where some local redefinitions could be very useful.
I've defined matrices A
and p
in the below, and used \cdot
instead of \times
(assuming that this doesn't change the meaning drastically- if it does, let me know)
I've also used align
instead of eqnarray
as detailed in eqnarray vs align
\documentclass{scrartcl}
\usepackage{amsmath}
\begin{document}
We have the matrix equation
\begin{align}
P2'' &= A \cdot p
\end{align}
where
\[
A=\begin{pmatrix}
(1-\cos \alpha) \cdot x\cdot x + \cos \alpha (1-\cos \alpha) \cdot x\cdot y -\sin \alpha \cdot z (1-\cos \alpha) \cdot x\cdot z +\sin \alpha \cdot y \\
(1-\cos \alpha) \cdot x\cdot y + \sin \alpha \cdot z (1-\cos \alpha) \cdot y\cdot y + \cos \alpha (1-\cos \alpha) \cdot y\cdot z - \sin \alpha \cdot x \\
(1-\cos \alpha) \cdot x\cdot z - \sin \alpha \cdot y (1-\cos \alpha) \cdot y\cdot z + \sin \alpha \cdot x (1-\cos \alpha) \cdot z\cdot z + \cos \alpha
\end{pmatrix}
\]
and
\[
p=\begin{pmatrix}
p2‘_X \\
p2‘_Y \\
p2‘_Z
\end{pmatrix}
\]
\end{document}
here's a different approach.
major changes:
eqnarray
is replaced byalign
;- i've replaced
\times
by\cdot
as suggested by azetina; - the multiple lines of the first
pmatrix
have been packed into aminipage
and within the box,multlined
frommathtools
has been used, with alternate "middle" lines shoved left or right as appropriate; - math has to be specified explicitly within the minipage;
multlined
doesn't seem to want to use the entire specified width of theminipage
so some extra space had to be added to the right-adjusted lines;pmatrix
doesn't like just a single line (theminipage
), so it was replaced with\left( ... \right)
;minipage
width was adjusted by experiment, and a small\vspace
added at the top for better appearance.
\documentclass{scrartcl}
\usepackage{mathtools}
\begin{document}
\begin{align}
P2 &=
\left(
{\begin{minipage}{.72\textwidth}
\vspace{2pt}
\abovedisplayskip=2pt \abovedisplayshortskip=2pt
$\begin{multlined}
(1-\cos \alpha) \cdot x\cdot x + \cos \alpha (1-\cos \alpha)\\
\shoveright{\kern8em
\cdot x\cdot y -\sin \alpha \cdot z (1-\cos \alpha)
\cdot x\cdot z +\sin \alpha \cdot y } \\
\shoveleft{
(1-\cos \alpha) \cdot x\cdot y + \sin \alpha \cdot z (1-\cos \alpha) } \\
\shoveright{\kern8em
\cdot y\cdot y + \cos \alpha (1-\cos \alpha)
\cdot y\cdot z - \sin \alpha \cdot x } \\
\shoveleft{
(1-\cos \alpha) \cdot x\cdot z - \sin \alpha \cdot y (1-\cos \alpha) } \\
\kern8em
\cdot y\cdot z + \sin \alpha \cdot x (1-\cos \alpha)
\cdot z\cdot z + \cos \alpha
\end{multlined}$
\end{minipage}}
\right) \\
&\quad\cdot
\begin{pmatrix}
p2_X \\
p2_Y \\
p2_Z
\end{pmatrix}
\end{align}
\end{document}
A variation of barbara's idea, but without the added complications. Just use \hfill
in suitable places in order to shove left or right the entry. To one of them I add a fixed space, to give more room. Also some vertical spacings are used to separate each "cell" from the next.
\documentclass{scrartcl}
\usepackage{amsmath}
\begin{document}
\begin{equation}
P2 =
\begin{pmatrix}
(1-\cos\alpha) \cdot x\cdot x + \cos\alpha (1-\cos\alpha) \cdot x\cdot y \hfill
\hspace{2.5pc} %%% space added to a wide half line, adjust visually
\\
\hfill{}-\sin\alpha \cdot z (1-\cos\alpha) \cdot x\cdot z +\sin\alpha \cdot y
\\[1ex]
(1-\cos\alpha) \cdot x\cdot y + \sin\alpha \cdot z (1-\cos\alpha) \cdot y\cdot y \hfill\\
\hfill{}+ \cos\alpha (1-\cos\alpha) \cdot y\cdot z - \sin\alpha \cdot x
\\[1ex]
(1-\cos\alpha) \cdot x\cdot z - \sin\alpha \cdot y (1-\cos\alpha) \cdot y\cdot z \hfill\\
\hfill{}+ \sin\alpha \cdot x (1-\cos\alpha) \cdot z\cdot z + \cos\alpha
\end{pmatrix}
\cdot
\begin{pmatrix}
p2_X \\[1ex]
p2_Y \\[1ex]
p2_Z
\end{pmatrix}
\end{equation}
\end{document}