我正在用 latex 写论文,但表格设置有问题。我想让所有方程式都左对齐,并且第一行和最后一行的高度要小一些。这是我的代码
\begin{table}\centering
\begin{tabular}{ m{3cm} m{10cm} }\hline
Continuity & {\begin{equation}
\frac{\partial \rho}{\partial t}+\nabla\cdot\left ( \rho\mathbf{V}\right )
=0\label{continuity_1}\end{equation}}\\
x-momentum\newline\newline y-momentum\newline\newline z-momentum & {\begin{subequations}\begin{align}
&\frac{\left ( \partial \rho u\right ) }{\partial t}+\nabla\cdot\left ( \rho u\mathbf{V}\right ) = -\frac{\partial p}{\partial x}+\nabla\cdot\left ( \mu\nabla u\right ) +S_{Mx}\\
&\frac{\left ( \partial \rho v\right ) }{\partial t}+\nabla\cdot\left ( \rho v\mathbf{V}\right ) = -\frac{\partial p}{\partial y}+\nabla\cdot\left ( \mu\nabla v\right ) +S_{My}\\
&\frac{\left ( \partial \rho w\right ) }{\partial t}+\nabla\cdot\left ( \rho w\mathbf{V}\right ) = -\frac{\partial p}{\partial z}+\nabla\cdot\left ( \mu\nabla w\right ) +S_{Mz}
\end{align}\label{NS_eq1}\end{subequations}}\\
Energy & {\begin{equation}
\frac{\left ( \partial \rho e\right ) }{\partial t}+\nabla\cdot\left ( \rho e\mathbf{V}\right ) =-p\nabla\cdot\mathbf{V}+\nabla\left ( k\nabla T \right ) + \Phi + S_{i} \label{energy_1}\end{equation}}\\
\hline\end{tabular}\caption{Governing equations of flow for a Newtonian fluid}\label{NS_eqt}\end{table}
答案1
要左对齐方程,可以使用flalign
(另见这里\abovedisplayskip
)。可以使用和来控制显示数学周围的间隙\belowdisplayskip
,但即便如此,我也必须调整行距。您还会注意到文本实际上与子方程式并不对齐。
需要注意的是,方程编号是在创建表格时设置的,而不是在显示表格时设置的。
\documentclass{article}
\usepackage{mathtools}
\usepackage{array}
\begin{document}
\begin{table}\centering
\abovedisplayskip=0pt
\belowdisplayskip=0pt
\begin{tabular}{ m{3cm} m{10cm} }\hline
Continuity & {\begin{flalign}
\frac{\partial \rho}{\partial t}+\nabla\cdot\left ( \rho\mathbf{V}\right )=0&&
\label{continuity_1}\end{flalign}}\\[-2ex]
x-momentum\newline\newline y-momentum\newline\newline z-momentum & {\begin{subequations}\begin{flalign}
&\frac{\left ( \partial \rho u\right ) }{\partial t}+\nabla\cdot\left ( \rho u\mathbf{V}\right )
= -\frac{\partial p}{\partial x}+\nabla\cdot\left ( \mu\nabla u\right ) +S_{Mx}&\\
&\frac{\left ( \partial \rho v\right ) }{\partial t}+\nabla\cdot\left ( \rho v\mathbf{V}\right )
= -\frac{\partial p}{\partial y}+\nabla\cdot\left ( \mu\nabla v\right ) +S_{My}&\\
&\frac{\left ( \partial \rho w\right ) }{\partial t}+\nabla\cdot\left ( \rho w\mathbf{V}\right )
= -\frac{\partial p}{\partial z}+\nabla\cdot\left ( \mu\nabla w\right ) +S_{Mz}&
\end{flalign}\label{NS_eq1}\end{subequations}}\\[-2ex]
Energy & {\begin{flalign}
\frac{\left ( \partial \rho e\right ) }{\partial t}+\nabla\cdot\left ( \rho e\mathbf{V}\right )
=-p\nabla\cdot\mathbf{V}+\nabla\left ( k\nabla T \right ) + \Phi + S_{i}&&
\label{energy_1}\end{flalign}}\\
\hline\end{tabular}\caption{Governing equations of flow for a Newtonian fluid}\label{NS_eqt}\end{table}
\end{document}
我会这样做。我还让方程编号依赖于表格,而不是文本。
\documentclass{article}
\usepackage{mathtools}
\newcounter{tableeqn}[table]
\renewcommand{\thetableeqn}{\thetable.\arabic{tableeqn}}
\newcounter{tablesubeqn}[tableeqn]
\renewcommand{\thetablesubeqn}{\thetableeqn\alph{tablesubeqn}}
\begin{document}
\begin{table}\centering
\stepcounter{table}% for \thetable
\def\arraystretch{2.5}
\begin{tabular}{llr}\hline
Continuity & $\displaystyle
\frac{\partial \rho}{\partial t}+\nabla\cdot ( \rho\mathbf{V} )=0$ &
\refstepcounter{tableeqn} (\thetableeqn)\label{continuity_1} \\
x-momentum & $\displaystyle
\frac{ ( \partial \rho u ) }{\partial t}+\nabla\cdot ( \rho u\mathbf{V} )
= -\frac{\partial p}{\partial x}+\nabla\cdot ( \mu\nabla u ) +S_{Mx}$ &
\stepcounter{tableeqn}\refstepcounter{tablesubeqn}(\thetablesubeqn) \\
y-momentum & $\displaystyle
\frac{ ( \partial \rho v ) }{\partial t}+\nabla\cdot ( \rho v\mathbf{V} )
= -\frac{\partial p}{\partial y}+\nabla\cdot ( \mu\nabla v ) +S_{My}$ &
\refstepcounter{tablesubeqn}(\thetablesubeqn) \\
\newline z-momentum & $\displaystyle
\frac{ ( \partial \rho w ) }{\partial t}+\nabla\cdot ( \rho w\mathbf{V} )
= -\frac{\partial p}{\partial z}+\nabla\cdot ( \mu\nabla w ) +S_{Mz}$ &
\refstepcounter{tablesubeqn}(\thetablesubeqn) \\
Energy & $\displaystyle
\frac{ ( \partial \rho e ) }{\partial t}+\nabla\cdot ( \rho e\mathbf{V} )
=-p\nabla\cdot\mathbf{V}+\nabla ( k\nabla T ) + \Phi + S_{i}$ &
\refstepcounter{tableeqn}(\thetableeqn)\label{energy_1} \\
\hline\end{tabular}
\addtocounter{table}{-1}%
\caption{Governing equations of flow for a Newtonian fluid}\label{NS_eqt}\end{table}
\end{document}
答案2
无需在环境tabular
内部使用table
:
\documentclass{article}
\usepackage{amsmath,booktabs}
\newcommand{\pder}[2]{\frac{\partial#1}{\partial#2}}
\begin{document}
\begin{table}
\centering
\rule{\textwidth}{\heavyrulewidth}
\vspace{-\baselineskip}
\begin{flalign}
&\text{Continuity} & \frac{\partial \rho}{\partial t}+\nabla\cdot (\rho\mathbf{V})=0
&&&\label{continuity_1}
\end{flalign}
\vspace{-\baselineskip}
\begin{subequations}
\begin{flalign}
&\text{$x$-momentum}
&\pder{(\rho u)}{t}+\nabla\cdot(\rho u\mathbf{V}) &= -\pder{p}{x}+\nabla\cdot(\mu\nabla u)+S_{Mx}
&&\\
&\text{$y$-momentum}
&\pder{(\rho v)}{t}+\nabla\cdot(\rho v\mathbf{V}) &= -\pder{p}{y}+\nabla\cdot(\mu\nabla v)+S_{My}
&&\\
&\text{$z$-momentum}
&
\pder{(\rho w)}{t}+\nabla\cdot(\rho w\mathbf{V}) &= -\pder{p}{z}+\nabla\cdot(\mu\nabla w)+S_{Mz}
&&
\end{flalign}
\label{NS_eq1}
\end{subequations}
\vspace{-\baselineskip}
\begin{flalign}
&\text{Energy}
&\qquad
\pder{(\rho e)}{t}+\nabla\cdot(\rho e\mathbf{V}) =-p\nabla\cdot\mathbf{V}+\nabla(k\nabla T)
+ \Phi + S_{i}
&&&\label{energy_1}
\end{flalign}
\rule{\textwidth}{\heavyrulewidth}
\caption{Governing equations of flow for a Newtonian fluid}\label{NS_eqt}
\end{table}
\end{document}