# Changing Table Numbering Scheme to Include Section Number

When I create a table and use \caption, Latex automatically adds "Table 1.1" or something similarly numbered. I'm using the book format, and want the caption numbering to be of the form "Table x.y.z", where x is the chapter number, y is the section number, and z is the table number within x.y. For example, the second table in section 4 in chapter 2 should say "Table 2.4.2".
How do I make Latex change the numbering of the tables?

-
You can use the chngcntr package, plus \counterwithin{table}{section}. See this question Continuous v. per-chapter/section numbering of figures, tables, and other document elements for more details. – Alan Munn Apr 1 '12 at 4:28
This worked perfectly, and it's easy to understand. Much appreciated! – Christopher Aden Apr 1 '12 at 4:52

Although your question is closely related to the following question, the numbering scheme you want is different.

The general solution is the same, however:

Use the chngcntr package to determine which counters depend on which. In your case, you want the table counter to depend on the section counter, so you add

\usepackage{chngcntr}
\counterwithin{table}{section}
-
Worked like a charm! Glad the solution was so straightforward! – Christopher Aden Apr 1 '12 at 4:53
bit of a shame that Peter invented a new name for this and did not use the amsmath name that is around for ages – Frank Mittelbach Apr 1 '12 at 4:57
@FrankMittelbach I guess if he used the same name, the package might clash with amsmath. This way there's no conflict (even though it wouldn't be needed). I don't know if that was the reasoning. – Alan Munn Apr 1 '12 at 5:08
I was thinking about that but in this particular case it doesn't really make much sense as he could have just "provided" the definition ... well it is the way it is by now. – Frank Mittelbach Apr 1 '12 at 5:29

For this two things are needed:

1. the table counter need resetting whenever the section counter is stepped
2. the command to display the counter value should show the combination of chapter, section and table.

You achieve the first by placing

\makeatletter
\makeatother

into the preamble of your document. The second step is done through

\renewcommand\thetable{\thesection.\arabic{table}}

where \thesection is the "display number" of the current section which in book is equiv to \arabic{chapter}.\arabic{section}.

### When using amsmath

If you use the amsmath package the solution is even simpler as this packages offers a declaration that combines the above steps:

\numberwithin{table}{section}
-
I like this solution over using another package because it allows you to modify the appearance, for example if someone wanted to us a dash or other separator, \thesection-\arabic{section} – SimplyKnownAsG Jan 18 '14 at 3:55