假设我有这个非常标准的 CSV 文件:
id,x0,y,sy,yhat,yerr,yrelerr,ychi2
0,-1,-1.083108355,0.075,-1.013608377,-0.069499978,0.068566894,0.85871057
1,-0.857142857,-0.625857469,0.075,-0.583690434,-0.042167035,0.072242122,0.316099357
2,-0.714285714,-0.103646818,0.075,-0.15377249,0.050125672,-0.32597295,0.446681425
3,-0.571428571,0.378297428,0.075,0.276145454,0.102151974,0.369920899,1.855115709
4,-0.428571429,0.721552903,0.075,0.706063397,0.015489506,0.02193784,0.042653297
5,-0.285714286,1.068762988,0.075,1.135981341,-0.067218353,-0.059172057,0.803254567
6,-0.142857143,1.576471029,0.075,1.565899284,0.010571745,0.006751229,0.019868763
7,0,1.955555616,0.075,1.995817228,-0.040261612,-0.020172995,0.288177313
8,0.142857143,2.358688591,0.075,2.425735171,-0.067046581,-0.027639695,0.799154489
9,0.285714286,2.936295065,0.075,2.855653115,0.08064195,0.028239407,1.15611094
10,0.428571429,3.346102227,0.075,3.285571059,0.060531168,0.018423333,0.651381746
11,0.571428571,3.814462054,0.075,3.715489002,0.098973052,0.026637961,1.741451551
12,0.714285714,4.110972552,0.075,4.145406946,-0.034434394,-0.008306638,0.210795996
13,0.857142857,4.54753839,0.075,4.575324889,-0.027786499,-0.00607312,0.137260362
14,1,4.935172219,0.075,5.005242833,-0.070070614,-0.013999443,0.872869489
我想要呈现如下表格:
\begin{table}[!ht]
\centering
\pgfplotstabletypeset[
debug=true,
col sep={\,},
row sep={\r\n},
header=has colnames,
every head row/.style={before row=\toprule},
every last row/.style={after row=\bottomrule}
]{./media/data.csv}
\end{table}
我收到以下错误:
! Missing \endcsname inserted.
<to be read again>
\protect
l.11 ]
{./media/data.csv}
我不明白。
我已经尝试过这些帖子:
没有成功。这个表出了什么问题?
答案1
对于你的下一个问题,你能提供一个可以复制粘贴并且可以编译的示例吗?这为帮助你的人解决了很多麻烦。我设法用以下代码编译了你的表格
\documentclass{article}
\usepackage{csvsimple}
\usepackage{pgfplotstable}
\usepackage{booktabs}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{table}[!ht]
\centering
\pgfplotstabletypeset[
col sep=comma,
header=has colnames,
every head row/.style={before row=\toprule},
every last row/.style={after row=\bottomrule}
]{data.csv}
\end{table}
\end{document}