我尝试在使用longtable
和时导入 .csv pdfplotstabletypeset
。我无法使longtable
命令运行。
\documentclass[12pt,a4paper,oneside]{report}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{longtable}
\usepackage{pgfplotstable}
\usepackage{ragged2e}
\usepackage{pdfpages}
\usepackage{pdflscape}
\usepackage{tikz}
\usepackage{subcaption}
\begin{filecontents*}{MYFILE.csv}
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
Software,A
\end{filecontents*}
\begin{document}
\begin{table}[!htb]
% \setstretch{1.1}
\pgfplotstabletypeset[
column type=,
col sep=comma,
string type,
begin table={\begin{longtable}{p{5cm}p{10cm}}},
% begin table={\begin{longtable}{@{*}r||p{1in}@{*}},
end table={\end{longtable}},
every head row/.style={
before row={\toprule},
after row={\midrule\addlinespace}},
assign column name/.style={/pgfplots/table/column name={\textbf{#1}}},
every last row/.style={after row=\midrule},
every row no 5/.style={after row=\toprule\addlinespace},
every row no 6/.style={after row=\midrule\addlinespace},
every row 6 column 0/.style={postproc cell content/.style={@cell content=\textbf{##1}}},
every row no 14/.style={after row=\toprule\addlinespace},
every row no 15/.style={after row=\midrule\addlinespace},
every row 15 column 0/.style={postproc cell content/.style={@cell content=\textbf{##1}}},
every row no 18/.style={after row=\toprule\addlinespace},
every row no 19/.style={after row=\midrule\addlinespace},
every row 19 column 0/.style={postproc cell content/.style={@cell content=\textbf{##1}}},
every row no 22/.style={after row=\toprule\addlinespace},
every row no 23/.style={after row=\midrule\addlinespace},
every row 23 column 0/.style={postproc cell content/.style={@cell content=\textbf{##1}}},
every row no 26/.style={after row=\toprule\addlinespace},
every row no 27/.style={after row=\midrule\addlinespace},
every row 27 column 0/.style={postproc cell content/.style={@cell content=\textbf{##1}}},
]{MYFILE.csv}
\end{table}
\end{document}
答案1
环境table
不能跨页,longtable
应在table
s 之外使用。因此,删除\begin{table}
和\end{table}
。如果您希望在表格顶部添加标题,请执行例如every head row/.style={before row={\caption{foo}\\\toprule}, ...
答案2
这是对我有用的代码:
\pgfplotstabletypeset[
column type=,
col sep=comma,
string type,
begin table={\begin{longtable}{p{5cm}p{10cm}}},
end table={\end{longtable}},
every head row/.style={
before row={\toprule},
after row={\midrule\addlinespace}},
assign column name/.style={/pgfplots/table/column name={\textbf{#1}}},
every last row/.style={after row=\midrule},
every row no 5/.style={after row=\toprule\addlinespace},
every row no 6/.style={after row=\midrule\addlinespace},
every row 6 column 0/.style={postproc cell content/.style={@cell content=\textbf{##1}}},
every row no 14/.style={after row=\toprule\addlinespace},
every row no 15/.style={after row=\midrule\addlinespace},
every row 15 column 0/.style={postproc cell content/.style={@cell content=\textbf{##1}}},
every row no 18/.style={after row=\toprule\addlinespace},
every row no 19/.style={after row=\midrule\addlinespace},
every row 19 column 0/.style={postproc cell content/.style={@cell content=\textbf{##1}}}
]{MYFILE.csv}