3

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,

1 Answer 1

4

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}

enter image description here

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}

enter image description here

2
  • 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
    Commented Dec 10, 2012 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. Commented Dec 10, 2012 at 18:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .