2

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.

nox
  • 4,160
  • 12
  • 26
economia
  • 259
  • equation had not be nested in align environment. – Zarko Jun 21 '18 at 19:28
  • 2
    \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

2 Answers2

2

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} 

enter image description here

Bernard
  • 271,350
1

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

\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}
nox
  • 4,160
  • 12
  • 26
  • 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
  • @Teepeemm -- yes, that should be possible. certainly worth trying, although i haven't time to do so now. – barbara beeton Jun 21 '18 at 21:05
  • @Teepeemm, @economia: I added your suggested way to label the equations. Also I corrected the \textonehalfs. – nox Jun 21 '18 at 21:53
  • thanks for your answers, the equation number counter now fall along proof count. For example, I have (0.1),(0.2),...,(0.n) before the first proof and (1.1),(1.2),...,(1.n) after the first proof and (2.1),(2.2),...,(2.n) after the second proof etc. I rather want the equation number to count after section. – economia Jun 21 '18 at 23:12
  • @economia By now, you could do a little research on your own and maybe ask a new question, as this is not really related to your initial question. Anyhow, this should be easily possible by changing the \numberthis command: \newcommand{\numberthis}{\refstepcounter{equation}\tag{\arabic{section}.\arabic{equation}}}. And also, please don't forget to accept an answer – nox Jun 21 '18 at 23:57
  • @economia Referring to here, one should use the package chngcntr and the provided commands from there. Now you're on your own. – nox Jun 22 '18 at 00:11