构建\csvreader
一个没有标题且有十一列的表格似乎行不通。
\documentclass{standalone}
\usepackage{array}
\usepackage{longtable}
\usepackage{csvsimple}
\begin{filecontents*}{data.csv}
0.1,0.4,0.7,1.0,1.3,1.6,1.9,2.2,2.5,2.8,3.1,3.4
0.2,1.0,1.8,2.6,3.4,4.2,5.0,5.8,6.6,7.4,8.2,9.0
\end{filecontents*}
\begin{document}
\begin{tabular}{cccccccccccc}
\hline
\csvreader[no head,table head=\hline,late after line=\\\hline]{data.csv}{1=\one,2=\two,3=\three,4=\four,5=\five,6=\six,7=\seven,8=\eight,9=\nine,10=\ten,11=\eleven}
{\thecsvrow & \one & \two & \three & \four & \five & \six & \seven & \eight & \nine & \ten & \ten & \eleven}
\end{tabular}
\end{document}
引发以下错误:
Package pgfkeys Error: I do not know the key '/csv head/11', to which you passed '\eleven ', and I am going to ignore it. Perhaps you misspelled it. ... & \eight & \nine & \ten & \ten & \eleven}
从 csvreader 中取出第 11 列可以解决问题,但是是否有解决方案或解决方法来获得第 11 列或更多列?
答案1
该csvsimple
包默认最多有十列,但可以通过设置键来调整数量column count
。
\begin{filecontents*}{\jobname.csv}
0.1,0.4,0.7,1.0,1.3,1.6,1.9,2.2,2.5,2.8,3.1,3.4
0.2,1.0,1.8,2.6,3.4,4.2,5.0,5.8,6.6,7.4,8.2,9.0
\end{filecontents*}
\documentclass{standalone}
\usepackage{array}
\usepackage{longtable}
\usepackage{csvsimple}
\begin{document}
\begin{tabular}{cccccccccccc}
\hline
\csvreader[
column count=11,
no head,
table head=\hline,
late after line=\\\hline
]{\jobname.csv}{
1=\one, 2=\two, 3=\three, 4=\four,
5=\five, 6=\six, 7=\seven, 8=\eight,
9=\nine, 10=\ten, 11=\eleven
}
{\thecsvrow & \one & \two & \three & \four & \five & \six & \seven & \eight & \nine & \ten & \eleven}
\end{tabular}
\end{document}