Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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).

share|improve this question
    
See also Label and caption without float. –  Martin Scharrer May 12 '11 at 22:41
add comment

1 Answer

up vote 5 down vote accepted

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}
share|improve this answer
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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