23

I'm posting today because I would like to reduce white space in a document I'm writing. The content is two-columns but I have floating tables that span across both columns (table*).

At some point, the text ends in the beginning of the first column of a new page. I would like to include my table on this page since it has a lot of free space below the text, but when I insert the table* right after the text, it goes to the top of the next page instead:

Do you know a way of obtaining the desired behavior?

Minimal working example :

\documentclass{article}
\usepackage{lipsum}

\begin{document}
\twocolumn

\paragraph{}
\lipsum[1]

\begin{table*}
\centering
\begin{tabular}{|c|c|c|c|}
\hline
Column 1 & Column 2 & Column 3 & Column 4 \\
\hline
Column 1 & Column 2 & Column 3 & Column 4 \\
\hline
\end{tabular}
\end{table*}%


\end{document}
Moriambar
  • 11,466
beeb
  • 483
  • I add that the table goes at the top of the next page if I have content after the table, but is centered on the next page if I push the content afterwards one more page with \clearpage – beeb Apr 06 '13 at 19:11
  • 1
    Welcome to TeX.sx! Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. BTW include your comment in your Question to make it relevant and concise. – texenthusiast Apr 06 '13 at 19:13
  • 2
    Have a look at Keeping tables/figures close to where they are mentioned and How to influence the position of float environments like figure and table in LaTeX?, which might answer your question. In that case, we’d probably close your question as a duplicate, just to keep things tidy. – doncherry Apr 06 '13 at 19:18
  • 1
    Thanks for your comments, I included a MWE. None of the solutions proposed in the two links could help me because of the two-column environment. The only thing said about my situation is that I should move it earlier in the code in order for the table to appear at the top of the page. Thing is I want this table after the text. I know this is not standard tex behavior, but is there a way to force it? – beeb Apr 06 '13 at 19:30
  • i don't know of any way to force a full-width float to "backtrack" in a two-column environment unless it is input before the page on which it is to appear at the top. move it, and insert lots of comments in the source file to say what you did, and what you want the result to be. – barbara beeton Apr 06 '13 at 21:25
  • Ok thanks anyway, I'll keep looking to this thread if someone happens to know the answer, and I'll move the code of my table earlier in the code for now. Thanks ! – beeb Apr 06 '13 at 21:27
  • @barbarabeeton While I am by no means an expert on floats and their placement, I tried a few things with the given MWE and couldn’t get the desired result. Could you provide a working answer based on this code? – doncherry Apr 07 '13 at 14:42
  • @doncherry -- example is only semi-working; it depends on the float not being on the first page. – barbara beeton Apr 07 '13 at 19:07
  • @beeb -- since in a comment you mentioned that "there is apparently no way to put such a float at the bottom of a page" it seems that would also be acceptable, would you mind if i rephrased the question to "how to put a full-width table at the top or bottom of the same two-column page as the reference text"? – barbara beeton Apr 08 '13 at 19:08
  • @barbarabeeton no problem for me, go ahead ! – beeb Apr 08 '13 at 23:10

2 Answers2

16

there seems to be no way to put a full-width float at the top of the first page; various mechanisms are used to prevent it, and i haven't found a workaround. (this is most likely also true for the first page of a new chapter in a book or report. maybe frank mittelbach or david carlisle knows a way to do it.)

however, the question states that

At some point, the text ends in the beginning of the first column of a new page.

if it is acceptable to place the float on some page after the first, this is possible, by moving the input for the figure far enough earlier that it is read in (and then delayed) before the page is finished that will be the page preceding the one on which the figure is wanted.

the following example will do this. it's ugly, but it works; it's used in tugboat all the time. (tugboat almost never has the requirement to put such a float at the top of the first page, and if there is such a requirement, we revert to plain tex.) i've added a [t] to request that the float be positioned at the top; it's probably redundant, but it does have the desired effect with some document classes (amsart for one, but apparently not article) if the float ends up as the only thing on the page.

\documentclass{article}
\usepackage{lipsum}

\begin{document}
\twocolumn

\paragraph{}
\lipsum[1-4]

%% this table should appear *before* the paragraph indicated below.
%% it is placed here in the input to force its position at the top of the next page.
\begin{table*}[t]
\centering
\begin{tabular}{|c|c|c|c|}
\hline
Column 1 & Column 2 & Column 3 & Column 4 \\
\hline
Column 1 & Column 2 & Column 3 & Column 4 \\
\hline
\end{tabular}
\end{table*}

\lipsum[5-6]

%% the table coded above should appear at the top of the page on which
%% this paragraph appears.
\paragraph{I want the figure above this text}
\lipsum[1]

\end{document}

EDIT:

the example below will place the figure at the bottom of the page, across both columns, at the cost of an overfull box message. (i'm trying to figure out how to get rid of that, but haven't yet succeeded.)

