..png)
루프에서 출력된 텍스트 파일에 행을 생성하는 @egreg로부터 코드를 얻습니다.
이 모든 행을 1 pgfplotstable에 모아야 합니다. 이는 다음과 같은 의미입니다.
\ifnum\the\filecount=1 \pgfplotstableread[col sep=comma]{data\the\filecount.txt}{\main}\else
\pgfplotstableread[col sep=comma]{data\the\filecount.txt}{\temp}
% \pgfplotstablevertcat{\main}{\temp} % <--- Does not work!
pgfplotstablevertcat-명령을 어떻게 배치해야 합니까?
주요 알고리즘의 경우 이전 행의 내용을 후속 행에 청구해야 합니다. 그러므로 이 정교한 출력 방법에서는 처음으로 남겨 두겠습니다. 나중의 주요 코드는 나중에 논의하고 단순화할 수 있습니다.
\documentclass[a4paper]{article}
\usepackage{pgfplotstable}
\newcount\filecount
\newwrite\cisout
\begin{document}
\filecount=1
\def\aaa{file number \the\filecount}%
\loop
\immediate\openout\cisout=data\the\filecount.txt
\immediate\write\cisout{%
111, 222, \aaa
}
\immediate\closeout\cisout
\ifnum\the\filecount=1 \pgfplotstableread[col sep=comma]{data\the\filecount.txt}{\main}\else
\pgfplotstableread[col sep=comma]{data\the\filecount.txt}{\temp}
% \pgfplotstablevertcat{\main}{\temp} % <--- Does not work!
\fi
\advance\filecount by 1
\ifnum\filecount<5
\repeat
\section{The Main Table is incomplete}
\pgfplotstabletypeset[col sep=comma, string type]{\main}
\section{The last Temp-Table}
\pgfplotstabletypeset[col sep=comma, string type]{\temp}
\section{Input Test}
\input{data1.txt} \\
\input{data2.txt}\\
\input{data3.txt}\\
\input{data4.txt}
\end{document}
답변1
다음과 같이 작동합니다.
\documentclass[a4paper]{article}
\usepackage{pgfplotstable}
\pgfplotstableset{string type}
\newcount\filecount
\newwrite\cisout
\begin{document}
\filecount=1
\def\aaa{\the\filecount}%
\loop
\immediate\openout\cisout=data\the\filecount.txt
\immediate\write\cisout{%
111, 222, \aaa
}
\immediate\closeout\cisout
\ifnum\the\filecount=1 \pgfplotstableread[col sep=comma, string type]{data\the\filecount.txt}{\main}%
\else \pgfplotstableread[col sep=comma, string type]{data\the\filecount.txt}{\temp}%
\pgfplotstablevertcat{\main}{\temp}% <--- Does work!
\fi%
\advance\filecount by 1
\ifnum\filecount<5
\repeat
\section{The Main Table is incomplete}
\pgfplotstabletypeset[col sep=comma, string type]{\main}
\section{The last Temp-Table}
\pgfplotstabletypeset[col sep=comma, string type]{\temp}
\section{Input Test}
\input{data1.txt} \\
\input{data2.txt}\\
\input{data3.txt}\\
\input{data4.txt}
\end{document}