我有一張桌子,但發生了奇怪的事情,這是為什麼?錯誤在第二頁:
\documentclass{article}
\usepackage{siunitx} % for 'S' column type
\usepackage{booktabs}%
\usepackage{array,makecell}
\usepackage{multirow}
\newcommand{\mc}{\multicolumn{1}{c}}
\begin{document}
\begin{tabular}{ *{5}{|c} | }
\cline{3-4}
\mc{} & & \multicolumn{2}{c|}{Condition Phase (worst case)} & \mc{} \\
\cline{3-4}
\mc{} & & \makecell{Condition \\ Positive/ \\ Shaded} &
\makecell{Condition \\ Negative/ \\ Unshaded} & \mc{\textbf{Actual}} \\
\hline
\multirow{5}{*}{\makecell{Testing \\ Phase \\ (best case)}} &
\makecell{Test \\ Positive/ \\ Shaded} &
\makecell{True positive \\ shaded \\ $T_p$ \\ \textit{(Correct)}} &
\makecell{False positive \\ shaded \\ $F_p$ \\ \textit{(Incorrect)}} &
\makecell{Precision/Positive \\ Predictive Value \\ (PPV) \\ $\frac{T_p}{T_p + F_p} \times 100\%$} \\
\cline{2-5}
&
\makecell{Test \\ Negative/ \\ Unshaded} &
\makecell{False negative \\ unshaded \\ $F_n$ \\ \textit{(Incorrect)}} &
\makecell{True negative \\ unshaded \\ $T_n$ \\ \textit{(Correct)}} &
\makecell{Negative \\ Predictive Value \\ (NPV) \\ $\frac{T_n}{T_n + F_n} \times 100\%$} \\
\hline
\mc{} & & \makecell{Sensitivity/Recall \\ Rate (RR) \\ $\frac{T_p}{T_p + F_n} \times 100\%$} &
\makecell{Specificity Rate \\ (SR) \\ $\frac{T_n}{T_n + F_p} \times 100\%$} & \mc{} \\
\cline{3-4}
\end{tabular}
\newpage
\begin{table}
\begin{tabular}{@{} lS[table-format=4.0] @{}}
\toprule
$\eta^2$ & {Interpretation} \\ % 'Counted' is placed in curly braces
\midrule
$\eta^2$ is $<$ .13 & Small effect \\
$\eta^2$ is between .13 to .26 & Medium effect \\
$\eta^2$ is $>$ .36 & Large effect \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
答案1
所討論的環境tabular
包含兩列,第一列類型為l
(用於左對齊文字),第二列類型為S[table-format=4.0]
,適用於最多 4 位數字的整數。但是,第二列其實並不包含數字輸入。因此,改變
\begin{tabular}{@{} lS[table-format=4.0] @{}}
到
\begin{tabular}{@{} ll @{}}
並且程式碼將編譯。
完整的 MWE(請注意,我對第一列的內容進行了一定程度的簡化和重新排列):
\documentclass{article}
\usepackage{booktabs,array}
\begin{document}
\begin{table}[ht!]
\begin{tabular}{@{} >{$}l<{$} l @{}}
\toprule
\eta^2 & Interpretation \\
\midrule
\eta^2<0.13 & Small effect \\
0.13<\eta^2<0.26 & Medium effect \\
\eta^2> 0.36 & Large effect \\
\bottomrule
\end{tabular}
\end{table}
\end{document}