Hallo,
I would like to wrap text around a table generated by a knitr code chunk. I found a solution for a regular table [here][1], but I didn't manage to re-implement it for a table generated by a code chunk. For a figure generated by a code chunk I just enclosed the chunk into wrapfigure control sequence, but when I tried to do the same with a table and wraptable I failed.
Would anyone have some idea how to do it? Thank you for any suggestions.
Regards
Kamila
The whole minimal code:
\documentclass[a4paper,12pt, english]{article}
\usepackage{graphicx}
\usepackage{wrapfig}
\begin{document}
sample text 1, sample text 1, sample text 1, sample text 1, sample text 1, sample text 1, sample text 1, sample text 1, sample text 1, sample text 1, sample text 1, sample text 1, sample text 1, sample text 1, sample text 1, sample text 1, sample text 1, sample text 1, sample text 1, sample text 1, sample text 1, sample text 1, sample text 1, sample text 1, sample text 1, sample text 1, sample text 1, sample text 1, sample text 1, sample text 1, sample text 1, sample text 1, sample text 1, sample text 1, sample text 1, sample text 1, sample text 1, sample text 1, sample text 1, sample text 1, sample text 1, sample text 1
\begin{wraptable}{r}{0.5\textwidth}
<<chunk_table, results="asis", echo=FALSE>>=
library(xtable)
print(xtable(head(iris[,c(1,2)])))
@
\caption [Iris]{Table iris caption, Table iris caption, Table iris caption, Table iris caption, Table iris caption, Table iris caption}
\end{wraptable}
sample text 2, sample text 2, sample text 2, sample text 2, sample text 2, sample text 2, sample text 2, sample text 2, sample text 2, sample text 2, sample text 2, sample text 2, sample text 2, sample text 2, sample text 2, sample text 2, sample text 2, sample text 2, sample text 2, sample text 2, sample text 2, sample text 2, sample text 2, sample text 2, sample text 2, sample text 2, sample text 2, sample text 2, sample text 2, sample text 2
\begin{wrapfigure}{r}{0.5\textwidth}
<<image,echo=FALSE, results='asis', echo=FALSE>>=
boxplot(na.omit(iris))
@
\caption [Iris]{Figure iris caption, Figure iris caption,Figure iris caption, Figure iris caption, Figure iris caption, Figure iris caption}
\end{wrapfigure}
sample text 3, sample text 3, sample text 3, sample text 3, sample text 3, sample text 3, sample text 3, sample text 3, sample text 3, sample text 3, sample text 3, sample text 3, sample text 3, sample text 3, sample text 3, sample text 3, sample text 3, sample text 3, sample text 3, sample text 3, sample text 3, sample text 3, sample text 3, sample text 3, sample text 3, sample text 3, sample text 3, sample text 3, sample text 3, sample text 3
\end{document}
[1]:
http://tex.stackexchange.com/questions/49300/wrap-text-around-a-tabular