Graphics, Figures & TablesTable unnecessarily floats to new page

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
trine8
Posts: 4
Joined: Sat Feb 16, 2013 2:42 pm

Table unnecessarily floats to new page

Post by trine8 »

Hi,

I am really frustrated about the following issue:

I have a document with two tables. The smaller(!) one always floats on a new page and does not allow any other text on that page, the larger one does not to that. With two rows less it works, but I really need those two rows.

My code looks like this:

Code: Select all

\begin{table*}[htbp]
\begin{small}
  \caption{...}
  \centering
\begin{tabular}
...
  \end{tabular}
\end{small}
\end{table*}
I used the * because the document has two columns and the table needs the full width.

Because of that problem my paper goes over the page limit, please help! :-(

Thank you in advance!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Table unnecessarily floats to new page

Post by Stefan Kottwitz »

Hi Trine,

welcome to the board!

You could add ! to the table options, i.e. write [!htbp] for more relaxed placement.

Btw. I recommend to write \small instead of \begin{small} ... \end{small}. It's a command, not an environment. The scope of this command already ends because of the outer (table) environment.

If the problem persist, post a compilable Infominimal working example, which allows to test and to fix the problem, shortened or with dummy text.

Stefan
LaTeX.org admin
trine8
Posts: 4
Joined: Sat Feb 16, 2013 2:42 pm

Table unnecessarily floats to new page

Post by trine8 »

Hi,

first of all, thanks for the reply!

I created a mini example:

Code: Select all

 \documentclass{sig-alternate}

 \begin{document}
 	
 \begin{table*}[!htbp]
\small
  \caption{c}
  \centering
%\renewcommand\arraystretch{1.5}
\begin{tabular}{|l||p{3.8cm}||p{1.7cm}|} \hline\\ 
   & \textbf{Lorem ipsum}& \textbf{Lorem } \\ 
   & \textbf{Lorem ipsum} & \textbf{Lorem }  \\ \hline
Lorem ipsum dolor sit  & Lorem ipsum  & Lorem \\ \hline
Lorem ipsum dolor sit  & Lorem ipsum  & Lorem \\ \hline
Lorem ipsum dolor sit  & Lorem ipsum  & Lorem \\ \hline
Lorem ipsum dolor sit  & Lorem ipsum Lorem ipsum dolor sit  Lorem ipsum & Lorem \\ \hline
Lorem ipsum dolor sit  & Lorem ipsum  & Lorem \\ \hline
Lorem ipsum dolor sit  & Lorem ipsum  & Lorem \\ \hline
Lorem ipsum dolor sit  & Lorem ipsum  & Lorem \\ \hline
Lorem ipsum dolor sit  & Lorem ipsum  & Lorem \\ \hline
Lorem ipsum dolor sit  & Lorem ipsum  & Lorem \\ \hline
Lorem ipsum dolor sit  & Lorem ipsum  & Lorem \\ \hline
Lorem ipsum dolor sit  & Lorem ipsum  & Lorem \\ \hline
Lorem ipsum dolor sit  & Lorem ipsum  & Lorem \\ \hline
Lorem ipsum dolor sit  & Lorem ipsum  & Lorem \\ \hline
Lorem ipsum dolor sit  & Lorem ipsum  & Lorem \\ \hline
Lorem ipsum dolor sit  & Lorem ipsum  & Lorem \\ \hline
Lorem ipsum dolor sit  & Lorem ipsum  & Lorem \\ \hline
Lorem ipsum dolor sit  & Lorem ipsum  & Lorem \\ \hline
Lorem ipsum dolor sit  & Lorem ipsum  & Lorem \\ \hline
Lorem ipsum dolor sit  & Lorem ipsum  & Lorem \\ \hline
Lorem ipsum dolor sit  & Lorem ipsum  & Lorem \\ \hline
Lorem ipsum dolor sit  & Lorem ipsum  & Lorem \\ \hline
Lorem ipsum dolor sit  & Lorem ipsum  & Lorem \\ \hline
Lorem ipsum dolor sit  & Lorem ipsum  & Lorem \\ \hline
Lorem ipsum dolor sit  & Lorem ipsum  & Lorem \\ \hline
Lorem ipsum dolor sit  & Lorem ipsum  & Lorem \\ \hline
Lorem ipsum dolor sit  & Lorem ipsum  & Lorem \\ \hline
Lorem ipsum dolor sit  & Lorem ipsum  & Lorem \\ \hline
Lorem ipsum dolor sit  & Lorem ipsum  & Lorem \\ \hline
Lorem ipsum dolor sit  & Lorem ipsum  & Lorem \\ \hline
Lorem ipsum dolor sit  & Lorem ipsum  & Lorem \\ \hline
Lorem ipsum dolor sit  & Lorem ipsum  & Lorem \\ \hline
	  \end{tabular}
	\vspace{-0.5cm}
	\end{table*}

Lorem ipsum 
	
 \end{document}
This should produce a one page document because the table is not too large (I have a large table that has no problem with other text on its page), but nevertheless this table takes one whole page, which leads to two pages in total. Delete one row in the table and all fits on one page.

However, my document has to use this given ACM sig-alternate class: http://www.acm.org/sigs/publications/sig-alternate.cls
It contains of ~1600 line of code and has lots of "float stuff" in it which may be the problem, but I have no idea how to minimize that.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Table unnecessarily floats to new page

Post by cgnieder »

Hi trine8,

welcome to the LaTeX community!

It seems the sig-alternate class typesets documents in two-column mode. And I guess you chose {table*} over the unstarred variant {table} because the table doesn't fit into one column. However, in the standard classes - and there is no reason that this class behaves differently in this aspect - the starred variant always is put on the next page. I don't know the details but I believe it has to with how output routine works would mean you only have two choices: accept the behaviour or make the table narrower so it fits in one column and use {table} instead of {table*}.

Regards
site moderator & package author
trine8
Posts: 4
Joined: Sat Feb 16, 2013 2:42 pm

Re: Table unnecessarily floats to new page

Post by trine8 »

Hi,

thanks again!

Unfortunately, the original table will never fit into one row and accepting the behavior means I would have to shorten my text by half a page :(

Are there no dirty hacks left? ;-) Only some millimeters are causing this trouble.

Furthermore, I cannot understand why it works with one table, but not with the second, although the first one is even larger.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Table unnecessarily floats to new page

Post by cgnieder »

The only thing that I can see you what you could do is move the source of the table to an earlier place in the document so it might be typeset on an earlier page. As I said (if I'm wrong I'll gladly be corrected): this is due to how LaTeX constructs pages. It needs to place the table than spans two columns before the text is set so the table is set as the first thing on a page and that is not the current page but the next one. If there are only two pages it will always be the second. Compare for example these two examples:

Code: Select all

% one page:
\documentclass[onecolumn]{article}
\begin{document}
Text
\begin{table*}
 a table
\end{table*}
   
\end{document}

Code: Select all

% two pages:
\documentclass[twocolumn]{article}
\begin{document}
Text
\begin{table*}
 a table
\end{table*}
   
\end{document}
As you can see the actual space has nothing to do with it: there's be more than enough space in the second example to place the table on the first page - yet it isn't done...

Regards
site moderator & package author
trine8
Posts: 4
Joined: Sat Feb 16, 2013 2:42 pm

Re: Table unnecessarily floats to new page

Post by trine8 »

Okay, strange, but somehow I did some magic: With {table*}[htb] it works in my document.. but not in my mini example. I hope, I will never have to compile my document again :D

Nevertheless, thank you guys a lot!
Post Reply