0

I have the following table:

ID,Ln,La,N$_{I}$,Period$_{I}$,$\sigma_{I}$
4,05:18:11.71,-00:01:35.7,13,45,3.56,1e-4
....

I am trying to create the table with the following code:

\documentclass[preprint,10pt]{aastex}
\usepackage[utf8]{inputenc}
\usepackage{caption}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{csvsimple,longtable,booktabs}
\usepackage{pdflscape}
\usepackage{afterpage}
\usepackage{pgffor}
\usepackage{float}
\usepackage{amsmath}
\usepackage[scientific-notation=true]{siunitx}
\usepackage{lscape}
\usepackage{csvsimple}
\citestyle{aa}

\usepackage[normalem]{ulem}
\usepackage{color}
\newcommand{\kgsins}[1]{\textcolor{blue}{#1}}
\newcommand{\kgsdel}[1]{\textcolor{red}{\sout{#1}}}


\begin{document}

\label{section:apptable}
{\setlength\tabcolsep{2.5pt}
\begin{flushleft}
\begin{flushleft}
\begin{landscape}
\small
\csvautolongtable[
  table head=\caption{some table}\\\hline
               \csvlinetotablerow\\\hline
              \endfirsthead\hline
              \csvlinetotablerow\\\hline
              \endhead\hline
              \endfoot]{table_v15demo.csv}
  \end{landscape}
  \end{flushleft}
   \end{flushleft}
\end{document}

The code compiles normally when I write sigma$_{I}$, but does not compile when I write $\sigma_{I}$ and instead get the following error:

Missing \endcsname inserted. \sigma l.711 \endfoot]{table_v15demo.csv}

The control sequence marked should not appear between \csname and \endcsname.

2

The problem is unrelated to amsmath, as you would have noticed if you had made a minimal example such as

\documentclass{article}

\usepackage{csvsimple,longtable}


\begin{document}


\csvautolongtable[
  table head=\caption{some table}\\\hline
               \csvlinetotablerow\\\hline
              \endfirsthead\hline
              \csvlinetotablerow\\\hline
              \endhead\hline
              \endfoot]{table_v15demo.csv}

\end{document}

The problem is that you are making internal macro names for the headings from the content of the first row and that can not work if you have non-expandable commands there. One possibility would be

\documentclass{article}

\usepackage{csvsimple,longtable}

\def\xsigma{\ifmmode\sigma\else\string\sigma\fi}
\begin{document}


\csvautolongtable[
  table head=\caption{some table}\\\hline
               \csvlinetotablerow\\\hline
              \endfirsthead\hline
              \csvlinetotablerow\\\hline
              \endhead\hline
              \endfoot]{table_v15demo.csv}

\end{document}

which uses \string to make the \sigma safe when not being typeset.

the csv file would then be

ID,Ln,La,N$_{I}$,Period$_{I}$,$\xsigma_{I}$
4,05:18:11.71,-00:01:35.7,13,45,3.56,1e-4
| improve this answer | |

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.