1

I am trying to read in a very long csv file to a longtable, but I am getting a missing \endgroup inserted error when compiling. I cannot figure out what is missing.

\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}

The csv file is being read in properly; when I try it with tabular instead of longtable it does read but the bottom gets cut off. I can't figure out what's missing.

2
  • 1
    Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. – Moriambar Apr 5 '17 at 19:02
  • Replace the document class standalone by some ordinary document class. The standalone class can only be used with single objects of a fixed size. As a side note, don't use vertical lines together with booktabs. – gernot Apr 5 '17 at 22:31
3

The standalone class adapts the size of the page to the contents of the document, and the longtable tries to adapt the columns to the size of the page, so this is too much flexibility.

The solution is to use either some standard document class or the standalone class with the varwidth option, like

\documentclass[varwidth=30cm]{standalone}

enter image description here

Note that due to the booktabs package the vertical lines are broken. Consider omitting the vertical lines.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.