我试图将具有长公式作为元素的 4x4 矩阵拟合到 A4 宽度。
\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}
有没有办法让文本换行?请耐心等待,我对此还不熟悉。
答案1
我会这样做。
\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}
此外,请使用\sin
,\cos
而不是sin
和cos
。
答案2
切勿使用诸如cos
多字母标识符的字母,数学斜体字体专为单字母变量名称而设计。\cos
在这种情况下使用,
我做了一些其他调整,但无论你做什么,这都将是不可读的,请考虑为子项定义一些变量,以便主矩阵显示更加合理。
\documentclass[]{scrbook}
\usepackage{amsmath,array}
\begin{document}
\begin{math}
\left[\begin{array}{*4{>{\centering\arraybackslash$}p{3.5cm}<{$}}}
\cos a_1\cos a_4 - \sin a_4(\cos a_2\cos a_3\sin a_1 - \sin a_1\sin a_2\sin a_3) \\
\cos a_4(\cos a_2\cos a_3\sin a_1 - \sin a_1\sin a_2\sin a_3) - \cos a_1\sin a_4 & \cos a_2\sin a_1\sin a_3 + \cos a_3\sin a_1\sin a_2 & - b\sin a_1 - d(\cos a_2\cos a_3\sin a_1 - \sin a_1\sin a_2\sin a_3) - e(\cos a_2\sin a_1\sin a_3 + \cos a_3\sin a_1\sin a_2) - c\cos a_2\sin a_1 \\
\sin a_4(\cos a_1\cos a_2\cos a_3 - \cos a_1\sin a_2\sin a_3) + \cos a_4\sin a_1 & \cos a_4(\cos a_1\cos a_2\cos a_3 - \cos a_1\sin a_2\sin a_3) - \sin a_1\sin a_4 & \cos a_1\cos a_2\sin a_3 - \cos a_1\cos a_3\sin a_2 & b\cos a_1 + d(\cos a_1\cos a_2\cos a_3 - \cos a_1\sin a_2\sin a_3) + e(\cos a_1\cos a_2\sin a_3 + \cos a_1\cos a_3\sin a_2) + c\cos a_1\cos a_2 \\
\sin a_4(\cos a_2\sin a_3 + \cos a_3\sin a_2) & \cos a_4(\cos a_2\sin a_3 + \cos a_3\sin a_2) & \cos a_2\cos a_3 - \sin a_2\sin a_3 & a + d(\cos a_2\sin a_3 + \cos a_3\sin a_2) + e(\sin a_2\sin a_3 - \cos a_2\cos a_3) + c\sin a_2 \\
0 & 0 & 0 & 1
\end{array}\right]
\end{math}
\end{document}
答案3
使用缩写并以矩阵符号写出:
\documentclass{scrbook}
\usepackage{geometry}
\usepackage{mathtools}
\begin{document}
$
\begin{array}{@{}l}
c1=\cos(a1)\\
c2=\cos(a2)\\
c3=\cos(a3)\\
c4=\cos(a4)\\
s1=\sin(a1)\\
s2=\sin(a2)\\
s3=\sin(a3)\\
s4=\sin(a4)\\
c12=c1*c2\\
c13=c1*c3\\
c14=c1*c4\\
c23=c2*c3\\
c123=c1*c2*c3\\
s12=s1*s2\\
s13=s1*s3\\
s14=s1*s4\\
s23=s2*s3\\
s123=s1*s2*s3
\end{array}$
$\left[\begin{array}{@{}llll@{}}
c14 - s4*(c23*s1 - s123) & c4*(c23*s1 - s123) - c1*s4 & c2*s13 + c3*s12 \\
\multicolumn{4}{r@{}}{ - b*s1 - d*(c23*s1 - s123) - e*(c2*s13 + c3*s12) - c*c2*s1} \\
s4*(c123 - c1*s23) + c4*s1 & c4*(c123 - c1*s23) - s14 & c12*s3 - c13*s2 \\
\multicolumn{4}{r@{}}{ b*c1 + d*(c123 - c1*s23) + e*(c12*s3 + c13*s2) + c*c12 }\\
s4*(c2*s3 + c3*s2) & c4*(c2*s3 + c3*s2) & c23 - s23 \\
\multicolumn{4}{r@{}}{ a + d*(c2*s3 + c3*s2) + e*(s23 - c23) + c*s2} \\
0 & 0 & 0 & 1
\end{array}\right]$
\bigskip
or
\bigskip
$\left[\begin{array}{@{}lll@{}}
c14 - s4*(c23*s1 - s123) & c4*(c23*s1 - s123) - c1*s4 & c2*s13 + c3*s12 \\
s4*(c123 - c1*s23) + c4*s1 & c4*(c123 - c1*s23) - s14 & c12*s3 - c13*s2 \\
s4*(c2*s3 + c3*s2) & c4*(c2*s3 + c3*s2) & c23 - s23 \\
0 & 0 & 0
\end{array}\right] + $
$+ \left[\begin{array}{@{}l@{}}
- b*s1 - d*(c23*s1 - s123) - e*(c2*s13 + c3*s12) - c*c2*s1 \\
b*c1 + d*(c123 - c1*s23) + e*(c12*s3 + c13*s2) + c*c12 \\
a + d*(c2*s3 + c3*s2) + e*(s23 - c23) + c*s2 \\
1
\end{array}\right]$
\end{document}