Graphics, Figures & TablesTable numbering in Appendices

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
eliwe
Posts: 6
Joined: Tue May 13, 2008 5:36 pm

Table numbering in Appendices

Post by eliwe »

Hi!

I've just converted some articles to the new Elsevier class and suddenly the appendices are all weird. I want to have appendices numbered A, B and so on, with tables numbered A.1, A.2, B.1.... which worked very well before. Now it continues table numbering from main document.

I managed to get it to have A, B etc in front of the table numbers by using the appendix-package, but it still continues on the main table numbering (A.7, A.8, B.9) instead of restarting.

Does anyone have an idea of how to get around this?

//Elisabeth

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Table numbering in Appendices

Post by Stefan Kottwitz »

Hi Elisabeth,

you could use \numberwithin of the amsmath package (especially if you're already using amsmath) or \counterwithin of the chngcntr package to number tables per section or chapter, like

Code: Select all

\numberwithin{table}{section}
This way the table counter would restart each section (or chapter in the other case), here it would start with the section number, in the case of the appendix A.1, B.1, ...

Stefan
LaTeX.org admin
eliwe
Posts: 6
Joined: Tue May 13, 2008 5:36 pm

Re: Table numbering in Appendices

Post by eliwe »

That almost but not quite does it. It resets the numbering, but includes the "Appendix" in the numbering, e.g. "Table Appendix A.1". Same for both \numberwithin and \counterwithin.

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

Table numbering in Appendices

Post by Stefan Kottwitz »

I would not include "Appendix" directly in the representation of the section counter like this document or class seems to do. But it could be corrected for tables by

Code: Select all

\renewcommand*\thetable{\Alph{section}.\arabic{table}}
Stefan
LaTeX.org admin
eliwe
Posts: 6
Joined: Tue May 13, 2008 5:36 pm

Re: Table numbering in Appendices

Post by eliwe »

That works. :-)
Thanks a lot for the help!

//Elisabeth
davidec
Posts: 16
Joined: Thu Oct 22, 2009 6:18 pm

Table numbering in Appendices

Post by davidec »

Also, you would probably like to reset the counter to zero, isn't it?

Code: Select all

\setcounter{table}{0}
\renewcommand\thetable{\Alph{section}.\arabic{table}}
Otherwise the first table in the appendix will be numbered, say, Table A.13 if the last table in the main text body is Table 12.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Re: Table numbering in Appendices

Post by Stefan Kottwitz »

Hi davidec,

welcome to the board!
If \numberwithin or \counterwithin like suggested above is used resetting the counter to 0 won't be necessary, it would be reset already at the beginning of every section.
Otherwise one would have to repeat this reset command at the beginning of appendix section B etc.

Stefan
LaTeX.org admin
davidec
Posts: 16
Joined: Thu Oct 22, 2009 6:18 pm

Table numbering in Appendices

Post by davidec »

Stefan, thanks for your kind welcome!
If \numberwithin or \counterwithin like suggested above is used resetting the counter to 0 won't be necessary, it would be reset already at the beginning of every section.
I agree. On the other hand, one may want the tables to be numbered throughout in the main body of the article, independently of the section (and not Table 1.1, 2.1, and so on), while numbered differently when it comes to the appendix. That's what I was trying to achieve with the counter reset.

In fact, that's the most common situation I can think of: say, a 20-page paper with 5 sections, where numbering the tables by section would be kind of an overkill. But in such a case, you may still want the tables in the appendix to be numbered distinctly.
Post Reply