14

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. :-(

6
  • not an option to manually decrease the counter at the end of the table? Oct 24, 2011 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, 2011 at 13:35
  • I've added it as an answer. Oct 24, 2011 at 13:38
  • Possible duplicate of Longtable caption numbering
    – rriemann
    May 10, 2017 at 9:22
  • 1
    @rriemann: More like the other way around, hm? ;-)
    – DevSolar
    May 10, 2017 at 9:25

3 Answers 3

12

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

See Axel Sommerfeldt's answer to Longtable caption numbering .

17

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.

2
  • 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, 2011 at 13:54
  • The answer provided by Joel Purra is a cleaner solution. Aug 6, 2020 at 12:24
4

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
1
  • @david-carlisle Is there any reason that the longtable package always increment the table counter, by default?
    – javadr
    Sep 3, 2017 at 13:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.