包 siunitx 错误:无效的数字输入‘E’。$RET$&

包 siunitx 错误:无效的数字输入‘E’。$RET$&

我正在创建这个包含数字和文字的表格。

 \documentclass[11pt]{report}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{float,lipsum,subfig}
\usepackage{adjustbox,tabularx,ragged2e}
\usepackage{amsmath,geometry,booktabs}
\usepackage{mathtools,array,dcolumn,longtable}
\newcolumntype{L}[1]{>{\RaggedRight\arraybackslash\hsize=#1\hsize}X}
\setlength\tabcolsep{4pt} % default: 6pt  % '2pt' is not exactly much
\usepackage[justification = centering]{caption}
\usepackage{setspace}
\usepackage{geometry}
\usepackage{titlesec}    
\usepackage{lipsum}
\usepackage{etoolbox}
\usepackage{siunitx}

\usepackage[nodisplayskipstretch]{setspace}
\onehalfspacing
\usepackage[skip=1ex]{caption}
\newrobustcmd{\B}{\bfseries}

\begin{document}

\singlespacing  
\begin{longtable}{S[table-format=2.0]
        *{3}{S[table-format=2.1]}
        S[table-format=2.1,detect-weight]
    }
    \caption{}
    \label{tab:descr_stat_es}\\
    \toprule
    {Geological fm.} &{L mean} &{L std} &{R mean}  &{R std}\\
    \midrule
    \endfirsthead
    \caption[]{}\\
    \toprule
    {Geological fm.} &{L mean} &{L std} &{R mean}  &{R std}\\
    \midrule
    \endhead
    \midrule[\heavyrulewidth]
    \multicolumn{5}{r}{\footnotesize\textit{Continued on the next page}}
    \endfoot
    \bottomrule
    \endlastfoot
    $MAC$&  377.9&  41.7&   14.4&   1.8 \\
    $MAC$&  423.9&  36.5&   15.8&   1.9 \\
    $MAC$&  425.3&  33.3&   14.0&   2.6 \\
    $MAC$&  466.3&  56.8&   20.8&   5.6 \\
    $MAC$&  499.8&  86.4&   20.2&   7.0 \\
    $MAC$&  538.8&  45.3&   26.3&   2.4 \\
    $MAC$&  543.7&  47.4&   26.5&   2.8 \\
    $MAC$&  588.1&  122.7&  40.1&   7.2 \\
    $MAC$&  601.7&  143.7&  44.1&   5.6 \\
    $MAC$&  614.5&  54.4&   27.4&   2.9 \\
    $MAC$&  623.7&  80.7&   33.7&   4.7 \\
    $RET$&  636.7&  121.9&  35.7&   6.9 \\
    $RET$&  691.2&  51.4&   40.9&   5.0 \\
    $MAC$&  710.3&  59.6&   39.0&   4.3 \\
    $MAC$&  761.3&  60.3&   57.7&   2.3 \\
    $MAC$&  762.9&  41.6&   58.5&   1.5 \\
    $MAC$&  766.8&  36.2&   56.4&   2.0 \\
    $MAC$&  767.0&  49.7&   58.9&   1.8 \\
    $MAC$&  774.0&  39.1&   59.2&   2.3 \\
    $MAC$&  780.0&  64.2&   57.0&   2.5 \\
\end{longtable}
\onehalfspacing

\end{document}

我收到此错误:

Package siunitx Error: Invalid numerical input 'E'. $RET$&

我怎样才能告诉 Latex 第一列不是数字输入?

答案1

不要将S列类型用于第一列(即最左侧的列):该列不包含数字(带或不带小数点标记),因此S在此处使用列类型不会产生任何效果。相反,请使用基本l列类型,并去掉$数学模式起始符和终止符。

此外,不要多次加载诸如setspacegeometry和之类的包。lipsum

在此处输入图片描述

\documentclass[11pt]{report}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{float,lipsum,subfig}
\usepackage{adjustbox,tabularx,ragged2e}
\usepackage{amsmath,geometry,booktabs}
\usepackage{mathtools,array,dcolumn,longtable}
\newcolumntype{L}[1]{>{\RaggedRight\arraybackslash%
       \hsize=#1\hsize\linewidth=\hsize}X}
\setlength\tabcolsep{4pt} % default: 6pt  % '2pt' is not exactly much
\usepackage[justification = centering]{caption}
%%%%\usepackage{setspace}  % don't load packages repeatedly
%%%%\usepackage{geometry}
\usepackage{titlesec}    
%%%%\usepackage{lipsum}
\usepackage{etoolbox}
\usepackage{siunitx}

\usepackage[nodisplayskipstretch]{setspace}
\onehalfspacing

\usepackage[skip=1ex]{caption}
\newrobustcmd{\B}{\bfseries}

\begin{document}

%\singlespacing   % <-- not needed for 'longtable'
\begin{longtable}{@{}
             l
        *{2}{S[table-format=3.1]}
             S[table-format=2.1]
             S[table-format=1.1]
    @{} }
    %% header and footer information
    \caption{}
    \label{tab:descr_stat_es}\\
    \toprule
    {Geological fm.} &{L mean} &{L std} &{R mean} &{R std}\\
    \midrule
    \endfirsthead

    \caption[]{}\\
    \toprule
    {Geological fm.} &{L mean} &{L std} &{R mean} &{R std}\\
    \midrule
    \endhead

    \midrule[\heavyrulewidth]
    \multicolumn{5}{r}{\footnotesize\textit{Continued on the next page}}
    \endfoot

    \bottomrule
    \endlastfoot

    %% body of longtable
    MAC&  377.9&  41.7&   14.4&   1.8 \\
    MAC&  423.9&  36.5&   15.8&   1.9 \\
    MAC&  425.3&  33.3&   14.0&   2.6 \\
    MAC&  466.3&  56.8&   20.8&   5.6 \\
    MAC&  499.8&  86.4&   20.2&   7.0 \\
    MAC&  538.8&  45.3&   26.3&   2.4 \\
    MAC&  543.7&  47.4&   26.5&   2.8 \\
    MAC&  588.1&  122.7&  40.1&   7.2 \\
    MAC&  601.7&  143.7&  44.1&   5.6 \\
    MAC&  614.5&  54.4&   27.4&   2.9 \\
    MAC&  623.7&  80.7&   33.7&   4.7 \\
    RET&  636.7&  121.9&  35.7&   6.9 \\
    RET&  691.2&  51.4&   40.9&   5.0 \\
    MAC&  710.3&  59.6&   39.0&   4.3 \\
    MAC&  761.3&  60.3&   57.7&   2.3 \\
    MAC&  762.9&  41.6&   58.5&   1.5 \\
    MAC&  766.8&  36.2&   56.4&   2.0 \\
    MAC&  767.0&  49.7&   58.9&   1.8 \\
    MAC&  774.0&  39.1&   59.2&   2.3 \\
    MAC&  780.0&  64.2&   57.0&   2.5 \\
\end{longtable}
\onehalfspacing

\end{document}

相关内容