LaTeX forum ⇒ Text FormattingEquation numbering

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
psw1937
Posts: 8
Joined: Sat Jan 03, 2015 5:01 am

Equation numbering

Postby psw1937 » Sat Jan 03, 2015 5:06 am

How do you get equations numbers of the form "page number.equation number”. Is there a way to set things up so the equation command numbers this way automatically?

Thanks

Tags:

rais
Posts: 177
Joined: Sun Nov 16, 2014 8:51 pm

Postby rais » Sat Jan 03, 2015 8:24 pm

psw1937 wrote:How do you get equations numbers of the form "page number.equation number”.

Isn't that what amsmath's \numberwithin command is for? See `texdoc amsldoc', section `Equation numbering'.

KR
Rainer

psw1937
Posts: 8
Joined: Sat Jan 03, 2015 5:01 am

Postby psw1937 » Sat Jan 03, 2015 8:40 pm

Hi Rainer

Yes it does do what I wanted. I was told this just after having posted my question. But you have to be careful with \numberwithin because it doesn't always number equations that are at the top of a page correctly. Sometimes it carries the numbering over from the previous page and other times it starts to number from zero rather than 1.

User avatar
Stefan Kottwitz
Site Admin
Posts: 9191
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Sat Jan 03, 2015 10:41 pm

Hi,

psw1937 wrote:Sometimes it carries the numbering over from the previous page and other times it starts to number from zero rather than 1.


interesting, do you have examples for this?

Stefan
Site admin

psw1937
Posts: 8
Joined: Sat Jan 03, 2015 5:01 am

Postby psw1937 » Sat Jan 03, 2015 11:09 pm

