0

I need some help to align the numbers in the last column to the \cdot AND decimal. Also center the numbers with the headers. Thanks.

Here is my code:

\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 Answer 1

1

column type={c} is incompatible with dec sep align. Actually dec sep align implies two columns r@{}l. That's the reason the headers are done with \multicolumn{2}.

The best you can do is something like

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

but centering with respect to the header is not a possibility.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .