
pgfplotstable
및 을 사용하여 긴 테이블을 인쇄하고 싶습니다 long tabu
. 어떤 이유로 다음 코드를 사용하면 모든 페이지에서 헤더가 반복되지 않습니다. 또한 \bottomrule
"table xy (continued)"와 같은 모든 페이지에 캡션을 추가 하고 싶습니다 .
또한 내가 지정한 너비는 \begin{tabu} to 0.6\linewidth
무시됩니다.
\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}
비고: 내 데이터 파일이 DATA.txt
올바르게 로드되었으며 다음과 같은 일부 줄이 포함되어 있습니다.
1 2 3 4 5 6
답변1
"예제를 컴파일 가능하게 만든다"는 것은 filecontents
인라인 테이블을 사용하는 것을 의미합니다.
주어진 예에는 함께 묶을 수 있는 것들이 많이 있습니다. 동일한 명령 정의가 여러 번 있는 경우 이를 압축하는 방법을 찾으십시오. 이는 Word가 아니라 LaTeX입니다...
% arara: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 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}