TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Sometimes, table cannot locate itself properly inside my document and I don't know how to fix this.

Here is an example:

The current page which the table cannot locate itself properly in looks like as follows:

enter image description here

As you can see, there is too much space in between.

The previous and next pages look like this (left one is previous and the right one is the next page):

enter image description here enter image description here

The documentclass is book and the table code is as follows:

\begin{tabular}{ p{4cm} p{5cm}  p{6cm} }
\cellcolor[gray]{0.9} Foo1 Title & \cellcolor[gray]{0.9}Foo2 Title & \cellcolor[gray]{0.9} Foo3 Title \\ \hline
Foo & Foo & Foo Bar bla bla bla...\\
Foo & Foo & Foo Bar bla bla bla...\\[5pt]


Table xxx: Foo Caption 

Figures can do this very properly. If the space is not enough inside the page, then the image puts itself in the next page but the space in the current page filled with text or something else.

Any idea how can I can fix this problem so that tables can locate themselves properly?

share|improve this question
up vote 5 down vote accepted

The reason your figure environments behave the way you describe is that they are floats. The tabular environment is not a float.

To achieve the desired behaviour, you should wrap your tabular environments within the table environment, which does float.

\caption{Table caption goes here}

Note that I've used \centering and not \begin{center}...\end{center} which adds extra vertical space.

You can change the htbp to suit your desired placement of floats. For further reading, have a look at

share|improve this answer
I am having one other problem with this one: I have also lstlisting blocks and they can sometimes go into two pages. If I follow the above style that u have suggested, table goes inside the lstlisting block if the listing block occupies two pages. Any chance I can fix this? – tugberk May 9 '12 at 12:31
@tugberk that's really a separate question :) however, the placeins package provides the command \FloatBarrier which you could put before your lstlisting environments – cmhughes May 9 '12 at 12:44
Thanks for the tip. I will try that. – tugberk May 9 '12 at 12:47

Your Answer


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.