pgfplotstable-合并表中的特定行

pgfplotstable-合并表中的特定行

有没有办法使用 pgfplotstable 合并表中特定行的单元格?

我想合并最后一行和倒数第二行的所有单元格,这样文本就可以横跨整个表格的宽度。我弄清楚了如何使用主行来实现这一点,但除了主行之外,找不到有关合并特定行的任何信息。

CSV 文件内容:

;coefficient;(SE);coefficient;(SE);coefficient;(SE);coefficient;(SE);coefficient;(SE)
Data ;;;;;;;;;;
Data 1;2.030;(.081);2.020;(.081);2.032;(.082);2.017;(.081);2.020;(.081)
Data 2;.117;(.212);.110;(.212);.110;(.212);.084;(.217);.110;(.212)
Data 3;2.002;(.020);2.004;(.020);2.004;(.020);2.004;(.020);2.003;(.020)
Note: All models include individual-level control variables: age, age-squared, gender, ethnicity, living together, having children, length of residence, employment status, highest educational level attained, highest education father.;;;;;;;;;;
*p , 0.05, **p , 0.01, ***p , 0.001;;;;;;;;;;

到目前为止的代码:

\documentclass{article}
    \usepackage{booktabs}
    \usepackage{pgfplotstable}
    \usepackage{pdflscape}    
\begin{document}
    \begin{landscape}
    \begin{table}[h!]
      \begin{center}
        \caption{Table title}
        \label{Table4}
    \pgfplotstabletypeset[
    multicolumn names,
        col sep=semicolon, 
        header=false,
        string type,
        every head row/.style={after row={\toprule & \multicolumn{2}{c}{model 1 }& \multicolumn{2}{c}{model 2} & \multicolumn{2}{c}{model 3} & \multicolumn{2}{c}{model 4} & \multicolumn{2}{c}{model 5}\\}},
        every first row/.style={after row=\midrule},
        every last row/.style={after row=\bottomrule},
        display columns/0/.style={column name=, column type = {p{.4\textwidth}}},
        display columns/1/.style={column name=},
        display columns/2/.style={column name=},
        display columns/3/.style={column name=},
        display columns/4/.style={column name=},
        display columns/5/.style={column name=},
        display columns/6/.style={column name=},
        display columns/7/.style={column name=},
        display columns/8/.style={column name=},
        display columns/9/.style={column name=},
        display columns/10/.style={column name=},
        ]{tabela4.csv}
     \end{center}
    \end{table}
    \end{landscape}
    \end{document}

答案1

我从最后两行中提取了注释并将其显示在\pgfplotstabletypeset本身之外。

我将阅读和排版步骤分开,尝试实际删除最后两行,但事实证明这样[skip rows between index=]做确实有效。

\documentclass{article}
    \usepackage{booktabs}
    \usepackage{pgfplotstable}
    \usepackage{pdflscape}  

    \newcounter{row}
    \newcommand{\note}{}% reserve global name
\begin{document}
    \begin{landscape}% automatic \clearpage
    \begin{table}[p]% vertically centers table in page
    \begin{center}% easier to turn off than \centering
        \caption{Table title}
        \label{Table4}
    \pgfplotstableread[% read in data
        col sep=semicolon, 
        header=false,
        string type]{temp.dat}\tableA
    % extract note from last two rows
    \pgfplotstablegetrowsof\tableA
    \setcounter{row}{\pgfplotsretval}%
    \addtocounter{row}{-2}% starts at row 0
    \edef\skiprow{\therow}% will be used later
    \pgfplotstablegetelem{\therow}{0}\of\tableA
    \let\note=\pgfplotsretval
    \stepcounter{row}%
    \pgfplotstablegetelem{\therow}{0}\of\tableA
    \xdef\note{\note{} \pgfplotsretval}%
    %
    \pgfplotstabletypeset[string type,multicolumn names,skip rows between index={\skiprow}{\pgfplotstablerows},
        every head row/.style={after row={\toprule & \multicolumn{2}{c}{model 1 }& \multicolumn{2}{c}{model 2} & \multicolumn{2}{c}{model 3} & \multicolumn{2}{c}{model 4} & \multicolumn{2}{c}{model 5}\\}},
        every first row/.style={after row=\midrule},
        every last row/.style={after row=\bottomrule},
        display columns/0/.style={column name=, column type = {l}},
        display columns/1/.style={column name=},
        display columns/2/.style={column name=},
        display columns/3/.style={column name=},
        display columns/4/.style={column name=},
        display columns/5/.style={column name=},
        display columns/6/.style={column name=},
        display columns/7/.style={column name=},
        display columns/8/.style={column name=},
        display columns/9/.style={column name=},
        display columns/10/.style={column name=},
        ]\tableA
    \end{center}
    \note
    \end{table}
    \end{landscape}% automatic \clearpage
    \end{document}

演示

相关内容