%EF%BC%9A%E4%BD%BF%E7%94%A8%E4%BA%86%20%60c%60.png)
為什麼我有這個錯誤?
我的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
列不接受可選參數,因此您會收到錯誤訊息。為了使您的程式碼可編譯,請替換c
為S
.後者是由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}