答案1
您可以使用mathtools
提供的bmatrix*
\documentclass{article}
\usepackage{mathtools} % also loads amsmath
\begin{document}
You can get left alignment
\begin{equation*}
\mathbf{J}_{f} =
\begin{bmatrix*}[l]
-2 x \sin(y) ^{2} & -2x^{2}\sin(y) \cos(y) & 0
\\
\sin(y) & x \cos(y) & 0
\\
2x & 0 & 0
\end{bmatrix*}.
\end{equation*}
or, alternatively, right alignment
\begin{equation*}
\mathbf{J}_{f} =
\begin{bmatrix*}[r]
-2 x \sin(y) ^{2} & -2x^{2}\sin(y) \cos(y) & 0
\\
\sin(y) & x \cos(y) & 0
\\
2x & 0 & 0
\end{bmatrix*}.
\end{equation*}
but I find neither to be prettier than with the standard
center alignment
\begin{equation*}
\mathbf{J}_{f} =
\begin{bmatrix}
-2 x \sin(y) ^{2} & -2x^{2}\sin(y) \cos(y) & 0
\\
\sin(y) & x \cos(y) & 0
\\
2x & 0 & 0
\end{bmatrix}.
\end{equation*}
\end{document}
一些不相关的评论。在这种情况下避免使用\left
和\right
:它们只会增加不必要的间距。还align
应该用于对齐几个方程。
答案2
array
使用环境(甚至没有)就可以获得右对齐amsmath
。
\documentclass{article}
\begin{document}
Right alignment can be obtained using \verb|array| environment.
\begin{equation}
\mathbf{J}_{f} =\left[
\begin{array}{rrr}
-2 x \sin(y) ^{2}&-2x^{2}\sin(y) \cos(y) & 0 \\
\sin(y) & x \cos(y) & 0 \\
2x & 0 & 0
\end{array}\right].
\end{equation}
\end{document}
答案3
旧软件包还spalign
提供了右/中/左对齐矩阵。事实上,您可以看到可以获得与其他用户相同的输出。
\documentclass[a4paper,12pt]{article}
\usepackage{amsmath,amssymb}
\usepackage{spalign}
\usepackage{parskip}
\begin{document}
Center option
\[\mathbf{J}_{f}=\spaligndelims{[}{]}
\spalignmat[c]{-2x\sin(y)^{2} -2x^{2}\sin(y)\cos(y) 0; \sin(y) x\cos(y) 0; 2x 0 0}
.\]
Left option
\[\mathbf{J}_{f}=\spaligndelims{[}{]}
\spalignmat[l]{-2x\sin(y)^{2} -2x^{2}\sin(y)\cos(y) 0; \sin(y) x\cos(y) 0; 2x 0 0}
.\]
Right option
\[\mathbf{J}_{f}=\spaligndelims{[}{]}
\spalignmat[r]{-2x\sin(y)^{2} -2x^{2}\sin(y)\cos(y) 0; \sin(y) x\cos(y) 0; 2x 0 0}
.\]
\end{document}
答案4
环境{bNiceMatrix}
具有nicematrix
(除其他功能外)用于水平对齐的键r
和。l
\documentclass{article}
\usepackage{nicematrix}
\begin{document}
You can get left alignment
\begin{equation*}
\mathbf{J}_{f} =
\begin{bNiceMatrix}[l]
-2 x \sin(y) ^{2} & -2x^{2}\sin(y) \cos(y) & 0
\\
\sin(y) & x \cos(y) & 0
\\
2x & 0 & 0
\end{bNiceMatrix}.
\end{equation*}
or, alternatively, right alignment
\begin{equation*}
\mathbf{J}_{f} =
\begin{bNiceMatrix}[r]
-2 x \sin(y) ^{2} & -2x^{2}\sin(y) \cos(y) & 0
\\
\sin(y) & x \cos(y) & 0
\\
2x & 0 & 0
\end{bNiceMatrix}.
\end{equation*}
\end{document}