pfgplottable 边框缺失

pfgplottable 边框缺失

我尝试在 pgfplottable 的左侧和右侧放置边框。

\begin{table}

\pgfplotstabletypeset[
 % col sep=comma,              %
 every head row/.style={
  before row={
    \hline
       & \multicolumn{3}{c|}{Unit [d]}\\
  },
  after row=\hline
},
% header=false,
every last row/.style={after row=\hline},
every even row/.style={
before row={\rowcolor[gray]{0.9}}},
col sep=comma,
string type,
columns/0/.style={column name={Task}, column type={|l}},
columns/1/.style={column name={A}, column type={|l}},
columns/2/.style={column name={B}, column type={|l}},
columns/3/.style={column name={C}, column type={|l|}},
]{
Task, A, B, C
Bread, 100, 50, 30
}
\caption{Tasks}
\end{table}

我认为,列类型指定在边框外部放置边框。但这我得到的是这样的。

有什么想法吗,为什么边框消失了?

答案1

这是一个可能的解决方案,其中将列样式 0、1、2、3 更改为 t、a、b、c,并简化列样式的代码。此外,第一行的内容应该是列样式,因为它们的名称是在样式定义中定义的。当前列类型为l左侧,如果希望居中,则改为使用c

caption要在环境中显示table,请启用相关命令并使用article类。

在此处输入图片描述

代码

\documentclass[border=1.5cm]{standalone}
\usepackage{pgfplots,amsmath,pgfplotstable}
\usepackage{xcolor,colortbl}
\pgfplotsset{compat=1.8}
\begin{document}
%\begin{table}
%\centering
\pgfplotstabletypeset[
 col sep=comma,              %
% row sep=\\,
 every head row/.style={
  before row={
    \hline
       & \multicolumn{3}{c|}{Unit [d]} \\
  },
  after row=\hline
},
% header=false,
every last row/.style={after row=\hline},
every even row/.style={
before row={\rowcolor[gray]{0.9}}},
col sep=comma, string type,
columns/t/.style={column type=|l,column name=Task},
columns/a/.style={column type=l,column name=A},
columns/b/.style={column name=B, column type=l},
columns/c/.style={column name=C, column type=l|},
]{
t, a, b, c
Bread, 100, 50, 30
}
%\caption{Tasks}
%\end{table}

\end{document}

相关内容