将 pgfplotstable 浮动到文本右侧

将 pgfplotstable 浮动到文本右侧

我想在文本右侧浮动一个较小的表格。以下是代码示例:

% 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}

感谢您帮助我解答一个简单的问题,

答案1

您可以使用wraptable来自wrapfig包;一个小例子:

\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}

在此处输入图片描述

当然(作为建议),booktabs包装可以有助于提高您的桌子的质量:

\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}

在此处输入图片描述

相关内容