开发者

Adding caption in LaTex without floats (tables)?

I have a few tables which are not long enough to warrant the use of \longtable, but they always start on the next page which breaks the whole flow and trying to force it with a [!h] in the t开发者_运维技巧able did not help. So I stopped using \tables and just have \tabular tag now which seems to have fixed the layout as there are no floats.

But the problem now is I can't get automatic captions for the Tables - any ideas how I can do this and also get auto numbering so when I use \addcontentsline it can show up in the TOC?


To use a caption outside a float environment, one needs to use \captionof which is part of package caption.

Example

\documentclass{article}
\usepackage{caption}

\begin{document}                                                                                         
\begin{center}
  \begin{tabular}{rl}
    right & left \\
    right & left \\
  \end{tabular}
  \captionof{table}{Your caption here}
\end{center}
\end{document}

There is also a capt-of package if you are just interested in using the command \captionof.


Short answer; you need a \table for the caption. Only using \tabular + captioning is not gonna work.

bit longer

There may be a nasty work-around as people tend to create work-arounds for everything, but my base rule for most of those work-arounds is: "if latex does not provide it by itself, do not try to do it". Most of time those "fixes" will give even more text-flow problems anyway.

Now if you really want it right below the text just do a \clearpage before the table and place the table. Than the rest of the text. This will probably solve it, although it will give an empty space on the rest of your 'previous' page of course.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