TransWikia.com

Error: Package array Error: Illegal pream-toke ([): `c` used

TeX - LaTeX Asked on October 1, 2020

Why I have this error?

enter image description here

My MWE:

documentclass[12pt,oneside]{book}

usepackage[showframe]{geometry}
usepackage{amsmath}
usepackage{ragged2e}
usepackage{booktabs, makecell, multirow, tabularx,
            threeparttable, tabulary}
renewcommandtheadfont{smallbfseries} % for bold in table using small
renewcommandtheadgape{}
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.80textwidth}{
  @{}
  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}

One Answer

The c type column does not accept an optional argument, hence the error message you get. In order to make your code compilable, replace c with S. The latter is a column type defined by the siunitx package, which, among others accepts the table-format option that you used. In order to get the correct alignment of the numbers, as well as the right column widths, you should also correct the values of table-format according to the contents of the corresponding table columns. In the following example, I have also added @{extracolsep{fill}} in order to make sure the table is as wide as the specified width, while the columns are spread evenly:

enter image description here

documentclass[12pt,oneside]{book}

usepackage[showframe]{geometry}
usepackage{amsmath}
usepackage{ragged2e}
usepackage{booktabs, makecell, multirow, tabularx,
            threeparttable, tabulary}
renewcommandtheadfont{smallbfseries} % for bold in table using small
renewcommandtheadgape{}
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.80textwidth}{
  @{}
  @{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}

Correct answer by leandriis on October 1, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP