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:

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

The documentclass is book and the table code is as follows:
\begin{center}
\begin{tabular}{ p{4cm} p{5cm} p{6cm} }
%\hline
\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]
\hline
\end{tabular}
Table xxx: Foo Caption
\end{center}
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?
lstlistingblocks 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 thelistingblock occupies two pages. Any chance I can fix this? – tugberk May 09 '12 at 12:31placeinspackage provides the command\FloatBarrierwhich you could put before yourlstlistingenvironments – cmhughes May 09 '12 at 12:44