错误:程序包数组错误:非法的 pream-toke ([): 使用了 `c`

错误:程序包数组错误:非法的 pream-toke ([): 使用了 `c`

为什么我会遇到这个错误?

在此处输入图片描述

我的 MWE:

\documentclass[12pt,oneside]{book}

\usepackage[showframe]{geometry}
\usepackage{amsmath}
\usepackage{ragged2e}
\usepackage{booktabs, makecell, multirow, tabularx,
            threeparttable, tabulary}
\renewcommand\theadfont{\small\bfseries} % for bold in table using \small
\renewcommand\theadgape{}
\usepackage[svgnames, table]{xcolor}
\usepackage{siunitx} %for table spacing to second row
\usepackage{graphicx}

\usepackage[font=small,
            labelfont={bf,sf}, textfont={sf}, 
            justification=centering]{caption}

\begin{document}


\begin{table}[h!]
\centering 
\begin{tabular*}{0.80\textwidth}{
  @{}
  l
  c[table-format=6]
  c[table-format=6]
  c[table-format=6]
  c[table-format=6]
  @{}  
}
\toprule
{\thead{Sample Setting \\ Configuration}} 
  & {\thead{Verification \\ 
  Status}}
  & {\thead{Precision \\ (\textit{P})}}
  & {\thead{Recall \\ (\textit{R}) }}
  & {\thead{\textit{F}-samples }} \\
\midrule

No. 4   &   66.07   &   0.6786  &   0.6552  &   0.6667  \\
No. 5   &   71.43   &   0.7097  &   0.7586  &   0.7333  \\


\bottomrule
\end{tabular*}
\end{table}



\end{document}

答案1

类型c列不接受可选参数,因此您会收到错误消息。为了使您的代码可编译,请用 替换cS后者是包定义的列类型siunitx,除其他外,它还接受table-format您使用的选项。为了获得正确的数字对齐以及正确的列宽,您还应该table-format根据相应表列的内容更正 的值。在下面的例子中,我还添加了@{\extracolsep{\fill}}以确保表格与指定宽度一样宽,而列均匀分布:

在此处输入图片描述

\documentclass[12pt,oneside]{book}

\usepackage[showframe]{geometry}
\usepackage{amsmath}
\usepackage{ragged2e}
\usepackage{booktabs, makecell, multirow, tabularx,
            threeparttable, tabulary}
\renewcommand\theadfont{\small\bfseries} % for bold in table using \small
\renewcommand\theadgape{}
\usepackage[svgnames, table]{xcolor}
\usepackage{siunitx} %for table spacing to second row
\usepackage{graphicx}

\usepackage[font=small,
            labelfont={bf,sf}, textfont={sf}, 
            justification=centering]{caption}

\begin{document}


\begin{table}[h!]
\centering 
\begin{tabular*}{0.80\textwidth}{
  @{}
  @{\extracolsep{\fill}}
  l
  S[table-format=2.2]
  S[table-format=1.4]
  S[table-format=1.4]
  S[table-format=1.4]
  @{}  
}
\toprule
{\thead{Sample Setting \\ Configuration}} 
  & {\thead{Verification \\ 
  Status}}
  & {\thead{Precision \\ (\textit{P})}}
  & {\thead{Recall \\ (\textit{R}) }}
  & {\thead{\textit{F}-samples }} \\
\midrule

No. 4   &   66.07   &   0.6786  &   0.6552  &   0.6667  \\
No. 5   &   71.43   &   0.7097  &   0.7586  &   0.7333  \\


\bottomrule
\end{tabular*}
\end{table}



\end{document}

相关内容