我正在使用 LaTeX 编写这个雅可比矩阵:
\mathbf{u_{i,j}}=\left[\begin{array}{ccc}
\frac{\partial u_1}{\partial x_1} & \frac{\partial u_1}{\partial x_2} & \frac{\partial u_1}{\partial x_3} \\
\frac{\partial u_2}{\partial x_1} & \frac{\partial u_2}{\partial x_2} & \frac{\partial u_2}{\partial x_3 \\
\frac{\partial u_3}{\partial x_1} & \frac{\partial u_3}{\partial x_2} & \frac{\partial u_3}{\partial x_3
\end{array}\right],
但它没有被编译。
我该如何写这个?
答案1
@Sebastiano回答显示了您需要做什么才能使代码编译时不出现错误或警告消息。为了使矩阵更易于阅读和更具视觉吸引力,您可能还需要 (a) 增加行之间的空白量和 (b) 使用环境bmatrix
(由包提供amsmath
)代替基本array
环境来更紧凑地排版矩阵 - 具体来说,方括号和矩阵本身之间的空间更小。
\documentclass{article}
\usepackage{amsmath} % for 'bmatrix' environment
\begin{document}
\[
\mathbf{u}_{i,j} =
\begin{bmatrix}
\frac{\partial u_1}{\partial x_1} &
\frac{\partial u_1}{\partial x_2} &
\frac{\partial u_1}{\partial x_3} \\[1ex] % <-- 1ex more space between rows of matrix
\frac{\partial u_2}{\partial x_1} &
\frac{\partial u_2}{\partial x_2} &
\frac{\partial u_2}{\partial x_3} \\[1ex]
\frac{\partial u_3}{\partial x_1} &
\frac{\partial u_3}{\partial x_2} &
\frac{\partial u_3}{\partial x_3}
\end{bmatrix}
\]
\end{document}
答案2
如同米科的答案...
但是,为了缩短代码编写时间,请使用以下physics
包:
\documentclass{article}
\usepackage{amsmath} % for 'bmatrix' environment
\usepackage{physics} % for 'pdv' macro
\begin{document}
\[\renewcommand\arraystretch{1.6}
\mathbf{u}_{i,j} =
\begin{bmatrix}
\pdv{u_1}{x_1} &
\pdv{u_1}{x_2} &
\pdv{u_1}{x_3} \\%[1ex] % <-- 1ex more space between rows of matrix
\pdv{u_2}{x_1} &
\pdv{u_2}{x_2} &
\pdv{u_2}{x_3} \\%[1ex]
\pdv{u_3}{x_1} &
\pdv{u_3}{x_2} &
\pdv{u_3}{x_3}
\end{bmatrix}
\]
\end{document}
答案3
首先,您有两个语法错误,即,}
在 之后缺少两个 (右花括号) \partial x_3
。其次,array
环境必须置于数学模式。
\documentclass[a4paper]{article}
\usepackage{amsmath}
\begin{document}
\[
\mathbf{u_{i,j}}=\left[\begin{array}{ccc}
\frac{\partial u_1}{\partial x_1} & \frac{\partial u_1}{\partial x_2} & \frac{\partial u_1}{\partial x_3} \\
\frac{\partial u_2}{\partial x_1} & \frac{\partial u_2}{\partial x_2} & \frac{\partial u_2}{\partial x_3} \\
\frac{\partial u_3}{\partial x_1} & \frac{\partial u_3}{\partial x_2} & \frac{\partial u_3}{\partial x_3}
\end{array}\right]
\]
\end{document}