pgfplotstabletypeset
我尝试使用和创建结果表tabularx
,但没有成功。我搞不懂,有人能帮忙吗?表格应该是这样的。
\documentclass{文章}
\usepackage{pgfplotstable}
%\pgfplotsset{compat=1.14}
\usepackage{pdflscape}
\usepackage{longtable}
\usepackage{booktabs}
\usepackage{filecontents}
\usepackage{tabularx}
\begin{document}
\begin{filecontents}{result3.dat}
,Chi2,Pvalue,Chi2,Pvalue,Chi2,Pvalue,Chi2,Pvalue
Variable XXXXXXXXXX,-9.49,0,-8,0,-7.14,0,-4.6,0
Variable YYYYYYYYYY,-8.73,0,-7.45,0,-7.18,0,-4.92,0
Variable ZZZZZZZZZZ,-5.05,0,-8.19,0,-3.75,0,-3.5,0
Variable WWWWWWWWWW,-17.85,0,-15.85,0,-10.73,0,-8.47,0
Variable VVVVVVVVVV,-7.32,0,-7.19,0,-7.08,0,-6.04,0
\end{filecontents}
\begin{center}
\begin{table}[!h]
\caption{Panel unit root tests}
\label{tab2}
\centering
\setlength\tabcolsep{1pt}
\pgfplotstabletypeset[
column type=,
begin table={\begin{tabularx}{\textwidth}{ccccccccc}},
end table={\end{tabularx}},
col sep = comma,
string type,
every head row/.style={
before row={\toprule
\multicolumn{1}{l}{} &
\multicolumn{4}{c}{ADF Fisher unit root test} &
\multicolumn{4}{c}{Phillips-Perron Fisher unit root test} \\
\cline{2-9} \\
\multicolumn{1}{l}{} &
\multicolumn{2}{c}{Without trend} &
\multicolumn{2}{c}{With trend} &
\multicolumn{2}{c}{Without trend} &
\multicolumn{2}{c}{With trend} \\
\cline{2-9}\\
}, after row={\midrule}
},
every last row/.style={
after row=\bottomrule},
display columns/0/.style={string type,column type={l}},
]{result3.dat}
\end{table}
\end{center}
\end{document}
答案1
好吧,您尝试设置列类型(最后一行之后),但您已经指定了列。只需删除它即可column type={l}
。
X
注意:如果使用,则应该至少有一列tabularx
,否则您可以使用tabular
。
\documentclass{article}
\usepackage{pgfplotstable}
%\pgfplotsset{compat=1.14}
\usepackage{pdflscape}
\usepackage{longtable}
\usepackage{booktabs}
\usepackage{filecontents}
\usepackage{tabularx}
\begin{document}
\begin{filecontents*}{result3.dat}
,Chi2,Pvalue,Chi2,Pvalue,Chi2,Pvalue,Chi2,Pvalue
Variable XXXXXXXXXX,-9.49,0,-8,0,-7.14,0,-4.6,0
Variable YYYYYYYYYY,-8.73,0,-7.45,0,-7.18,0,-4.92,0
Variable ZZZZZZZZZZ,-5.05,0,-8.19,0,-3.75,0,-3.5,0
Variable WWWWWWWWWW,-17.85,0,-15.85,0,-10.73,0,-8.47,0
Variable VVVVVVVVVV,-7.32,0,-7.19,0,-7.08,0,-6.04,0
\end{filecontents*}
\begin{center}
\begin{table}[!h]
\caption{Panel unit root tests}
\label{tab2}
\centering
\setlength\tabcolsep{1pt}
\pgfplotstabletypeset[
column type=,
begin table={\begin{tabularx}{\textwidth}{Xcccccccc}},
end table={\end{tabularx}},
col sep = comma,
string type,
every head row/.style={
before row={\toprule
\multicolumn{1}{l}{} &
\multicolumn{4}{c}{ADF Fisher unit root test} &
\multicolumn{4}{c}{Phillips-Perron Fisher unit root test} \\
\cline{2-9} \\
\multicolumn{1}{l}{} &
\multicolumn{2}{c}{Without trend} &
\multicolumn{2}{c}{With trend} &
\multicolumn{2}{c}{Without trend} &
\multicolumn{2}{c}{With trend} \\
\cline{2-9}\\
}, after row={\midrule}
},
every last row/.style={
after row=\bottomrule},
display columns/0/.style={string type},
]{result3.dat}
\end{table}
\end{center}
\end{document}