将 pgfplottable 拆分为两列

将 pgfplottable 拆分为两列

我的附录中有一张长表,其中包含大量数据,我想将其拆分成两列(即并排放置两个表以占用更少的边)。这可能吗?

我的代码如下:

\documentclass{article}

\title{Applications of the Kalman Filter to Timeseries Analysis}
\author{Freddie Poser \& Andr\'e Renom}
\date{2017}

\usepackage{hyperref} 
\usepackage{url}
\usepackage[hyphenbreaks]{breakurl}
\usepackage{xcolor}
\usepackage{listings}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{caption}
\usepackage{import}
\usepackage[list=true]{subcaption}
\usepackage{pgfplots}
\usepackage[section]{placeins}
\usepackage{pgfplotstable}
\usepackage{pgfplots}
\usepackage{booktabs}
\usepackage{tikz}
\usepackage{amsmath}
\usepackage{multicol}
\usepackage{longtable}


\pgfplotstableset{% global config, for example in the preamble
    every head row/.style={before row=\toprule,after row=\midrule},
    every last row/.style={after row=\bottomrule},
    fixed,precision=2,
    begin table=\begin{longtable},
    end table=\end{longtable}
}
\usepgfplotslibrary{statistics}
\pgfplotstableread{results.dat}\datatable

\usepackage{float}
\floatstyle{plaintop}
\restylefloat{figure}
\usepackage[toc,page]{appendix}


\definecolor{code-green}{HTML}{29d875}
\definecolor{code-blue}{HTML}{297bd8}

\def\code#1{\texttt{#1}}

\renewcommand{\ttdefault}{pcr}
\lstset{
    basicstyle=\small\ttfamily,
    numbers=left,
    breaklines=true,
    postbreak=\raisebox{0ex}[0ex][0ex]{\ensuremath{\hookrightarrow\space}},
    keywordstyle=\bfseries,
    keywordstyle=[2]\itshape,
    keywordstyle=[3],
    stringstyle=\itshape,
    commentstyle=\color{gray},
    morecomment=[l][\color{magenta}]{\#},
    showstringspaces=false
}

\lstdefinelanguage{Scala}{  
    keywords=[2]{List, DenseVector},
    keywords=[3]{that, DELTA\_TIME},
    morekeywords={abstract,case,catch,class,def,
        do,else,extends,false,final,finally,
        for,if,implicit,import,match,mixin,
        new,null,object,override,package, 
        private,protected,requires,return,sealed,
        super,this,trait,true,try,
        type,val,var,while,with,yield,Double},
    sensitive,
    morecomment=[l]//,
    morecomment=[n]{/*}{*/},
    morestring=[b]",
    morestring=[b]',
    morestring=[b]""",
}


\newcommand{\matr}[1]{\mathbf{#1}}


\bibliographystyle{apalike}
\usepackage[paper=a4paper,margin=1in]{geometry}

\begin{document}
    \pgfplotstabletypeset[
    columns/SNAME/.style={
        string type
    },
    every head row/.style={
        output empty row
    },
    every first row/.style={before row={% <=================================
            \caption{This is a Table with Data}%
            \label{tab:DataTable}\\
            \toprule 
            Stock Index & Stock Name & $P_{kalman}$ & $P_{sma}$ & $P_{wma}$ \\ 
            \toprule    
            \endfirsthead % <=======================================================
            \multicolumn{5}{c}{{Table \thetable\ Continued from previous page}} \\
            \toprule
            Stock Index & Stock Name & $P_{kalman}$ & $P_{sma}$ & $P_{wma}$ \\ 
            \midrule
            \endhead % <============================================================
            \midrule \multicolumn{5}{r}{{Continued on next page}} \\ \bottomrule
            \endfoot % <============================================================
            \midrule
            \multicolumn{5}{r}{{End of table}} \\ \bottomrule
            \endlastfoot % <========================================================
    }}%
    ]{\datatable}

\end{document}

答案1

我找到了一个适合我的解决方案。我没有尝试将表格拆分为两列,而是使用键select equal part entry of将数据拆分为两组匹配的列。它看起来像这样:

\pgfplotstabletypeset[
    columns={S,SNAME,KAL,SMA,WMA,S,SNAME,KAL,SMA,WMA},
    display columns/0/.style={select equal part entry of={0}{2}, column name=$i$},
    display columns/1/.style={select equal part entry of={0}{2},string type, column name={Stock}},
    display columns/2/.style={select equal part entry of={0}{2}, column name=$P_{kalman}$},
    display columns/3/.style={select equal part entry of={0}{2}, column name=$P_{SMA}$},
    display columns/4/.style={select equal part entry of={0}{2}, column name=$P_{WMA}$},
    display columns/5/.style={select equal part entry of={1}{2}, column name=$i$},
    display columns/6/.style={select equal part entry of={1}{2},string type, column name={Stock}},
    display columns/7/.style={select equal part entry of={1}{2}, column name=$i$}
    display columns/8/.style={select equal part entry of={1}{2}, column name=$P_{SMA}$},
    display columns/9/.style={select equal part entry of={1}{2}, column name=$P_{WMA}$},
    every head row/.style={before row=\caption{Full experimental data}\label{tab:data}\\\toprule, after row=\midrule\endhead}
    ]{\datatable}

相关内容