将方程与条件对齐

将方程与条件对齐

我使用以下带边界条件的方程,

在此处输入图片描述

我想将方程式居中对齐,并将边界条件保持在右侧。但方程式有点居中对齐,边界条件并不完全在右侧。有人能为这种情况提出更好的对齐方法吗?以下是代码片段,如果有人愿意帮忙的话!

\subsubsection{Outflow}
For the outflow boundary condition, the pressure is specified as a Dirichlet boundary condition, assigned with free-stream pressure and the density $\rho$ and the velocity $\vec{u}$ are specified as a Neumann boundary condition,
\begin{align}
p &= p_\infty & \text{ on }  \Gamma_{out} \\
\frac{\partial \rho}{\partial \hat{n}} &= 0  & \text{ on }  \Gamma_{out} \\ 
\frac{\partial \vec{u}}{\partial \hat{n}} &= 0  & \text{ on }  \Gamma_{out}
\end{align}

答案1

我不会对这三个方程使用居中对齐:要么将它们对齐在等号处,要么由于附加条件而将它们左对齐。我也不会将条件放在离方程太远的地方:毕竟条件是方程的一部分。或\quad似乎\qquad足够了。

\documentclass{article}
\usepackage{amsmath}
\numberwithin{equation}{section}

\begin{document}

\section{Outflow}
For the outflow boundary condition, the pressure is specified as a Dirichlet boundary 
condition, assigned with free-stream pressure and the density $\rho$ and the velocity 
$\vec{u}$ are specified as a Neumann boundary condition,
\begin{alignat}{2}
&p = p_\infty\qquad                            && \text{on $\Gamma_{\mathrm{out}}$} \\
&\frac{\partial\rho}{\partial\hat{n}} = 0      && \text{on $\Gamma_{\mathrm{out}}$} \\
&\frac{\partial \vec{u}}{\partial \hat{n}} = 0 && \text{on $\Gamma_{\mathrm{out}}$}
\end{alignat}

\end{document}

在此处输入图片描述

如果希望等号对齐,只需更改第一个的位置&

\documentclass{article}
\usepackage{amsmath}
\numberwithin{equation}{section}

\begin{document}

\section{Outflow}
For the outflow boundary condition, the pressure is specified as a Dirichlet boundary
condition, assigned with free-stream pressure and the density $\rho$ and the velocity
$\vec{u}$ are specified as a Neumann boundary condition,
\begin{alignat}{2}
p &= p_\infty\qquad                            && \text{on $\Gamma_{\mathrm{out}}$} \\
\frac{\partial\rho}{\partial\hat{n}} &= 0      && \text{on $\Gamma_{\mathrm{out}}$} \\
\frac{\partial \vec{u}}{\partial \hat{n}} &= 0 && \text{on $\Gamma_{\mathrm{out}}$}
\end{alignat}

\end{document}

在此处输入图片描述

我个人倾向于第一个解决方案。

答案2

为了实现将主要方程式放在教科书中间的既定目标,你可以在当前的方程式系统中增加一个额外的方程式,无形的柱子向左转主要方程式,并有新的列包含\text{on $\Gamma_{out}$。可以通过将文本包含在\phantom语句中来使其不可见。

请注意,没有必要在所有三行中提供不可见的内容 - 提供一次(例如,在第一行)就足以达到所需的效果。

在此处输入图片描述

\documentclass{article}
\usepackage{amsmath}
\newcommand\Gout{\Gamma_{\!\textit{out}}} % occurs repeatedly
\begin{document}
\subsubsection{Outflow}
For the outflow boundary condition, the pressure is specified as a Dirichlet boundary 
condition, assigned with free-stream pressure and the density $\rho$ and the velocity 
$\vec{u}$ are specified as a Neumann boundary condition,
\begin{align}
&\phantom{\text{on $\Gout$}} & p &= p_\infty & \text{on $\Gout$} \\
&& \frac{\partial\rho}{\partial \hat{n}} &= 0  & \text{on $\Gout$} \\ 
&& \frac{\partial\vec{u}}{\partial\hat{n}} &= 0  & \text{on $\Gout$}
\end{align}
\end{document}

相关内容