缺少插入的 \endcsname。\进步

缺少插入的 \endcsname。\进步

我尝试在 overleaf 上编译此代码,但没有成功。下面是链接我的代码。

编译时显示此错误。

Missing \endcsname inserted.
<to be read again> 
                   \advance 
l.41     ]
          {n.csv} % filename/path to file 

我不知道发生了什么。打出我的表格需要很长时间。

答案1

实际上您不能将siunitxS列用作文本。更改它即可。

table output

\documentclass{article}
\usepackage{booktabs} % For \toprule, \midrule and \bottomrule
\usepackage{siunitx} % Formats the units and values
\usepackage{pgfplotstable} % Generates table from .csv
\pgfplotsset{compat=1.14}

% Setup siunitx:
\sisetup{
  round-mode          = places, % Rounds numbers
  round-precision     = 2, % to 2 places
}

\begin{filecontents}{n.csv}
Month,Solar Radiation(KWH/m2/day),Days Per Month,Output(KWh/month)
J,6.61,31,731.5287
February,6.92,28,691.7232
March,6.74,31,745.9158
April,5.9,30,631.89
May,5.48,31,606.4716
June,4.8,30,514.08
July,4.85,31,536.7495
August,5.05,31,558.8835
September,5.48,30,586.908
October,5.37,31,594.2979
November,5.4,30,578.34
December,6.09,31,673.9803
Yearly Totals,0,365,7450.7685
\end{filecontents}

\begin{document}

\begin{table}[h!]
  \begin{center}
    \caption{Autogenerated table from .csv file.}
    \label{table1}
    \pgfplotstabletypeset[
      multicolumn names, % allows to have multicolumn names
      col sep=comma, % the seperator in our .csv file
      display columns/0/.style={
        column name=$Month$, % name of first column
        column type={c},string type},  % use siunitx for formatting
      display columns/1/.style={
        column name=$Solar Radiation(KWHm2day)$,
        column type={S},string type},
        display columns/2/.style={
        column name=$Days Per Month$,
        column type={S},string type},
        display columns/3/.style={
        column name=$Output(KWhmonth)$,
        column type={S},string type},
      every head row/.style={
        before row={\toprule}, % have a rule at top
        after row={
            \si{\ampere} & \si{\volt}\\ % the units seperated by &
            \midrule % rule under units
        }
      },
        every last row/.style={after row=\bottomrule}, % rule at bottom
    ]{n.csv} % filename/path to file
  \end{center}
\end{table}

\end{document}

相关内容