csv longtable 中缺少 \endgroup

csv longtable 中缺少 \endgroup

我正在尝试将一个非常长的 csv 文件读入 longtable,但在编译时出现错误missing \endgroup inserted。我不知道缺少了什么。

\documentclass{standalone}

\usepackage{csvsimple}
\usepackage{rotating}
\usepackage{tabularx}
\usepackage{longtable}
\usepackage{booktabs}

\begin{document}
%\begin{sidewaystable}
    \begin{longtable}{c|c|c|c|c|c|c|c}%

    \toprule

    \bfseries Obsid & \bfseries Source & \bfseries Raw Soft Counts & \bfseries Raw Medium Counts & \bfseries Raw Hard Counts & \bfseries Background Soft Counts & \bfseries Background Medium Counts & \bfseries Background Hard Counts % specify table head
    \\&&\bfseries (.3-1.0 keV)&\bfseries (1.0-2.1 keV)&\bfseries (2.1-7.5 keV)&\bfseries (.3-1.0 keV)&\bfseries (1.0-2.1 keV)&\bfseries (2.1-7.5 keV) \\
    \midrule \endhead
    \bottomrule \endfoot
    \csvreader[
    late after line=\\,
    late after last line=,
    before reading={\catcode`\#=12},
    after reading={\catcode`\#=6},
    respect all,
    head to column names]%
    {counts_info_from_csc.csv}{RAW_COUNTS[.3-1]=\rawcountsS,RAW_COUNTS[1-2.1]=\rawcountsM,RAW_COUNTS[2.1-7.5]=\rawcountsH,BKG_COUNTS[.3-1]=\bkgcountsS,BKG_COUNTS[1-2.1]=\bkgcountsM,BKG_COUNTS[2.1-7.5]=\bkgcountsH}{\OBSID & \SOURCE & \rawcountsS & \rawcountsM & \rawcountsH & \bkgcountsS & \bkgcountsM & \bkgcountsH}%

    \end{longtable}
%\end{sidewaystable}
\end{document}

csv 文件读入正确;当我尝试用tabular而不是 时,longtable它确实读入,但底部被截断。我搞不清楚缺少了什么。

答案1

该类standalone使页面大小适应文档的内容,并longtable尝试使列适应页面大小,因此灵活性太强了。

解决方案是使用一些标准文档类或standalone带有选项的类varwidth,例如

\documentclass[varwidth=30cm]{standalone}

在此处输入图片描述

请注意,由于booktabs包装的原因,垂直线被破坏了。考虑省略垂直线。

相关内容