the approach is to launch a single-column float somewhere in the first column, above where it will start. in the single-column float is embedded a minipage that is the full page width. after the first run, determine by how much the column was shortened, and, somewhere in the second column, issue a negative \enlargethispage command that will leave the bottom part of the page blank, allowing the full-width figure to overflow into the empty area.

\documentclass{article}
\usepackage{lipsum}

\begin{document}

\twocolumn

%% avoid overfull boxes from the lipsum test.
\sloppy

\paragraph{}
\lipsum[1]

%% this table should appear at the bottom of the page.
%% it must be placed in the input somewhere near the top of the
%% first column so that it will actually appear in the first column.
\begin{table}[b]
\begin{minipage}{\textwidth}
\centering
\begin{tabular}{|c|c|c|c|}
\hline
Column 1 & Column 2 & Column 3 & Column 4 \\
\hline

Column 1 & Column 2 & Column 3 & Column 4 \\
\hline
\end{tabular}
\end{minipage}
\end{table}

%% the table coded above should appear at the bottom of the page on which
%% this paragraph appears.
\textbf{I want the figure at the bottom of the page}

\lipsum[1]

\lipsum[2]

%% somewhere in the second column, reduce the page (column) length
%% by the amount needed to clear the figure.
\enlargethispage{-4\baselineskip}

\lipsum[3-6]

\end{document}

yes, it's ugly. don't say you weren't warned.

additional caveat -- the vertical spacing can be fouled up by section headings that have stretch built in. that makes this an iterative process. try to avoid applying this approach until your text is final, and even then, it might be wise to try to "fix" a page break at the top of the page on which the table is to appear.

EDIT 2:

the kludge described here became a tugboat article, "placing a full-width insert at the bottom of two columns", tugboat 35:3 (2014), p.255. (like all tugboat articles in electronic form, this article has a one-year "embargo" during which it is available only to tug members; it will become available to everyone sometime in late fall, 2015.)

one important point mentioned in the article is that the stfloats package, mentioned in Put a table* at the bottom of a page? works only for pages after the first page.

David Carlisle
  • 757,742
  • Hello, thanks for your reply, that's what I did to solve my problem since there is apparently no way to put such a float at the bottom of a page. – beeb Apr 07 '13 at 22:09
  • there's no automatic way to put a full-width float at the bottom of a page. there is a totally horrendous workaround that i will try to explain tomorrow. (it's time for supper now.) – barbara beeton Apr 07 '13 at 22:26
  • Thank you for the edit, that's exactly what I wanted ! I know it's not pretty but it's a workaround so I'm happy ! Thanks :) – beeb Apr 08 '13 at 23:14
  • 1
    you could put \hspace*{-\textwidth} immediately after the minipage or put the minipage in \makebox[0pt][l]{....] to hide eh width and avoid the overfull box warning – David Carlisle Dec 16 '14 at 15:19
  • @DavidCarlisle -- the (fairly ridiculous) approach i took in the article was to set \setlength{\hfuzz}{1.1\columnwidth} at the baginning of \begin{figure}. – barbara beeton Dec 16 '14 at 15:24
  • @barbarabeeton my typing accuracy is apparently contagious – David Carlisle Dec 16 '14 at 15:26
  • @DavidCarlisle -- my typing accuracy is about as good ... but i've learned how to proofread. – barbara beeton Dec 16 '14 at 15:32
  • @barbarabeeton I've tried this trick here http://tex.stackexchange.com/questions/3527/put-a-table-at-the-bottom-of-a-page to place full-width float at the bottom of a twocolumn page in the elsarticle template. It seems to work well. Doesn't solve the issue about "same page" placement though. – Jean-Sébastien Apr 22 '15 at 04:27
  • 1
    @Jean-SébastienGosselin -- not exactly sure what you mean by "same page" placement, but it's definitely necessary to place the input for the float well before the point where it should be positioned, to make sure that there is sufficient room remaining for the insertion in the first column. (tex is "one way".) i've added a reference/link to a tugboat article that expands on this answer. – barbara beeton Apr 22 '15 at 12:51
  • @barbarabeeton Yes, that is what I meant by "same page". I should have said "same page as the reference text". Thanks for the reference, will take a look at it. – Jean-Sébastien Apr 22 '15 at 12:56
5

I found this working best for me, especially with a two-column figure/table at the bottom of the first page:

% The trick is with the following package. You **need** to use the following package.
\usepackage{nidanfloat}

% ....

% Put your figure near the first page content.
\begin{figure*}[b]
    \centering
    \def\svgwidth{\textwidth}
    \import{sections/images/}{some_figure.pdf_tex}
    \caption{Some caption.}
    \label{fig:some_label}
\end{figure*}