# wrapping a rotated table

I have a rather wide table that doesn't fit to page width, so I rotated it. The fit is nice, but my idea was to have text wrapped around this rotated table.

So far I found two choices that are mutually exclusive. If I use wraptable,

\begin{wraptable}{l}{0.3\textwidth}
\begin{sideways}
...
\end{sideways}
\end{wraptable}


I get a nice flipped and wrapped table, but the caption doesn't follow and it looks weird, having a 0.3\textwidth caption above a slim table.

If I use sidewaystable

\begin{sidewaystable}
\begin{tabular}...
...
\end{tabular}
\end{sidewaystable}


the table and caption looks OK, but it's placed on a new page and I can't figure out how to align it to one of the margins and have text wrapped around it.

Question: How to rotate table, caption, push the table to one of the margins and have text wrapped around the sides of the table?

\documentclass{article}
\usepackage{wrapfig,graphicx}

\begin{document}

\begin{wraptable}{l}{0.3\textwidth}
\sbox0{\begin{tabular}{ccc}
aaa aa aaa a aaa aa&b b b b b bb bb&ccc ccc ccc ccc\\
aaa a a aa a& bbb bbb bbb bbb bbb bbb bbb&c c c c c
\end{tabular}}
\rotatebox{90}{%
\parbox{\wd0}{\centering
\caption{long long long caption goes here}
\endgraf\bigskip
\usebox0}}
\end{wraptable}
\def\a{a a a a a a a a a a a a }
\def\b{\a\a\a\a\a\a\a\a\a\a\a\a\a\a}
\b\b\b\b\b\b\b

\end{document}

• Great explanation!, as usual ;-) +1. – user11232 May 7 '13 at 15:00