我怎样才能对齐这些方程式?

我怎样才能对齐这些方程式?
$\frac{dP}{dr}=\frac{-\Big(P+\rho (P)c^2 \Big)} {2} \frac {d\nu} {dr}\]$\\
\newline
$$\Rightarrow d\nu = \frac {-2dP} {P+\rho (P) c^2}$$\\
\bigskip \newline
$$ \nu (r) = - \int_{0}^{P(r)} \frac {2dP}{P+\rho (P) c^2} + \nu (r_b)$$
\newline
\newline
\newline
$$ e^{\nu(r)} &= e^{\nu(r_b) -  \int_{0}^{P(r)} \frac {2dP}{P+\rho (P) c^2} }$$
\newline


$$ e^ {\nu (r)}= e^{\nu(r_b)} exp \Big[-\int_{0}^{P(r)} \frac {2dP}{P+\rho (P) c^2} \Big]$$

我是 Latex 的新手,所以我的代码看起来很简单,你能帮我对齐这些方程式吗?

答案1

通过使用align*环境(由amsmath包),可以将五个方程分组并水平对齐。你没有说如何它们应该对齐,所以我假设它们应该在相应的=符号上对齐。

输出

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align*}
\frac{dP}{dr}&=\frac{-\bigl(P+\rho (P)c^2 \bigr)} {2} 
\frac {d\nu} {dr}\\
\Rightarrow d\nu &= \frac {-2dP} {P+\rho (P) c^2} \\
\nu (r) &= - \int_{0}^{P(r)} \frac {2dP}{P+\rho (P) c^2} + \nu (r_b)\\
e^{\nu(r)} &= \exp\biggl[\nu(r_b) -  \int_{0}^{P(r)} 
              \frac {2dP}{P+\rho (P) c^2} \biggr]\\
e^ {\nu (r)}&= e^{\nu(r_b)} \exp \biggl[-\int_{0}^{P(r)} 
\frac {2dP}{P+\rho (P) c^2} \biggr]
\end{align*}
\end{document} 

显然,最大的变化是align*环境的使用和所有指令的消除\newline。其他一些变化:在第一行中使用\bigl(和(您使用的是和);在最后两行中使用和;并且在最后两行中使用(请注意,“exp”字符串设置为直立字母)。\bigr)\Big(\Big)\biggl[\biggr]\exp

另请参阅帖子$$、[、align、equation 和 displaymath 之间有什么区别?讨论这些显示数学环境的不同之处。

答案2

这就是你要找的东西吗?

\begin{align*}
\frac{dP}{dr}=\frac{-\left(P+\rho (P)c^2 \right)}{2} \frac {d\nu}{dr}\Rightarrow d\nu &= \frac {-2dP} {P+\rho (P) c^2}\\
\nu (r) &= \nu (r_b)- \int_{0}^{P(r)} \frac {2dP}{P+\rho (P) c^2}  \\
e^{\nu(r)} &= e^{\nu(r_b) - \int_{0}^{P(r)} \frac {2dP}{P+\rho (P) c^2} }\\
e^ {\nu (r)}&= e^{\nu(r_b)} \exp \left(-\int_{0}^{P(r)} \frac {2dP}{P+\rho (P) c^2} \right)\end{align*}

答案3

以下是我的做法:

\documentclass{article}

\usepackage{mathtools}

\newcommand*\ABLD{\ArrowBetweenLines[\Downarrow]&&}
\newcommand*\diffOp{\mathop{}\!\mathit{d}}
\newcommand*\diff[2]{\frac{\diffOp #1}{\diffOp #2}} % can be made more flexible but no need in this case

\begin{document}

\begin{alignat*}{2}
  && \diff{P}{r}
  &= \frac{-(P + \rho(P)c^{2})}{2}\diff{\nu}{r}\\
  \ABLD
  \diffOp \nu
  &= \frac{-2\diffOp P}{P + \rho(P)c^{2}}\\
  \ABLD
  \nu(r)
  &= -\int_{0}^{P(r)} \frac{2\diffOp P}{P + \rho(P)c^{2}} + \nu(r_{b})\\
  \ABLD
  e^{\nu(r)}
  &= \exp{\mkern -8mu}\left[\nu(r_{b}) - \int_{0}^{P(r)} \frac{2\diffOp P}{P + \rho(P)c^{2}}\right]\\
  \ABLD
  e^{\nu(r)}
  &= e^{\nu(r_{b})} \exp{\mkern -8mu}\left[-\int_{0}^{P(r)} \frac{2\diffOp P}{P + \rho(P)c^{2}}\right]
\end{alignat*}

\end{document}

输出1

或者可能

\documentclass{article}

\usepackage{mathtools}

\newcommand*\ABLD{\ArrowBetweenLines[\Downarrow]&&}
\newcommand*\diffOp{\mathop{}\!\mathit{d}}
\newcommand*\diff[2]{\frac{\diffOp #1}{\diffOp #2}} % can be made more flexible but no need in this case

\begin{document}

\begin{alignat*}{2}
  && \diff{P}{r}
  &= \frac{-(P + \rho(P)c^{2})}{2}\diff{\nu}{r}\\
  \ABLD
  \diffOp \nu
  &= \frac{-2\diffOp P}{P + \rho(P)c^{2}}\\
  \ABLD
  \nu(r)
  &= -\int_{0}^{P(r)} \frac{2\diffOp P}{P + \rho(P)c^{2}} + \nu(r_{b})\\
  \ABLD
  e^{\nu(r)}
  &= \exp{\mkern -8mu}\left[\nu(r_{b}) - \int_{0}^{P(r)} \frac{2\diffOp P}{P + \rho(P)c^{2}}\right]{\mkern -6mu}
   = e^{\nu(r_{b})} \exp{\mkern -8mu}\left[-\int_{0}^{P(r)} \frac{2\diffOp P}{P + \rho(P)c^{2}}\right]
\end{alignat*}

\end{document}

输出2

或者可能

\documentclass{article}

\usepackage{mathtools}

\newcommand*\ABLD{\ArrowBetweenLines[\Downarrow]&&}
\newcommand*\diffOp{\mathop{}\!\mathit{d}}
\newcommand*\diff[2]{\frac{\diffOp #1}{\diffOp #2}} % can be made more flexible but no need in this case

\begin{document}

\begin{alignat*}{2}
  && \diff{P}{r}
  &= \frac{-(P + \rho(P)c^{2})}{2}\diff{\nu}{r}\\
  \ABLD
  \diffOp \nu
  &= \frac{-2\diffOp P}{P + \rho(P)c^{2}}\\
  \ABLD
  \nu(r)
  &= -\int_{0}^{P(r)} \frac{2\diffOp P}{P + \rho(P)c^{2}} + \nu(r_{b})\\
  \ABLD
  e^{\nu(r)}
  &= \exp{\mkern -4mu}\biggl[\nu(r_{b}) - \int_{0}^{P(r)} \frac{2\diffOp P}{P + \rho(P)c^{2}}\biggr]{\mkern -4mu}\\
  &&&= e^{\nu(r_{b})} \exp{\mkern -4mu}\biggl[-\int_{0}^{P(r)} \frac{2\diffOp P}{P + \rho(P)c^{2}}\biggr]
\end{alignat*}

\end{document}

输出

如果您想要更小的括号和最后两个=s 的对齐。

PS 我可能会选择最后一个版本。

相关内容