4

I am currently creating a figure which is filled by longtable inside, why I do this is because I need the caption to be figure, while on the other hand, I need the table environment.

The thing is, the reason I use longtable is I will create a big table, but putting it inside a figure has made it unseparated. Is there a way to do this actually?

So what I already have are: 1.

\begin{longtable}{ccccc}
% Long content
\end{longtable}

This is ok, but I dont have the Figure caption (if it's possible to put this caption somewhere, maybe this will be an easier solution)

2.

\begin{figure}
  \begin{longtable}{ccccc}
  % Long content
  \end{longtable}
\end{figure}

With this, I will have the caption, but the table will always be in a page (they don't want to be separated).

6

Do not use a float for longtable, but rather the capt-of or caption package and then \captionof{figure}{...} to create the Figure caption. Because longtable does increment the table counter by one you need to reduce it again to ensure proper numbering for following tables.

\documentclass{article}

\usepackage{longtable}
\usepackage{capt-of}

\begin{document}

% Document
\begin{center}
  \begin{longtable}{ccccc}
      a \\
  % Long content
  \end{longtable}%
  \captionof{figure}{Caption text}%
  \addtocounter{table}{-1}%
\end{center}

\end{document}
  • 3
    I think you also have to substract 1 from the table counter. I think longtable advances it automatically but I am not a 100% sure. – Martin H May 12 '11 at 22:29
  • @MartinH: Thanks. Yes, this is the case. I added it to my answer. – Martin Scharrer May 12 '11 at 22:34

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.