I am typesetting a book which is divided into paragraphs (sections), which are numbered continuously through the whole book, and which contain some tables. Tables must be numbered with the same number as the section within which they are located. Thus, "Table 23" is immediately recognizable as the being located in the Section 23.
However, some sections contain more than one tables. I need them to be numbered with a sequential number added to the section number, restarting per each section.
E.g.: Tables 46.1 and Table 46.2 stand both within the Section 46, while Tables 120.1, 120.2 and 120.3 are located in the Section 120.
But, importantly, if there is only one Table in a Section, its number must remain simply the same as the Section number, without the trailing ".1".
Can I achieve this automatically?
\renewcommand{\thetable}{\arabic{section}.\arabic{table}}
along with\numberwithin{table}{section}
. – user121799 Jul 15 '18 at 14:31table
of section 23 occurs, TeX simply doesn't know whether or not it'll be the sole table in that section. That won't be known until either another\section
command occurs -- in which case thetable
is indeed the onlytable
-- or if anothertable
environment and associated\caption
directives show up -- in which case the previoustable
was not the only one in that section. Would you be willing to accept a solution that has a separate\caption
directive for tables that are singletons in their respective sections? – Mico Jul 15 '18 at 14:49