# wrapfig and rotating place figure at end of document

With the packages wrapfig and rotating and calls to wraptable, sideways and tabular, I get a document where the table is placed at the end of the document. For instance, in a two page document defined by \pagebreak, my table gets placed on the second page, or at the end of the document, and not where I want it, on the first page where it is declared. Anyone know why this happens or have a work around?

\documentclass[12pt,letterpaper]{article}
\usepackage[american]{babel}
\usepackage{rotating}
\usepackage{wrapfig}

\begin{document}

\section{Test page 1}

\begin{wraptable}{r}{.5\textwidth}
\begin{sideways}
\begin{tabular}{l}
1 \\
2 \\
3 \\
4
\end{tabular}
\end{sideways}
\end{wraptable}

\pagebreak

\section{Test page 2}

\end{document}


Basically, I want to rotate a (sizable) table on a page that also has horizontal text.

-

wraptable is meant to be used along with text such that it wraps along. You just add text before and after wraptable, then things are set right.

\documentclass[12pt,letterpaper]{article}
\usepackage[american]{babel}
\usepackage{rotating}
\usepackage{wrapfig,lipsum}

\begin{document}

\section{Test page 1}
\lipsum[1]
\begin{wraptable}{r}{.5\textwidth}
\caption{A wrapped table will not float if there is enough text surrounding it.}\label{wrap-tab:1}
\begin{sideways}
\begin{tabular}{l}\\
1 \\
2 \\
3 \\
4
\end{tabular}
\end{sideways}
\end{wraptable}
\lipsum[2] %%% This provides text.
\pagebreak

\section{Test page 2}

\end{document}


-

Normally, using a lower case letter to specify horizontal placement will create a stationary wraptable or wrapfig, that is

\begin{wraptable}{r}{.5\textwidth}


does not float, whereas

\begin{wraptable}{R}{.5\textwidth}


does. However, stationary wrapfigs and wraptables can be forced to float under some circumstances. Sadly, the package documentation isn't very helpful here, but I have noticed that wraptables and wrapfigs can be very sensitive to what's around them. For example, inserting a short piece of text immediately before the wraptable in your code causes the table to appear on page 1.

-
I made the adjustment as suggested, but the result is the same. –  Chernoff Apr 25 '12 at 20:13
Actually my suggestion was wrong anyway! I have edited my answer, and I now get the wraptable on page 1, but it's hard to say whether it will help in your actual document. –  Ian Thompson Apr 25 '12 at 20:57