Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Numbering the Equations in Latex

  1. Jul 13, 2009 #1
    Hello,

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

    Regards
     
  2. jcsd
  3. Jul 13, 2009 #2

    robphy

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

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

    I haven't tried these myself.
     
    Last edited by a moderator: May 4, 2017
  4. Jul 13, 2009 #3
    Beautiful! I had been meaning to get around to learning this, and it works very well.

    Code (Text):

    \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>
     
     
  5. Jul 13, 2009 #4
    Thanks robphy and Fenn for replying.

    When I wrote for example

    Code (Text):
    \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
     
  6. Jul 13, 2009 #5
    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 (Text):

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

    \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]
     
  7. Jul 13, 2009 #6
    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
     
  8. Jul 13, 2009 #7
    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 text books 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 (Text):

    \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}
     
     
  9. Jul 13, 2009 #8
    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
     
  10. Jul 13, 2009 #9
    This numbering is already done by default when you create an equation...what's the problem with that?
     
  11. Jul 13, 2009 #10
    Dear junglebeast,

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

    Regards
     
  12. Jul 13, 2009 #11
    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!
     
  13. Jul 13, 2009 #12
    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
     
  14. Aug 8, 2009 #13
    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
     
  15. Aug 8, 2009 #14
  16. Aug 8, 2009 #15
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Numbering the Equations in Latex
Loading...