Yes. I have had both occur in the same document. Unfortunately its a 200 page document and finding the bit of code that causes the problem is difficult. I have code that numbers the first equation on the top of the page 0. The equation at the top of page 2 is numbered 2.0, or at least it was when I ran this code. I'll keep looking for the example of other problem.

  1. \documentclass[UKenglish,11pt,a4paper]{book}
  2. \usepackage{babel,pstricks,pst-plot,longtable,url,graphicx,setspace}
  3. \usepackage{anyfontsize,fancyhdr,amssymb,amsmath}
  4. \pagestyle{fancy}
  5. \fancyhead{}
  6. \fancyfoot{}
  7. \renewcommand{\headrulewidth}{0pt}
  8. \renewcommand{\headheight}{13.6pt}
  9. %\usepackage{makeidx}
  10. \newcounter{pic}[page]
  11. \newcounter{fig}[page]
  12. \setcounter{secnumdepth}{4}
  13. \newtheorem{ption}{Proposition}
  14. \newtheorem{assum}{Assumption}
  15. \newtheorem{them}{Theorem}
  16. \newtheorem{lem}{Lemma}
  17. \newcounter{thm}[page]
  18. \numberwithin{equation}{page}
  19. \begin{document}
  20. substituting in the value for $\pi^{\star\star\star}$ gives,\footnote{This follows from the fact that\begin{eqnarray*}\Delta S^{\star\star\star}&=&\pi^{\star\star\star} (v-c)-\frac{(\pi^{\star\star\star})^2}{2}\\
  21. &=&\pi^{\star\star\star}\left(v-c-\frac{1}{2}\pi^{\star\star\star}\right)\label{eqn1}\\
  22. &=&\pi^{\star\star\star}\left(v-c-\frac{1}{2}v+\frac{1}{4}c\right)\\
  23. &=&\pi^{\star\star\star}\left(\frac{1}{2}v-\frac{3}{4}c\right)\\
  24. &=&\left(v-\frac{1}{2}c\right)\left(\frac{1}{2}v-\frac{3}{4}c\right)\\
  25. &=&\frac{1}{2}v^2-\frac{3}{4}vc-\frac{1}{4}vc+\frac{3}{8}c^2\\
  26. &=&\frac{1}{2}v^2-vc+\frac{3}{8}c^2.
  27. \end{eqnarray*}$\Delta S^\star$ can be written\begin{eqnarray*}\Delta S^\star&=&\frac{1}{2}(v-c)^2\\
  28. &=&\frac{1}{2}(v^2-2vc+c^2)\\
  29. &=&\frac{1}{2}v^2-vc+\frac{1}{2}c^2~~~~~~>\Delta S^{\star\star\star}\end{eqnarray*}}
  30. \begin{eqnarray*}\Delta S^{\star\star\star}&=&\frac{1}{2}v^2-vc+\frac{3}{8}c^2~~~~~~<\Delta S^\star\end{eqnarray*}
  31. Note that if $v^2\geq 2c$ then $\Delta S^{\star\star\star}\geq \Delta S^{\star\star}$.\footnote{To see this note that\begin{eqnarray*}\Delta S^{\star\star\star}&\geq&\Delta S^{\star\star}\\
  32. \Rightarrow \frac{1}{2}v^2-vc+\frac{3}{8}c^2&\geq&\frac{3}{8}(v-c)^2\\
  33. \Rightarrow \frac{1}{2}v^2-vc+\frac{3}{8}c^2&\geq&\frac{3}{8}(v^2-2vc+c^2)\\
  34. \Rightarrow \frac{1}{2}v^2-vc+\frac{3}{8}c^2&\geq&\frac{3}{8}v^2-\frac{6}{8}vc+\frac{3}{8}c^2\\
  35. \Rightarrow \frac{1}{2}v^2-vc&\geq&\frac{3}{8}v^2-\frac{6}{8}vc\\
  36. \Rightarrow \frac{1}{2}(v^2-2vc)&\geq&\frac{3}{8}(v^2-2vc)\\
  37. \mathrm{which~is~true~when~v^2}&\geq&2vc.\end{eqnarray*}}
  38.  
  39. This means that if the gains that result from the improvement in quality are large enough Buyer control is preferred to both Seller control or having separate firms. The advantage of Buyer control is that it encourages investment by the Buyer. But as he doesn't take into account the costs, $c$, the Buyer overinvests relative to the first best outcome.%\newpage\setcounter{equation}{1}
  40.  
  41. In the special case of $v^2\geq 2vc$ the Buyer will be willing, and able, to pay the Seller a fixed amount at time A to obtain the right to make the decision about the improvement. That amounts to the Buyer buying the Seller's firm. The Seller will be able to demand amount equal to the difference in his expected profits, $\Delta S_S^{\star\star}-\Delta S_S^{\star\star\star}$, in return for letting the Buyer make the improvement decision.
  42. \[\Delta S_S^{\star\star}-\Delta S_S^{\star\star\star}=\frac{1}{4}(v^2+2c)\footnote{This follows from,\begin{eqnarray*}
  43. \Delta S^{\star\star}_S&=&\frac{1}{4}(v-c)^2\\
  44. &=&\frac{1}{4}(v^2-2vc+c^2)\\
  45. &=&\frac{1}{4}v^2-\frac{1}{2}vc+\frac{1}{4}c^2\\
  46. \Delta S^{\star\star\star}_S&=&-\pi^{\star\star\star}c-(1-\pi^{\star\star\star})\frac{1}{2}c\\
  47. &=&-\pi^{\star\star\star}c-\frac{1}{2}(c-\pi^{\star\star\star}c)\\
  48. &=&-\pi^{\star\star\star}c-\frac{1}{2}(c-(v-\frac{1}{2}c)c)\\
  49. &=&-\pi^{\star\star\star}c-\frac{1}{2}(c-vc+\frac{1}{2}c^2)\\
  50. &=&-c(v-\frac{1}{2}c)-\frac{1}{2}(c-vc+\frac{1}{2}c^2)\\
  51. &=&-vc+\frac{1}{2}c^2-\frac{1}{2}c+\frac{1}{2}vc-\frac{1}{4}c^2\\
  52. &=&-\frac{1}{2}vc+\frac{1}{4}c^2-\frac{1}{2}c\\
  53. \Delta S^{\star\star}_S-\Delta S^{\star\star\star}_S&=&\frac{1}{4}v^2-\frac{1}{2}vc+\frac{1}{4}c^2+\frac{1}{2}vc-\frac{1}{4}c^2+\frac{1}{2}c\\
  54. &=&\frac{1}{4}v^2+\frac{1}{2}c\\
  55. &=&\frac{1}{4}(v^2-2c).
  56. \end{eqnarray*}}\]Here we can think of this outcome as resulting from the Buyer's firm purchasing the Seller's firm for a price of $\frac{1}{4}(v^2-2c)$ in period A. Ownership in the sense of GHM means the Buyer gains residual control rights over the Seller's firm, or more precisely the residual control rights over the non-human assets of the Seller's firm. The residual control right are, however, limited in this case to deciding whether or not to make the quality improvement in period B. The fact that the Buyer can make this decision by fiat means that the Seller's improvement costs, $c$, are not being internalised in {\em Case III} as they were in equation of {\em Case I}. This explains why despite the fact that the two firms are integrated joint profits are less than in the first-best outcome ({\em Case I} ).
  57.  
  58.  
  59. \end{document}
