'longtable' caption without incrementing 'table'?

For reasons both complex and confusing, I would like to caption a `longtable` without incrementing the `table` counter in the process.

I want to have two consecutive `longtable` environments to be captioned with identical table numbers; i.e. one `longtable` captioned "Table x.y: Data Set (Part A)" and one captioned "Table x.y: Data Set (Part B)", with x.y being identical for both tables.

Apparently however, even `\caption*{}` command bumps `table`. I am a bit at a loss here.

Note: I know that the `xtab` package would enable me to have one long table with switches of headers and captions mid-table. However I got a (different) problem with that package, akin to this question but sadly not solved by egreg's answer there; so this question should be considered `longtable`-only as `xtab`, `supertabular` etc. don't float my boat right now. :-(

-
not an option to manually decrease the counter at the end of the table? – Roelof Spijker Oct 24 '11 at 13:32
@whlt3: \facepalm... sometimes I think too difficult, especially when I'm not really comfortable with the environment. I only thought about suppressing the increment, not about the manual decrement... `\addtocounter{table}{-1}` is all that's needed... – DevSolar Oct 24 '11 at 13:35
I've added it as an answer. – Roelof Spijker Oct 24 '11 at 13:38

3 Answers

You can simply decrease the table counter after the first table, this will ensure the second table receives the same number. Simply put

``````\addtocounter{table}{-1}
``````

In between the two tables you wish to show.

-
It is a bit wierd how LaTeX sometimes forces you to do something, then take it back again. I still have problems wrapping my mind around it, being so intent on not doing the thing in the first place I lose sight of the end to justify the means. – DevSolar Oct 24 '11 at 13:54

Instead of using the numbered `longtable` environment, use the unnumbered `longtable*` environment; enable with `\usepackage{caption}`.

-

A patch for `longtable`:

``````\usepackage{longtable}
\usepackage{etoolbox}
\makeatletter
\newif\ifLT@nocaption
\preto\longtable{\LT@nocaptiontrue}
\appto\endlongtable{%
\ifLT@nocaption
\addtocounter{table}{\m@ne}%
\fi}
\preto\LT@caption{%
\noalign{\global\LT@nocaptionfalse}}
\makeatother
``````
-