# Equation number within proof environment while aligning all the equations?

I know equation numbering is possible in a proof environment, as shown below in 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
$$G(t)=L\gamma!\,t^{-\gamma}+t^{-\delta}\eta(t) \qedhere$$
\end{proof}
\end{document}


But I want the equations to be aligned. Thus I need \begin{align}...\end{align}, as shown in the MWE2 below:

\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\\
$$\sigma &= \sqrt{np\left(1-p\right)}\\$$
&=  \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\\
$$\vartriangle Z&= \dfrac{1}{\textonehalf \sqrt{n}}\\$$
\lim_{n \to \infty} \vartriangle Z &= 0
\end{align}
\end{proof}
\end{document}


But there is an error in MWE2. How do I assign equation numbers to some selected equations in a proof environment while aligning all the equations? I want the equation number so that I can label (\label{}) such equations and reference (\ref{}) it within the document. I want the alignment along the equation signs, so that it will look aesthetical and professional.

• equation had not be nested in align environment. – Zarko Jun 21 '18 at 19:28
• \textonehalf should not be used in math mode. If you want a small fraction, use \tfrac{1}{2}. – egreg Jun 21 '18 at 19:47
• You've received some good answers, but I'm confused about why you were trying to nest the equation environment in the first place. The only thing I can think of is that you wanted the numbering provided by equation. But surely you realize all those \nonumber commands were what was removing the equation numbers in the first place? – Teepeemm Jun 21 '18 at 21:22

As Zarko mentioned, the equation environment must not be used in an align environment. Just removing the equation environment works for me:

\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}

• And an alternative to all that \nonumber would be align* and then \tag{1234} the appropriate line. – Teepeemm Jun 21 '18 at 19:36
• How do I label each equation so that I can reference it? – economia Jun 21 '18 at 19:49
• @economia I added the labels. – nox Jun 21 '18 at 19:53
• @Teepeemm -- while \tag certainly works, it rather defeats the latex concept of automatic numbering, in that if you shift the equations around, you will have to retag them manually. – barbara beeton Jun 21 '18 at 20:32
• @barbarabeeton Could I use \refstepcounter{equation}\tag{(\arabic{equation})}? I'd rather not have to type \nonumber six or more times just to have one line that I can refer to. – Teepeemm Jun 21 '18 at 21:01

Is it this you want? You can get small fractions in math mod ewith \tfrac. But in this context, I'd recommend the \mfrac command from  nccmath.

Also: preferably, use the utf8 encoding nowadays. Don't nest an equation environment in align. Needless to load amsfonts if you load amssymb. Just use this simplified code:

\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}


• nccmath load amsmath if i recall correctly :-) – Zarko Jun 21 '18 at 22:19
• @Zarko: You're quite right. It's a quite useful small package, in my opinion. – Bernard Jun 21 '18 at 22:38
• yes, it is. recently i use it quite often. +1 for nice answer – Zarko Jun 21 '18 at 22:43
• @economia: You must have something that makes the equation number depend on another counter. Could you post a small code demonstrating the problem? – Bernard Jun 21 '18 at 23:25