我的表格排版很奇怪

我的表格排版很奇怪

我有一张表,但奇怪的事情发生了,这是为什么?错误出现在第二页:

\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}

相关内容