# 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
\begin{equation}
G(t)=L\gamma!\,t^{-\gamma}+t^{-\delta}\eta(t) \qedhere
\end{equation}
\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\\
\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}


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. Jun 21, 2018 at 19:28
• \textonehalf should not be used in math mode. If you want a small fraction, use \tfrac{1}{2}. Jun 21, 2018 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? Jun 21, 2018 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}{\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. Jun 21, 2018 at 19:36
• How do I label each equation so that I can reference it? Jun 21, 2018 at 19:49
• @economia I added the labels.
– nox
Jun 21, 2018 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. Jun 21, 2018 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. Jun 21, 2018 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 :-) Jun 21, 2018 at 22:19
• @Zarko: You're quite right. It's a quite useful small package, in my opinion. Jun 21, 2018 at 22:38
• yes, it is. recently i use it quite often. +1 for nice answer Jun 21, 2018 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? Jun 21, 2018 at 23:25
{"ft_lang_label":"__label__en","ft_lang_prob":0.6657911,"math_prob":0.99184734,"size":2157,"snap":"2022-05-2022-21","text_gpt3_token_len":698,"char_repetition_ratio":0.17696238,"word_repetition_ratio":0.06837607,"special_character_ratio":0.2753825,"punctuation_ratio":0.11081081,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99986255,"pos_list":[0,1,2,3,4],"im_url_duplicate_count":[null,2,null,2,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-05-25T20:52:58Z\",\"WARC-Record-ID\":\"<urn:uuid:008d781d-cbb6-4dd7-8785-dc389046ff44>\",\"Content-Length\":\"253628\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:961b800b-d44d-49ae-80fc-f638bd12cdc3>\",\"WARC-Concurrent-To\":\"<urn:uuid:9a8059aa-c066-4c2f-842c-33ad304d2ac4>\",\"WARC-IP-Address\":\"151.101.1.69\",\"WARC-Target-URI\":\"https://tex.stackexchange.com/questions/437432/equation-number-within-proof-environment-while-aligning-all-the-equations\",\"WARC-Payload-Digest\":\"sha1:OMEAQONZ3CUTGSEMNNYI3NUAEWEXVTVA\",\"WARC-Block-Digest\":\"sha1:HECIUS4B7AJR6HL2SYVJT3JINXONORGY\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-21/CC-MAIN-2022-21_segments_1652662593428.63_warc_CC-MAIN-20220525182604-20220525212604-00675.warc.gz\"}"}