我知道在某个环境中可以对方程编号proof
,如下面的 MWE1 所示:
\documentclass[12pt,a4paper]{article}
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage[left=2.00cm, right=2.00cm, top=2.00cm, bottom=2.00cm]{geometry}
\begin{document}
\begin{proof}
A+B=C
\begin{equation}
G(t)=L\gamma!\,t^{-\gamma}+t^{-\delta}\eta(t) \qedhere
\end{equation}
\end{proof}
\end{document}
但我希望方程式对齐。因此我需要\begin{align}...\end{align}
,如下面的 MWE2 所示:
\documentclass[12pt,a4paper]{article}
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage[left=2.00cm, right=2.00cm, top=2.00cm, bottom=2.00cm]{geometry}
\begin{document}
\begin{proof}
\begin{align}
\mu &= np \nonumber\\
&= \textonehalf n;\nonumber\\
\begin{equation}
\sigma &= \sqrt{np\left(1-p\right)}\\
\end{equation}
&= \textonehalf \sqrt{n};\nonumber\\
Z &= \dfrac{X-\mu}{\sigma} \nonumber\\
&= \frac{X-\textonehalf n}{\textonehalf \sqrt{n}};\nonumber\\
\vartriangle Z&= \frac{\left(X+1\right)-\textonehalf n}{\textonehalf
\sqrt{n}} - \frac{X-\textonehalf n}{\textonehalf \sqrt{n}} \nonumber\\
\begin{equation}
\vartriangle Z&= \dfrac{1}{\textonehalf \sqrt{n}}\\
\end{equation}
\lim_{n \to \infty} \vartriangle Z &= 0
\end{align}
\end{proof}
\end{document}
但是 MWE2 中有一个错误。如何在校样环境中为某些选定的方程分配方程编号,同时对齐所有方程?我需要方程编号,以便我可以标记 ( \label{}
) 此类方程并\ref{}
在文档中引用 () 它。我希望沿方程符号对齐,这样看起来美观且专业。
答案1
正如 Zarko 所提到的,该equation
环境不能在align
环境中使用。只需删除方程式环境即可:
\documentclass[12pt,a4paper]{article}
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage[left=2.00cm, right=2.00cm, top=2.00cm, bottom=2.00cm]{geometry}
\newcommand{\numberthis}{\refstepcounter{equation}\tag{\arabic{equation}}}
\newcommand{\labeln}[1]{\numberthis\label{#1}}
\newcommand{\mathonehalf}{\ensuremath{\frac{1}{2}}}
\begin{document}
\begin{proof}
\begin{align}
\mu &= np \\
&= \mathonehalf n;\\
\sigma &= \sqrt{np\left(1-p\right)} \labeln{eq:sigma}\\
&= \mathonehalf \sqrt{n};\\
Z &= \dfrac{X-\mu}{\sigma}\\
&= \frac{X-\mathonehalf n}{\mathonehalf \sqrt{n}};\\
\vartriangle Z&= \frac{\left(X+1\right)-\mathonehalf n}{\mathonehalf
\sqrt{n}} - \frac{X-\mathonehalf n}{\mathonehalf \sqrt{n}}\\
\vartriangle Z&= \dfrac{1}{\mathonehalf \sqrt{n}} \labeln{eq:dz}\\
\lim_{n \to \infty} \vartriangle Z &= 0 \labeln{eq:limdz}
\end{align}
\end{proof}
References to $\sigma$ \eqref{eq:sigma} and $\Delta Z$ \eqref{eq:dz}.
\end{document}
答案2
这是你想要的吗?你可以用 得到数学模数中的小分数\tfrac
。但在这种情况下,我建议\mfrac
使用 中的命令 nccmath
。
另外:最好utf8
现在使用编码。不要equation
在中嵌套环境。如果加载了,则align
无需加载。只需使用此简化代码:amsfonts
amssymb
\documentclass[12pt, a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{textcomp}
\usepackage{amsmath, nccmath}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage[margin=2cm]{geometry}
\begin{document}
\begin{proof}
\begin{align}
\mu &= np \nonumber\\
&= \tfrac{1}{2}n;\nonumber\\
\sigma &= \sqrt{np (1-p )}\\
&= \mfrac{1}{2} \sqrt{n};\nonumber\\
Z &= \dfrac{X-\mu}{\sigma} \nonumber\\
&= \frac{X-\textonehalf n}{\textonehalf \sqrt{n}};\nonumber\\
\Delta Z&= \frac{\left(X+1\right)-\textonehalf n}{\textonehalf
\sqrt{n}} - \frac{X-\textonehalf n}{\textonehalf \sqrt{n}} \nonumber\\
\Delta Z&= \dfrac{1}{\textonehalf \sqrt{n}}\\
\lim_{n \to \infty} \Delta Z &= 0
\end{align}
\end{proof}
\end{document}