我如何“強制” pgfplotstable 位於標題下

我如何“強制” pgfplotstable 位於標題下

由於該板上的建議,我決定在我的實驗室報告中使用 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}

在此輸入影像描述

相關內容