![pgfplotstable を見出しの下に「強制的に」配置するにはどうすればよいでしょうか](https://rvso.com/image/305875/pgfplotstable%20%E3%82%92%E8%A6%8B%E5%87%BA%E3%81%97%E3%81%AE%E4%B8%8B%E3%81%AB%E3%80%8C%E5%BC%B7%E5%88%B6%E7%9A%84%E3%81%AB%E3%80%8D%E9%85%8D%E7%BD%AE%E3%81%99%E3%82%8B%E3%81%AB%E3%81%AF%E3%81%A9%E3%81%86%E3%81%99%E3%82%8C%E3%81%B0%E3%82%88%E3%81%84%E3%81%A7%E3%81%97%E3%82%87%E3%81%86%E3%81%8B.png)
この掲示板の推奨により、ラボ レポートで pgfplotstable を使用して CSV からデータをインポートし、LaTeX で表として印刷することにしました。ただし、付録などのセクションでは、表を見出しの下 (見出しの上ではなく) に配置する必要があるため、コード内に配置した場所に LaTeX で表を配置するにはどうすればよいでしょうか。
サンプル:
\appendix
\appendixpage
\section{Tables}
\begin{subappendices}
\subsection{Heading 1}
\pgfplotstableread{mydata.csv}{\mydatalabel}
\begin{table}
\centering
\caption[LoT Caption]{Full Caption}
\pgfplotstabletypeset[%
every head row/.style={
before row=\toprule, after row=\midrule},
every last row/.style={
after row=\bottomrule},
]{\mydatalabel}
\label{table:mydatalabel}
\end{table}
LaTeX は自動的にフォーマットし、表を見出し 1 (および他の見出しも) の上に配置します。
pgfplotstables を使用する前は、テーブルを意図した場所に強制的に配置するために次のコードを使用していました。
\begin{center}
\captionof{table}[LoT Caption]{Full Caption}
\begin{tabular}{c c c c}
\toprule
\bottomrule
\label{table:mydatalabel} \\
\end{tabular}
\end{center}
似たようなことはできますか?テーブルに手動でデータを入力する必要がなくなったので、これまでのところpgfplotstablesの使用が気に入っています。
答え1
\pgfplotstabletypeset
環境内で使用する必要はありません。環境が使用されるtable
場所であればどこでも使用できます。tabular
\label
最後のコードスニペットで環境内にコマンドが出現することにこだわっているかもしれません。これも必須tabular
ではありません。\label
後、\caption
期待通りに動作します。
では、その方法を説明します。pgfplotstable
データ ファイルにアクセスできないため、マニュアルのサンプル データ ファイルを使用しました。
\documentclass{article}
\usepackage{capt-of,pgfplotstable}
\pgfplotsset{compat=1.12}
\begin{document}
Table~\ref{table:mydata} is typeset just fine by \verb|pgfplotstable|,
even outside of a \verb|table| environment.
\begin{center}
\captionof{table}[Short Caption]{This is the full, long-form caption.}
\label{table:mydata}
\pgfplotstabletypeset[columns={dof,error1}]{pgfplotstable.example1.dat}
\end{center}
\end{document}