Numbering the Equations in Latex

  • Context: LaTeX 
  • Thread starter Thread starter EngWiPy
  • Start date Start date
  • Tags Tags
    Latex
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
14 replies · 118K views
EngWiPy
Messages
1,361
Reaction score
61
Hello,

I am wondering if there is an automatic way to number the equations in my thesis based on chapters, sections, subsections, ..., etc.

Regards
 
Physics news on Phys.org
\numberwithin?
http://home.iitk.ac.in/~swagatk/faq/latex.html
http://online.redwoods.cc.ca.us/instruct/darnold/staffDev/lecture4.pdf#page=6
maybe useful... http://www.categorifiedcoder.info/old/weblog/archives/pure_latex_numberwithin

I haven't tried these myself.
 
Last edited by a moderator:
Beautiful! I had been meaning to get around to learning this, and it works very well.

Code:
\numberwithin{equation}{section} %sets equation numbers <chapter>.<section>.<index>
\numberwithin{equation}{subsection} %sets equation numbers <chapter>.<section>.<subsection>.<index>
\numberwithin{equation}{subsubsection} %sets equation numbers <chapter>.<section>.<subsection>.<subsubsection>.<index>
 
Thanks robphy and Fenn for replying.

When I wrote for example

Code:
\numberwithin{equation}{subsection}

and I have equations in the section before the subsection, the numbering will be something like 1.0.1 or if I have equations in the chapter before any section the numbering will be 0.0.1. I don't want this. I know a way to put a new control sequence just before each chapter, section, subsection, ..., etc, but I am wondering if there is a global control squence that solves these issues automatically, so that the numbers will be:

1- For chapter one: 1.1, 1.2, 1.3, ...
2- For section one in chapter one: 1.1.1, 1.1.2, 1.1.3, ...
.
.
.
etc

Best regards
 
That might be a little confusing to the reader, where the depth of equation indices depends on the section where the equation resides. It may not be obvious to the reader whether (1.2) refers to Section 1.2, or Equation 2 in Chapter 1 before the first section. Just my opinion though.

To do what you're asking, it looks like /numberwithin will do this:

Code:
\chapter{New chapter}

\numberwithin{equation}{chapter}

\begin{align}
 F &= ma\\
 &= mv^2/r
\end{align}

...

\numberwithin{equation}{section}

\section{New Section}

\begin{align}
 E &= mc^2\\
 \pi &\text{ is exactly three!}
\end{align}

[tex] <br /> \chapter{New chapter}<br /> <br /> \numberwithin{equation}{chapter}<br /> <br /> \begin{align}<br /> F &= ma\\<br /> &= mv^2/r<br /> \end{align}<br /> <br /> ...<br /> <br /> \numberwithin{equation}{section}<br /> <br /> \section{New Section}<br /> <br /> \begin{align}<br /> E &= mc^2\\<br /> \pi &\text{ is exactly three!}<br /> \end{align}[/tex]
 
But in this case: how to distiniguish between the equations in chapter one and chapter two, for example, and both before any new section is encountered? The whole thing is confusing actually. I am thinking to treat chapters as sections, and sections as subsections, and so on. I don't know if there is anything prevent me doing that. But if you see any book, the equations are labeled as I discribed in my previous thread.

Regards
 
Well, this forum doesn't do my example justice. For my thesis, I'm using the memoir package, and my equations would appear as (1.1), (1.2), (1.1.1), (1.1.2) in the example I gave. Which package are you using to prepare your thesis?

All my textbooks that I have with me right now use the format (<chapter>.<index>). I'll have to check my Sakurai when I get home to see how he handles (<chapter>.<section>.<index>). I would personally put a section right at the top of your chapter, so you're within the first section from the onset.

Code:
\chapter{How to Bathe a Dog}
\section{Introduction}

Generally speaking, the best equation used to bathe a dog is
%
\begin{align}
  g(t) &= 4\pi \frac{M}{\sqrt{t}}.
\end{align}
 
Fenn said:
Well, this forum doesn't do my example justice. For my thesis, I'm using the memoir package, and my equations would appear as (1.1), (1.2), (1.1.1), (1.1.2) in the example I gave. Which package are you using to prepare your thesis?
...

How to use the memoir package? I think it is just what I want. Right now, I don't use any pacakes to number the equations, it is in its default setting.

Regards
 
This numbering is already done by default when you create an equation...what's the problem with that?
 
junglebeast said:
This numbering is already done by default when you create an equation...what's the problem with that?

Dear junglebeast,

The numbering is done by default, yes you are right, but the default numbering is sequential, and doesn't count for chapters, sections, subsections, ... ,etc.

Regards
 
S_David said:
How to use the memoir package? I think it is just what I want. Right now, I don't use any pacakes to number the equations, it is in its default setting.
Regards

Actually, looks like I was using the improper name. Memoir is a class. At the top of your document, you have the line \documentclass[options]{classname}.

If you are using a different class, you will probably notice some unexpected behavior when you switch from one class to another. This package defines a whole pile of stuff that I have found handy when setting up the document. There is a comprehensive description of this class at http://www.ctan.org/tex-archive/macros/latex/contrib/memoir/memman.pdf, but you could also try looking for a thesis template that uses memoir, and see how it relates to your existing setup.

I'm still in the process of developing my thesis, and as I do so, my layout changes. When I am nearing completion, I plan to document my configuration and release it as a template for others. Thanks to this thread, the equation numbering style will be a part of that template!
 
Fenn said:
Actually, looks like I was using the improper name. Memoir is a class. At the top of your document, you have the line \documentclass[options]{classname}.

If you are using a different class, you will probably notice some unexpected behavior when you switch from one class to another. This package defines a whole pile of stuff that I have found handy when setting up the document. There is a comprehensive description of this class at http://www.ctan.org/tex-archive/macros/latex/contrib/memoir/memman.pdf, but you could also try looking for a thesis template that uses memoir, and see how it relates to your existing setup.

I'm still in the process of developing my thesis, and as I do so, my layout changes. When I am nearing completion, I plan to document my configuration and release it as a template for others. Thanks to this thread, the equation numbering style will be a part of that template!

I am using the article class then. Anyway I will look at the document you gave, and see if it satisfies my thesis requirements. Finally, I liked what you said about your thesis template, which for sure will help others in writting their own thesis.

Best regards
 
Hi,
I was wondering how to number a set of equations (in Latex) under the same number but differentiate with a letter appeneded at the end!
i.e,
aX + bY = k -------(1.1a)
cX + dY = l -------(1.1b)
rX + sY = m -------(1.1c)
like wise.
I can get them numbered as (1.1),(1.2),(1.3) etc. But don't know how to get the above format.

Thanks,
Madara
 
You can use the subequation environment

ftp://ftp.ams.org/pub/tex/doc/amsmath/short-math-guide.pdf