tags:

views:

111

answers:

3

When I try centering my table & getting a caption so that it reads something like "Table 1. This is the caption." the table appears at the top of the page no matter what I do. If I don't do the caption then I can get it in the part of the document that I want. How do I fix this problem?

\begin{table}
    \caption{This is the caption.}
    \begin{center}
        \begin{tabular}{ | l | l | l | l |}
        \hline

        ...

        \hline
        \end{tabular}
    \end{center}
\end{table}
+3  A: 

Try

\begin{table}[h]
   ...
\end{table}

That tells latex "put the table here" instead of letting it float.

I also use

\usepackage{array}

in the preamble for pretty much all my latex documents, but pr0wl informs us that it is not necessary. Thanks pr0wl!

Norman Ramsey
\usepackage{array} is NOT neseccary.
Acron
LaTeX has algorithms for placing figures and tables which are designed to produce quality layout -- sometimes they disagree with what you want. If "h" doesn't place the table where you want it ("approximately here"), you can be more insistent with "h!".Also see http://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions and http://www.math.uiuc.edu/~hildebr/tex/basics.html
M. S. B.
+1  A: 

You can also try \usepackage{float} which gives you the extra positioning command H, which is really forces LaTeX to put the figure right where you specified. If you do use float, make sure to declare your labels after your captions.

In terms of making your figures apear "here", H>h!>h. But H! does nothing.

Perkee
+1  A: 

Floats management is always not so easy to understand (see here). The table environment automatically makes a table a floating element. That is, an element able to move around the page to achieve a good page layout (a good layout from a typographical point of view may differ from the layout you like).

LaTeX manages the floats for you, and, on the other hand, gives very powerful means to control crossed references.

If you don't want something to float, simply don't make it a floating element. By the way, if you need a caption, use the caption package (see here again).

Alessandro C.