我怎样才能使这个方程式居中对齐?
\documentclass[12pt, a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[english]{babel}
\usepackage{physics}
\usepackage{mathtools, nccmath}
\usepackage{calc}
\usepackage{float}
\usepackage{fancyhdr}
\usepackage[makeroom]{cancel}
\usepackage{mdframed}
\usepackage[showframe]{geometry}
\begin{document}
\mbox{}
\begin{fleqn}
\begin{equation}\label{in1}
\begin{aligned}[t]
& \textcolor{blue}{\int_0^{r_1} r_2^2 e^{-\frac{2Zr_2}{a}} \mathrm{d}r_2} =\begin{vmatrix}
u = r_2^2 &u' = 2r_2 \\
v'=e^{-\frac{2Zr_2}{a}} &v = -\frac{a}{2Z} e^{-\frac{2Zr_2}{a}}
\end{vmatrix}
= \left[\frac{r_2^2 e^{-\frac{2zr_1}{a}}}{-\frac{2Z}{a}} \right]_0^{r_1} + \int_0^{r_1} r_2 \frac{a}{Z} e^{-\frac{2Zr_2}{a}} \mathrm{d}r_2 } = \\
& = \left[\frac{r_2^2 e^{-\frac{2zr_1}{a}}}{-\frac{2Z}{a}} \right]_0^{r_1} + \left[-\frac{a^2}{Z}r_2 \frac{e^{-\frac{2Zr_2}{a}}}{2Z} \right]_0^{r_1} + \int_0^{r_1} \frac{ a^2}{2Z^2} e^{-\frac{2Zr_2}{a}} \mathrm{d}r_2 = \\
& = \left[\frac{r_2^2 e^{-\frac{2zr_1}{a}}}{-\frac{2Z}{a}} \right]_0^{r_1} + \left[-\frac{a^2}{Z}r_2 \frac{e^{-\frac{2Zr_2}{a}}}{2Z} \right]_0^{r_1} + \left[-\frac{a^3}{4Z^3}e^{-\frac{2Zr_2}{a}} \right]_0^{r_1} = \\
& = -\frac{ar_1^2e^{-\frac{2Zr_1}{a}}}{2Z} - \frac{a^2}{2Z^2}r_1e^{-\frac{2Zr_1}{a}}-\frac{a^3}{4Z^3} \left(e^{-\frac{2Zr_1}{a}}-1 \right)
\end{aligned}
\end{equation}
\end{fleqn}
\mbox{}
\begin{fleqn}
\begin{equation}\label{in2}
\begin{aligned}[t]
\textcolor{red}{\int_{r_1}^{\infty} r_2 e^{-\frac{2Zr_2}{a}} \mathrm{d}r_2 } = \begin{vmatrix}
u = r_2 &u' = 1 \\
v'=e^{-\frac{2Zr_2}{a}} &v = -\frac{a}{2Z} e^{-\frac{2Zr_2}{a}}
\end{vmatrix} = \\
& = \left[-\frac{ar_2}{2Z}e^{-\frac{2Zr_2}{a}} \right]_{r_1}^{\infty} + \int_{r_1}^{\infty} \frac{a}{2Z}e^{-\frac{2Zr_2}{a}}\mathrm{d}r_2 } = \\
& = \left[-\frac{ar_2}{2Z}e^{-\frac{2Zr_2}{a}} \right]_{r_1}^{\infty} + \left[-\frac{ar_2}{4Z^2}e^{-\frac{2Zr_2}{a}} \right]_{r_1}^{\infty} = \\
& = \frac{ar_1}{2Z}e^{-\frac{2Zr_1}{a}}+\frac{a^2}{4Z^2}e^{-\frac{2Zr_1}{a}}
\end{aligned}
\end{equation}
\end{fleqn}
\end{document}
答案1
您只需删除fleqn
环境:它会使方程式从左边距开始(类似于fleqn
文档类选项,但仅在环境内)。因此希望以下代码能够产生您想要的结果:
\documentclass[12pt, a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[english]{babel}
\usepackage{physics}
\usepackage{mathtools, nccmath}
\usepackage{calc}
\usepackage{float}
\usepackage{fancyhdr}
\usepackage[makeroom]{cancel}
\usepackage{mdframed}
\usepackage[showframe]{geometry}
\begin{document}
\begin{equation}\label{in1}
\begin{aligned}[t]
\textcolor{blue}{\int_0^{r_1} r_2^2 e^{-\frac{2Zr_2}{a}} \mathrm{d}r_2} &=\begin{vmatrix}
u = r_2^2 &u' = 2r_2 \\
v'=e^{-\frac{2Zr_2}{a}} &v = -\frac{a}{2Z} e^{-\frac{2Zr_2}{a}}
\end{vmatrix} \\
& = \left[\frac{r_2^2 e^{-\frac{2zr_1}{a}}}{-\frac{2Z}{a}} \right]_0^{r_1} + \int_0^{r_1} r_2 \frac{a}{Z} e^{-\frac{2Zr_2}{a}}
\mathrm{d}r_2 =
\\
& = \left[\frac{r_2^2 e^{-\frac{2zr_1}{a}}}{-\frac{2Z}{a}} \right]_0^{r_1} + \left[-\frac{a^2}{Z}r_2 \frac{e^{-\frac{2Zr_2}{a}}}{2Z} \right]_0^{r_1} + \int_0^{r_1} \frac{ a^2}{2Z^2} e^{-\frac{2Zr_2}{a}} \mathrm{d}r_2 = \\
& = \left[\frac{r_2^2 e^{-\frac{2zr_1}{a}}}{-\frac{2Z}{a}} \right]_0^{r_1} + \left[-\frac{a^2}{Z}r_2 \frac{e^{-\frac{2Zr_2}{a}}}{2Z} \right]_0^{r_1} + \left[-\frac{a^3}{4Z^3}e^{-\frac{2Zr_2}{a}} \right]_0^{r_1} = \\
& = -\frac{ar_1^2e^{-\frac{2Zr_1}{a}}}{2Z} - \frac{a^2}{2Z^2}r_1e^{-\frac{2Zr_1}{a}}-\frac{a^3}{4Z^3} \left(e^{-\frac{2Zr_1}{a}}-1 \right)
\end{aligned}
\end{equation}
\mbox{}
\begin{equation}\label{in2}
\begin{aligned}[t]
\textcolor{red}{\int_{r_1}^{\infty} r_2 e^{-\frac{2Zr_2}{a}} \mathrm{d}r_2 } & = \begin{vmatrix}
u = r_2 &u' = 1 \\
v'=e^{-\frac{2Zr_2}{a}} &v = -\frac{a}{2Z} e^{-\frac{2Zr_2}{a}}
\end{vmatrix} = \\
& = \left[-\frac{ar_2}{2Z}e^{-\frac{2Zr_2}{a}} \right]_{r_1}^{\infty} + \int_{r_1}^{\infty} \frac{a}{2Z}e^{-\frac{2Zr_2}{a}}\mathrm{d}r_2 = \\
& = \left[-\frac{ar_2}{2Z}e^{-\frac{2Zr_2}{a}} \right]_{r_1}^{\infty} + \left[-\frac{ar_2}{4Z^2}e^{-\frac{2Zr_2}{a}} \right]_{r_1}^{\infty} = \\
& = \frac{ar_1}{2Z}e^{-\frac{2Zr_1}{a}}+\frac{a^2}{4Z^2}e^{-\frac{2Zr_1}{a}}
\end{aligned}
\end{equation}
\end{document}
答案2
你只需要稍微尝试一下对齐运算符&
。你可以通过以下方式实现多个方程块之间的对齐这个答案并通过更改命令定义中的值来调整对齐位置。这不是最完美的解决方案,但很简单,而且可以完成它需要做的事情。
我还擅自清理了您的代码并使用align
环境而不是三个嵌套环境。
\documentclass[12pt, a4paper]{article}
\usepackage{amsmath}
\usepackage{xcolor}
\newcommand{\fakealign}{%
\mbox{\hspace{2cm}} & \mbox{\hspace{12cm}} \nonumber\\}
\begin{document}
\begin{align}
\fakealign
\textcolor{blue}{\int_0^{r_1} r_2^2 e^{-\frac{2Zr_2}{a}} \mathrm{d}r_2} &=\begin{vmatrix}
u = r_2^2 &u' = 2r_2 \\
v'=e^{-\frac{2Zr_2}{a}} &v = -\frac{a}{2Z} e^{-\frac{2Zr_2}{a}}
\end{vmatrix}
= \left[\frac{r_2^2 e^{-\frac{2zr_1}{a}}}{-\frac{2Z}{a}} \right]_0^{r_1} + \int_0^{r_1} r_2 \frac{a}{Z} e^{-\frac{2Zr_2}{a}} \mathrm{d}r_2 = \\
& = \left[\frac{r_2^2 e^{-\frac{2zr_1}{a}}}{-\frac{2Z}{a}} \right]_0^{r_1} + \left[-\frac{a^2}{Z}r_2 \frac{e^{-\frac{2Zr_2}{a}}}{2Z} \right]_0^{r_1} + \int_0^{r_1} \frac{ a^2}{2Z^2} e^{-\frac{2Zr_2}{a}} \mathrm{d}r_2 = \\
& = \left[\frac{r_2^2 e^{-\frac{2zr_1}{a}}}{-\frac{2Z}{a}} \right]_0^{r_1} + \left[-\frac{a^2}{Z}r_2 \frac{e^{-\frac{2Zr_2}{a}}}{2Z} \right]_0^{r_1} + \left[-\frac{a^3}{4Z^3}e^{-\frac{2Zr_2}{a}} \right]_0^{r_1} = \\
& = -\frac{ar_1^2e^{-\frac{2Zr_1}{a}}}{2Z} - \frac{a^2}{2Z^2}r_1e^{-\frac{2Zr_1}{a}}-\frac{a^3}{4Z^3} \left(e^{-\frac{2Zr_1}{a}}-1 \right)
\end{align}
\begin{align}
\fakealign
\textcolor{red}{\int_{r_1}^{\infty} r_2 e^{-\frac{2Zr_2}{a}} \mathrm{d}r_2 } &= \begin{vmatrix}
u = r_2 &u' = 1 \\
v'=e^{-\frac{2Zr_2}{a}} &v = -\frac{a}{2Z} e^{-\frac{2Zr_2}{a}}
\end{vmatrix} = \\
& = \left[-\frac{ar_2}{2Z}e^{-\frac{2Zr_2}{a}} \right]_{r_1}^{\infty} + \int_{r_1}^{\infty} \frac{a}{2Z}e^{-\frac{2Zr_2}{a}}\mathrm{d}r_2 = \\
& = \left[-\frac{ar_2}{2Z}e^{-\frac{2Zr_2}{a}} \right]_{r_1}^{\infty} + \left[-\frac{ar_2}{4Z^2}e^{-\frac{2Zr_2}{a}} \right]_{r_1}^{\infty} = \\
& = \frac{ar_1}{2Z}e^{-\frac{2Zr_1}{a}}+\frac{a^2}{4Z^2}e^{-\frac{2Zr_1}{a}}
\end{align}
\end{document}