我目前有以下方程组代码:
\documentclass{article}
\usepackage{amsmath}
\usepackage{etoolbox}
\newcommand{\dpartial}[2]{\frac{\partial #1}{\partial #2}}
\AtBeginEnvironment{bmatrix}{\everymath{\displaystyle}} % \displaystyle systems of equations
\begin{document}
\begin{equation}
\begin{bmatrix}
m\dpartial{u}{T} & m\dpartial{u}{p} \\
-m\left(T\dpartial{R}{T} + R\right) & V - mT\dpartial{R}{p}
\end{bmatrix}
%
\begin{bmatrix}
\dot{T} \\
\dot{p}
\end{bmatrix} =
%
\begin{bmatrix}
\dot{Q} - p\dot{V} + \dot{m}(h-u) - m\dpartial{u}{\phi}\dot{\phi} \\
\dot{m}RT + mT\dpartial{R}{\phi}\dot{\phi} - p\dot{V}
\end{bmatrix}
\end{equation}
\end{document}
但结果却是这样的:
因此,我的问题是是否有一种方法来格式化方程组,使得包含 T 和 p 的导数的向量可以具有与其相邻矩阵相同的高度。
提前感谢您的帮助。
答案1
通过添加\vphantom{\dpartial{u}{p}}
到向量元素:
\documentclass{article}
\usepackage{amsmath}
\newcommand{\dpartial}[2]{\frac{\partial #1}{\partial #2}}
\usepackage{etoolbox}
\AtBeginEnvironment{bmatrix}{\everymath{\displaystyle}} % \displaystyle systems of equations
\begin{document}
\begin{equation}
\begin{bmatrix}
m\dpartial{u}{T} & m\dpartial{u}{p} \\
-m\left(T\dpartial{R}{T} + R\right) & V - mT\dpartial{R}{p}
\end{bmatrix}
%
\begin{bmatrix}
\dot{T}\vphantom{\dpartial{u}{p}} \\
\dot{p}\vphantom{\dpartial{u}{p}}
\end{bmatrix} =
%
\begin{bmatrix}
\dot{Q} - p\dot{V} + \dot{m}(h-u) - m\dpartial{u}{\phi}\dot{\phi} \\
\dot{m}RT + mT\dpartial{R}{\phi}\dot{\phi} - p\dot{V}
\end{bmatrix}
\end{equation}
\end{document}
附录: 考虑到@Mico 的评论,通过在行之间插入一些垂直空间,您将获得更好看的矩阵和向量。您可以通过多种方式实现这一点,例如:
- 通过终止行
\\[2ex]
- 通过
\addlinespace
在包中插入确定booktabs
:
\documentclass{article}
\usepackage{booktabs}
\usepackage{amsmath}
\newcommand{\dpartial}[2]{\frac{\partial #1}{\partial #2}}
\usepackage{etoolbox}
\AtBeginEnvironment{bmatrix}{\everymath{\displaystyle}} % \displaystyle systems of equations
\begin{document}
\begin{equation}
\begin{bmatrix}
m\dpartial{u}{T} & m\dpartial{u}{p} \\
\addlinespace
-m\biggl(T\dpartial{R}{T} + R\biggr) & V - mT\dpartial{R}{p}
\end{bmatrix}
%
\begin{bmatrix}
\dot{T}\vphantom{\dpartial{u}{p}} \\
\addlinespace
\dot{p}\vphantom{\dpartial{u}{p}}
\end{bmatrix} =
%
\begin{bmatrix}
\dot{Q} - p\dot{V} + \dot{m}(h-u) - m\dpartial{u}{\phi}\dot{\phi} \\
\addlinespace
\dot{m}RT + mT\dpartial{R}{\phi}\dot{\phi} - p\dot{V}
\end{bmatrix}
\end{equation}
\end{document}
- 通过使用包
\makegapedcells
中定义makecell
:
\documentclass{article}
\usepackage{makecell}
\usepackage{amsmath}
\newcommand{\dpartial}[2]{\frac{\partial #1}{\partial #2}}
\usepackage{etoolbox}
\AtBeginEnvironment{bmatrix}{\everymath{\displaystyle}} % \displaystyle systems of equations
\begin{document}
\begin{equation}
\setcellgapes{5pt}
\makegapedcells
\begin{bmatrix}
m\dpartial{u}{T} & m\dpartial{u}{p} \\
-m\biggl(T\dpartial{R}{T} + R\biggr) & V - mT\dpartial{R}{p}
\end{bmatrix}
%
\begin{bmatrix}
\dot{T}\vphantom{\dpartial{u}{p}} \\
\dot{p}\vphantom{\dpartial{u}{p}}
\end{bmatrix} =
%
\begin{bmatrix}
\dot{Q} - p\dot{V} + \dot{m}(h-u) - m\dpartial{u}{\phi}\dot{\phi} \\
\dot{m}RT + mT\dpartial{R}{\phi}\dot{\phi} - p\dot{V}
\end{bmatrix}
\end{equation}
\end{document}
答案2
使用{NiceArray}
,nicematrix
您可以在数组的前导中添加分隔符。您不需要\vphantom
。
\documentclass{article}
\usepackage{nicematrix}
\newcommand{\dpartial}[2]{\frac{\partial #1}{\partial #2}}
\begin{document}
\begin{equation*}
\everymath{\displaystyle}
\begin{NiceArray}{[cc][c]}
m\dpartial{u}{T} & m\dpartial{u}{p} & \dot{T} \\
-m\left(T\dpartial{R}{T} + R\right) & V - mT\dpartial{R}{p} & \dot{p}
\end{NiceArray}
=
\begin{bmatrix}
\dot{Q} - p\dot{V} + \dot{m}(h-u) - m\dpartial{u}{\phi}\dot{\phi} \\
\dot{m}RT + mT\dpartial{R}{\phi}\dot{\phi} - p\dot{V}
\end{bmatrix}
\end{equation*}
\end{document}
您需要多次编译(因为nicematrix
使用 PGF/Tikz 节点)。