正确对齐长表中的最后一列

正确对齐长表中的最后一列

我需要一些帮助来将最后一列中的数字与\cdotAND 小数对齐。同时将数字与标题居中。谢谢。

这是我的代码:

\documentclass{book}

\usepackage{pgfplots, pgfplotstable, booktabs, colortbl, siunitx, array}
\pgfplotsset{compat=newest}
\usepackage{longtable}
\usepackage{booktabs}

\usepackage[a4paper,top=1in,bottom=1in,right=1in,left=1in]{geometry} 

\usepackage{filecontents}
\begin{filecontents}{t1PCA_KNN1.dat}
Test, Recog, eucl-min-dist
  1,   1, 2117152161.2166634
  2,   2, 1598439136.3832090
  3,  25, 1647045456.7444425
  4,   4, 886205782.4485940
  5,   5, 271948956.2398851
  6,   6, 653878414.5153273
  7,   7, 1340345307.4232824
  8,   8, 431759462.3791042
  9,   9, 1051308071.6470116
 10,  10, 1436531402.8133149
 11,  19, 2304006442.0983062
 12,  12, 1134781789.9087639
 13,  13, 286127652.4132110
\end{filecontents}%

\begin{document}

%%% Code from Dr. Christian ------ for not using headers.----------------------
\pgfkeysifdefined{/pgfplots/table/output empty row/.@cmd}{
    % upcoming releases offer this more convenient option:
    \pgfplotstableset{
        empty header/.style={
          every head row/.style={output empty row},
        }
    }
}{
    % versions up to and including 1.5.1 need this:
    \pgfplotstableset{
        empty header/.style={
            typeset cell/.append code={%
                \ifnum\pgfplotstablerow=-1 %
                    \pgfkeyssetvalue{/pgfplots/table/@cell content}{}%
                \fi
            }
        }
    }
}
%%%-----------------------------------------------

\pgfplotstabletypeset[
    empty header,
    begin table=\begin{longtable},
    columns/Test/.style={column type={c},dec sep align,precision=0},
    columns/Recog/.style={column type={c},dec sep align,precision=0},
    columns/eucl-min-dist/.style={column type={c},dec sep align,fixed zerofill,precision=2},
    rows/eucl-min-dist/.style={fixed zerofill,precision=2},
    every first row/.append style={before row={%
    \caption{This is a Table with Data}%
    \label{tab:DataTable}\\\toprule
    \multicolumn{2}{p{1.7cm}}{\centering{\bfseries{Test Subject}}} & \multicolumn{2}{p{1.7cm}}{\centering{\bfseries{Recog Subject}}} & \multicolumn{2}{p{1.7cm}}{\centering{\bfseries{Euclidean Min Dist}}}\\ \toprule
    \endfirsthead
    %
    \multicolumn{6}{c}%
    {{\bfseries Table \thetable\ Continued from previous page}} \\
    \toprule
    %
    \multicolumn{2}{p{1.5cm}}{\centering{\bfseries{Test Subject}}} & \multicolumn{2}{p{1.5cm}}{\centering{\bfseries{Recog Subject}}} & \multicolumn{2}{p{1.7cm}}{\centering{\bfseries{Euclidean Min Dist}}}\\ \toprule
    \endhead
    %
    \midrule \multicolumn{6}{r}{{Continued on next page}} \\ \bottomrule
    \endfoot
    %
    \midrule
    \multicolumn{6}{r}{} \\
    \endlastfoot
    }},
    end table=\end{longtable},
    col sep=comma,
    string type,
    ]{t1PCA_KNN1.dat}

\end{document} 

答案1

column type={c}与 不兼容dec sep align。实际上dec sep align意味着两列r@{}l。这就是标题用 完成的原因\multicolumn{2}

你能做的最好的事情就是

columns/eucl-min-dist/.style={sci, sci zerofill, dec sep align}, 

但相对于标题居中是不可能的。

相关内容