0

enter image description hereI tried to create a result table using pgfplotstabletypeset and tabularx, however I have not succeeded. I cannot figure this out, could anyone help ? The table should look like this. enter image description here \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}{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}
DB225681
  • 147

1 Answers1

3

Well, you tried to set a column type (after last row), but you already had your columns specified. Just remove that column type={l}.

Notice: You should have at least one X column if you use tabularx, otherwise you could go with 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}
TeXnician
  • 33,589