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?