LaTex table numbering
How could I number the tables in my article chapter based ? So I want all the tables in the fifth section to be numbered like "Table 5.1", ..., "Table 5.n".
I tried
\usepackage{chngcntr}
\counterwithin{figure}{section}
\counterwithin{table}{section}
\counterwithin{equation}{section}
but I am having some problems (missing package I guess).
However, I need a simpler sol开发者_JAVA技巧ution, without the need to use such packages.
The article class doesn't have chapters. Try the book or report classes - you'll find that the tables and figures are automatically numbered according to chapter.
Here is a solution without the use of any package (courtesy of "The Latex Companion", A1.4):
\makeatletter
\renewcommand{\thetable}{\thesection.\@arabic\c@table}
\@addtoreset{table}{section}
\makeatother
This resets the table counter whenever a new section is started, and formats it as sectionno.tableno
instead of just tableno
. You can change the figure
and equation
counters similarly.
If you are using the amsmath
package (or an AMS class like amsart
that loads it automatically), you can use
\numberwithin{table}{section}
This was created for equations, but works for any pair of counters though supposedly there might be tricky situations that it does not handle well.
精彩评论