pgfplotstable longtabu wiederholender Header und andere Optionen

pgfplotstable longtabu wiederholender Header und andere Optionen

pgfplotstableIch möchte eine lange Tabelle mit und drucken long tabu. Aus irgendeinem Grund wird mit dem folgenden Code die Kopfzeile nicht auf jeder Seite wiederholt. Ich möchte außerdem \bottomruleauf jeder Seite ein und eine Überschrift wie „Tabelle xy (Fortsetzung)“.

Außerdem wird die von mir angegebene Breite \begin{tabu} to 0.6\linewidthignoriert.

\documentclass{scrreprt}

\usepackage{array}
\usepackage{tabu}
\usepackage{longtable}
\usepackage{booktabs}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\usepackage{siunitx}
\usepackage{caption}

\begin{document}

\pgfplotstableset{
    create on use/new/.style = {create col/expr={\pgfplotstablerow+1}}} % Indices of rows
\pgfplotstabletypeset[
        outfile=table.tex,
    begin table={\begin{longtabu} to 0.6\linewidth},
    end table={\end{longtabu}},
    every head row/.style={
        before row={
            \toprule
            },
        after row={
            % Specify units in header
            & unit & unit & unit & unit & unit & unit \\
            \midrule},
    },
    every last row/.style={
        after row={
            \bottomrule
            \caption[short]{long}\\
            \label{tab:table}\\
            }
        },
    multicolumn names,
    col sep=space,
    columns={
        new,
        [index]0,
        [index]1,
        [index]2,
        [index]3,
        [index]4,
        [index]5
    },
    % Index
    display columns/0/.style={
        column name=Index,
        column type={r},
        precision=1
    },
    display columns/1/.style={
        column name=$x_1$,
        column type={S},string type},
    display columns/2/.style={
        column name=$x_2$,
        column type={S},string type},
    display columns/3/.style={
        column name=$x_3$,
        column type={S},string type},
    display columns/4/.style={
        column name=$x_4$,
        column type={S},string type},
    display columns/5/.style={
        column name=$x_5$,
        column type={S},string type},
    display columns/6/.style={
        column name=$x_5$,
        column type={S},string type}
]{DATA.txt}

\end{document}

Bemerkung: Meine Datendatei DATA.txtwurde korrekt geladen und enthält einige Zeilen wie

1 2 3 4 5 6

Antwort1

„Das Beispiel kompilierbar machen“ bedeutet die Verwendung filecontentseiner Inline-Tabelle.

Im angegebenen Beispiel gibt es viele Dinge, die zusammengebündelt werden können. Wenn Sie x-mal dieselben Befehlsdefinitionen haben, suchen Sie nach Möglichkeiten, sie zu komprimieren – dies ist LaTeX, nicht Word ...

Bildbeschreibung hier eingeben

Bildbeschreibung hier eingeben

% arara: pdflatex
% arara: pdflatex
% arara: pdflatex

\RequirePackage{filecontents}
\begin{filecontents}{\jobname.txt}
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
\end{filecontents}

\documentclass[]{scrreprt}

\usepackage{pgfplotstable}
\usepackage{tabu}
\usepackage{longtable}
\usepackage{booktabs}

%\usepackage{array}
%\usepackage{caption}

%\usepackage{siunitx}

% Specify columns
\pgfplotsinvokeforeach{0,...,5} {%
\pgfplotstableset{
columns/#1/.style = {
column name=$x_{\pgfmathparse{int(#1+1)} \pgfmathresult}$,
%column type=r, 
%column type={S},
string type
},
}}%

% Indices of rows: 
\pgfplotstableset{
create on use/IndexCol/.style = {create col/expr={\pgfplotstablerow+1}},
columns/IndexCol/.style={column type=c}, 
column name={Index}
} 

% Sepcify Long Table
\pgfplotstableset{
LongTable/.style 2 args={%%%%%%%%%%%%%%%%
begin table={\begin{longtabu} to 0.6\textwidth},
end table={\end{longtabu}},
every head row/.style={
before row={
\caption{#2}\\
\endfirsthead 
\midrule
\multicolumn{\ColsNo}{c}{{Table \thetable\ Continued from previous page}} \\
\bottomrule
\endhead
\midrule \multicolumn{\ColsNo}{r}{Continued on next page} \\ \bottomrule
\endfoot 
\midrule
\multicolumn{\ColsNo}{r}{{End of Table \thetable}} \\ \bottomrule
\endlastfoot 
},
after row={& #1 \\ \midrule},
},
%every last row/.style={after row={}},
%multicolumn names,
}%%%%%%%%%%%%%%
}

\begin{document}
\chapter{My long table}

\pgfplotstablegetcolsof{\jobname.txt}
\pgfmathtruncatemacro\ColsNo{\pgfplotsretval+1}

\pgfplotstabletypeset[columns={IndexCol,0,1,...,5},
LongTable={ 
{{[unit]} & {[unit]} & {[unit]} & {[unit]} & {[unit]} & {[unit]}}%
{Long Table with Data  \label{tab:DataTable}}%
},
 outfile=table.tex,
]{\jobname.txt}
\end{document}

verwandte Informationen