# Float pgfplotstable to right of text

I want to float a smaller table to the right of my text. Here is an example of the code:

% Example Table
\documentclass{minimal}
\begin{filecontents*}{scientists.csv}
name,surname,age
Albert,Einstein,133
Marie,Curie,145
Thomas,Edison,165
\end{filecontents*}

% Read in Table

\documentclass{article}
\usepackage{pgfplotstable}
\begin{document}
\section*{Section 1}  I want to have this text wrap around the small table to the right.  This is actually a longer paragraph which would fill the side of the page.

\begin{table}
\pgfplotstabletypeset[
col sep=comma,
string type,
columns/name/.style={column name=Name, column type={|l}},
columns/surname/.style={column name=Surname, column type={|l}},
columns/age/.style={column name=Age, column type={|c|}},
every head row/.style={before row=\hline,after row=\hline},
every last row/.style={after row=\hline},
]{scientists.csv}
\end{table}
\end{document}


Thanks for help with a simple question,

-

You can use the wraptable environment from the wrapfig package; a little example:

\documentclass{article}
\begin{filecontents*}{scientists.csv}
name,surname,age
Albert,Einstein,133
Marie,Curie,145
Thomas,Edison,165
\end{filecontents*}

% Read in Table

\usepackage{pgfplotstable}
\usepackage{wrapfig}

\begin{document}
\section*{Section 1}
\begin{wraptable}{r}{5cm}
\centering
\pgfplotstabletypeset[
col sep=comma,
string type,
columns/name/.style={column name=Name, column type={|l}},
columns/surname/.style={column name=Surname, column type={|l}},
columns/age/.style={column name=Age, column type={|c|}},
every head row/.style={before row=\hline,after row=\hline},
every last row/.style={after row=\hline},
]{scientists.csv}
\end{wraptable}
I want to have this text wrap around the small table to the right.  This is actually a longer paragraph which would fill the side of the page. I want to have this text wrap around the small table to the right.  This is actually a longer paragraph which would fill the side of the page. I want to have this text wrap around the small table to the right.  This is actually a longer paragraph which would fill the side of the page. I want to have this text wrap around the small table to the right.  This is actually a longer paragraph which would fill the side of the page.

\end{document}


Of course (as a suggestion), the booktabs package can contribute to increase the quality of your table:

\documentclass{article}
\begin{filecontents*}{scientists.csv}
name,surname,age
Albert,Einstein,133
Marie,Curie,145
Thomas,Edison,165
\end{filecontents*}

% Read in Table

\usepackage{pgfplotstable}
\usepackage{wrapfig}
\usepackage{booktabs}

\begin{document}
\section*{Section 1}
\begin{wraptable}{r}{5cm}
\centering
\pgfplotstabletypeset[
col sep=comma,
string type,
columns/name/.style={column name=Name, column type={@{}l}},
columns/surname/.style={column name=Surname, column type={l}},
columns/age/.style={column name=Age, column type={c@{}}},
every head row/.style={before row=\toprule,after row=\cmidrule(r){1-1}\cmidrule(lr){2-2}\cmidrule(l){3-3}},
every last row/.style={after row=\bottomrule},
]{scientists.csv}
\end{wraptable}
I want to have this text wrap around the small table to the right.  This is actually a longer paragraph which would fill the side of the page. I want to have this text wrap around the small table to the right.  This is actually a longer paragraph which would fill the side of the page. I want to have this text wrap around the small table to the right.  This is actually a longer paragraph which would fill the side of the page. I want to have this text wrap around the small table to the right.  This is actually a longer paragraph which would fill the side of the page.

\end{document}


-
Thanks -- when I do that, the table appears over my text... How can I prevent this? Nevermind, this occurred because it was over an itemize –  mike Dec 10 '12 at 18:18
@mike yes; wraptable and wrapfigure don't behave well near lists; you can use the environments after a list and after using \par (or leaving a blank line) in-between. On a side note, I added another option to my answer using the booktabs package. –  Gonzalo Medina Dec 10 '12 at 18:26