Last edited by Stefan Kottwitz on Sat Jan 03, 2015 11:19 pm, edited 1 time in total.
Reason: code marked

psw1937
Posts: 8
Joined: Sat Jan 03, 2015 5:01 am

Postby psw1937 » Sun Jan 04, 2015 5:12 am

Hi Stefan

I have found the case where the top equation on the second page is numbered following on from the numbering of the first page. In this case the top equation on page 2 is numbered 1.3 while the second equation on page 2 is numbered 2.1.

  1. \documentclass[UKenglish,11pt,a4paper]{book}
  2. %\usepackage[colorlinks,urlcolor=blue]{hyperref}
  3. \usepackage{babel,pstricks,pst-plot,longtable,url,graphicx,setspace}
  4. \usepackage{anyfontsize,fancyhdr,amssymb,amsmath}
  5. \pagestyle{fancy}
  6. \fancyhead{}
  7. \fancyfoot{}
  8. \renewcommand{\headrulewidth}{0pt}
  9. \renewcommand{\headheight}{13.6pt}
  10. %\usepackage{makeidx}
  11. \newcounter{pic}[page]
  12. \newcounter{fig}[page]
  13. \setcounter{secnumdepth}{4}
  14. \newtheorem{ption}{Proposition}
  15. \newtheorem{assum}{Assumption}
  16. \newtheorem{them}{Theorem}
  17. \newtheorem{lem}{Lemma}
  18. %\newcounter{eqnn}[page]
  19. \newcounter{thm}[page]
  20. \numberwithin{equation}{page}
  21. %\makeindex
  22. \begin{document}
  23. Now let $i$ be an/the member for whom the gain in utility (reduction in disutility) from changing his effort level is the smallest, that is, \[v_i(a_i^\star)-v_i(a_i(\varepsilon))\leq v_j(a^\star_j)-v_j(a_j(\varepsilon))~~~~~~~~~\mathrm{for~all~}j.\]Summing over $j$ gives\begin{eqnarray}n(v_i(a_i^\star)-v_i(a_i(\varepsilon)))&\leq&\sum_{j=1}^n v_j(a^\star_j)-v_j(a_j(\varepsilon))\leq x^\star- (x^\star-\varepsilon)\nonumber\\
  24. \Rightarrow \label{eqn8}x^\star -(x^\star -\varepsilon)&\geq &n(v_i(a_i^\star)-v_i(a_i(\varepsilon)))> 0.\end{eqnarray}(Note that $i$ may depend on $\varepsilon$ but the notion used here does not reflect this.)
  25.  
  26. Using Taylor's Theorem\footnote{Young's Form of Taylor’s Theorem: Let $f:(\alpha,\beta) \rightarrow \Re$ be $n-1$ times continuously differentiable on $(\alpha,\beta)$ and assume that $f$ has an $n^{th}$ derivative at the point $x$ in $(\alpha,\beta)$. For any $v$ such that $x + v$ belongs to $(\alpha,\beta)$,
  27. \[f(x+v)=f(x)+\sum^n_{i=1}\frac{f^k(x)}{k!}v^k +\frac{r(v)}{n!}v^n\]
  28. where the remainder term $r(v)$ satisfies \[\lim_{v\rightarrow 0}r(v)=0.\] Here we have $f(\cdot)=v(\cdot), k=1,x+v=x_i(\varepsilon), v=(a_i(\varepsilon)-a^\star_i)<0$ and $x=a^\star_i$.
  29. Substituting in to the formula above we get
  30. \begin{eqnarray*}v_i(a_i(\varepsilon))&=&v_i(a^\star_i)+\frac{v^{'}_i(a^\star_i)}{1!}(a_i(\varepsilon)-a^\star_i) +\hat{r_i}(\varepsilon)\\
  31. \Rightarrow -v^{'}_i(a^\star_i)(a_i(\varepsilon)-a^\star_i)-\hat{r_i}(\varepsilon)&=&v_i(a^\star_i)-v_i(a_i(\varepsilon))\\
  32. \Rightarrow v_i(a^\star_i)-v_i(a_i(\varepsilon))&=&v^{'}_i(a^\star_i)(a^\star_i-a_i(\varepsilon))-\hat{r_i}(\varepsilon)
  33. \end{eqnarray*}
  34. } (or the definition of a derivative) we get
  35. \begin{eqnarray}\label{eqn9}v_i(a^\star_i)-v_i(a_i(\varepsilon))&=&v^{'}_i(a^\star_i)(a^\star_i-a_i(\varepsilon))-\hat{r_i}(\varepsilon)\\
  36. &&~~~~~\mathrm{where}~~\frac{\hat{r}_i(\varepsilon)}{(a^\star -a_i(\varepsilon))}\rightarrow 0~\mathrm{as~}\varepsilon \rightarrow 0.\nonumber\end{eqnarray}%\newpage\noindent
  37. Similarly,\footnote{
  38. Here we have $f(\cdot)=v(\cdot), k=1,x+v=x(a_{-i}^\star,a_i(\varepsilon)), v=(a_i(\varepsilon)-a^\star_i)<0$ and $x=a^\star$.
  39. Substituting in to the formula above we get
  40. \begin{eqnarray*}x(a_{-i}^\star,a_i(\varepsilon))&=&x(a^\star_i)+\frac{\frac{\partial x(a^\star)}{\partial a_i}}{1!}(a_i(\varepsilon)-a^\star_i) +\tilde{r_i}(\varepsilon)\\
  41. \Rightarrow -\frac{\partial x(a^\star)}{\partial a_i}(a_i(\varepsilon)-a^\star_i)-\tilde{r_i}(\varepsilon)&=&x(a^\star_i)-x(a_{-i}^\star,a_i(\varepsilon))\\
  42. \Rightarrow x(a^\star_i)-x(a_{-i}^\star,a_i(\varepsilon))&=&\frac{\partial x(a^\star)}{\partial a_i}(a^\star_i-a_i(\varepsilon))-\tilde{r_i}(\varepsilon)
  43. \end{eqnarray*}}
  44. \begin{eqnarray}\label{eqn10}x(a^\star_i)-x(a_{-i}^\star,a_i(\varepsilon))&=&\frac{\partial x(a^\star)}{\partial a_i}(a^\star_i-a_i(\varepsilon))-\tilde{r_i}(\varepsilon)\\
  45. &&~~~~~\mathrm{where}~~\frac{\tilde{r}_i(\varepsilon)}{(a^\star -a_i(\varepsilon))}\rightarrow 0~\mathrm{as~}\varepsilon \rightarrow 0.\nonumber\end{eqnarray}
  46. Since $a^\star$ maximises total surplus it is the solution to the problem:
  47. \begin{equation}\max_{a} S(a)=x(a)-\sum^n_{i=1} v_i(a_i)\end{equation}which means it satisfies the first order considtions\[\frac{\partial x(a^\star)}{\partial a_i}=v^{'}(a^\star_i)~~~~~i=1, \dots, n\]This means we can rewrite \ref{eqn10}. Remember that $x^\star -\varepsilon=x(a^\star_{-i},a_i(\varepsilon))$ so that\[x^\star-x(a^\star_{-i},a_i(\varepsilon))=x^\star-(x^\star-\varepsilon)=\frac{\partial x(a^\star)}{\partial a_i}(a^\star_i-a_i(\varepsilon))-\tilde{r_i}(\varepsilon)\]which means
  48. \begin{eqnarray*}\frac{\partial x(a^\star)}{\partial a_i}(a^\star_i-a_i(\varepsilon))-\tilde{r_i}(\varepsilon)&=&x^\star-(x^\star-\varepsilon)\\
  49. &\geq& n(v_i(a^\star_i)-v_i(a_i(\varepsilon)))\\
  50. &=&n\left(\frac{\partial x(a^\star)}{\partial a_i}(a^\star_i-a_i(\varepsilon))-\hat{r_i}(\varepsilon)\right)\end{eqnarray*}Dividing by $a^\star_i-a_i(\varepsilon)$ and gathering the remainders gives
  51. \[\frac{\partial x(a^\star)}{\partial a_i}\geq n\frac{\partial x(a^\star)}{\partial a_i}+\frac{\tilde{r}_i(\varepsilon)-n\hat{r}_i(\varepsilon)}{a^\star_i-a_i(\varepsilon)}\]Letting $\varepsilon\rightarrow 0$ gives\footnote{Now there is a caveat here: Remember that $i$ in (\ref{eqn8}) depends on $\varepsilon$, so as $\varepsilon\rightarrow0$, the index $i$ may change. Nevertheless, since there are only $n$ choices for $i$, some index $i$ must occur infinitely often, so for such an index the equation above must hold.}
  52. \[\frac{\partial x(a^\star)}{\partial a_i}=n\left({\frac{\partial x(a^\star)}{\partial a_i}}\right)~~~~~~~~(\mathrm{utilising~equations~\ref{eqn9}~and~\ref{eqn10}).}\]
  53.  
  54. \end{document}
Last edited by Stefan Kottwitz on Sun Jan 04, 2015 12:11 pm, edited 1 time in total.
Reason: code marked

rais
Posts: 177
Joined: Sun Nov 16, 2014 8:51 pm

Postby rais » Sun Jan 04, 2015 8:39 pm

psw1937 wrote:I have found the case where the top equation on the second page is numbered following on from the numbering of the first page. In this case the top equation on page 2 is numbered 1.3 while the second equation on page 2 is numbered 2.1.

Sorry if I misled you, I didn't keep in mind that the page content is still under construction when \thepage is called...
Heiko's zref package might just do the trick:
  1. \documentclass[UKenglish,11pt,a4paper]{book}
  2. \usepackage{babel,amsmath}
  3. \usepackage{blindtext}
  4. \usepackage{zref-perpage}
  5. %\numberwithin{equation}{page}
  6. \zmakeperpage{equation}
  7. \renewcommand*\theequation{\thezpage.\arabic{equation}}
  8. \begin{document}
  9. \blindtext[5]
  10. \begin{equation}
  11. y=f(x)
  12. \end{equation}
  13. \end{document}

KR
Rainer

psw1937
Posts: 8
Joined: Sat Jan 03, 2015 5:01 am

Postby psw1937 » Sun Jan 04, 2015 8:51 pm

rais wrote:
psw1937 wrote:I have found the case where the top equation on the second page is numbered following on from the numbering of the first page. In this case the top equation on page 2 is numbered 1.3 while the second equation on page 2 is numbered 2.1.

Sorry if I misled you, I didn't keep in mind that the page content is still under construction when \thepage is called...
Heiko's zref package might just do the trick:


Thanks Rainer. The way I am doing it now is with the "perpage" package and the commands

\MakePerPage{equation}
\renewcommand{\theequation}{\theperpage.\arabic{equation}}

I guess these two packages will be doing the same thing.

Paul.


Return to “Text Formatting”

Who is online

Users browsing this forum: Baidu [Spider] and 7 guests