插入数学公式时水平盒子溢出

插入数学公式时水平盒子溢出

我尝试制作一个简单的表格来显示我的置信区间和 p 值(目前只插入默认值)。但是,当我插入数学时,我收到 hbox 过满的错误。有人能帮我解决这个问题吗?

\begin{table}[!htp]
\centering

\sisetup{detect-all}
\NewDocumentCommand{\B}{}{\fontseries{b}\selectfont}

\begin{tabular}{
  @{}
  S[table-format=1.2]
  S[table-format=-1.2]
  S[table-format=1.2]
  S[table-format=1.2]
  S[table-format=1.2]
  S[table-format=1.2]
  @{}
}
\toprule
\multicolumn{2}{c}{\textbf{Baseline vs. ANN}} & \multicolumn{2}{c}{\textbf{Baseline vs. Logistic Regression}} & \multicolumn{2}{c}{\textbf{Logistic Regression vs. ANN}} \\
\cmidrule(lr){1-2} \cmidrule(lr){3-4} \cmidrule(l){5-6}
{p-value} & {95 \% conf. int.} & {p-value} & {95 \% conf. int.} & {p-value} & {95 \% conf. int.} \\
\midrule
{$1.0 \cdot 10^{-17}$} & {$[0.31, 0.44]$} & {$1.0 \cdot 10^{-17}$} & {$[0.31, 0.44]$} & {$1.0 \cdot 10^{-17}$} & {$[0.31, 0.44]$} \\
{$1.0 \cdot 10^{-17}$} & {$[0.31, 0.44]$} & {$1.0 \cdot 10^{-17}$} & {$[0.31, 0.44]$} & {$1.0 \cdot 10^{-17}$} & {$[0.31, 0.44]$} \\
{$1.0 \cdot 10^{-17}$} & {$[0.31, 0.44]$} & {$1.0 \cdot 10^{-17}$} & {$[0.31, 0.44]$} & {$1.0 \cdot 10^{-17}$} & {$[0.31, 0.44]$} \\
\bottomrule
\end{tabular}

\caption{Models and metrics (triples of data)}

\end{table}

答案1

超额行是不是由数学材料引起。相反,它们是由标题单元格引起的,标题单元格包含的材料太多了。以下屏幕截图对比了 OP 表格的外观以及适合默认宽度文本块的可能替代方案。

在此处输入图片描述

\documentclass{article}
\usepackage{booktabs}
\begin{document}

\begin{table}[!htp]
\centering

%% first, the OP's code
\begin{tabular}{@{} cccccc @{}}
\toprule
\multicolumn{2}{c}{\textbf{Baseline vs. ANN}} & \multicolumn{2}{c}{\textbf{Baseline vs. Logistic Regression}} & \multicolumn{2}{c}{\textbf{Logistic Regression vs. ANN}} \\
\cmidrule(lr){1-2} \cmidrule(lr){3-4} \cmidrule(l){5-6}
{p-value} & {95 \% conf. int.} & {p-value} & {95 \% conf. int.} & {p-value} & {95 \% conf. int.} \\
\midrule
$1.0 \cdot 10^{-17}$ & $[0.31, 0.44]$ & $1.0 \cdot 10^{-17}$ & $[0.31, 0.44]$ & $1.0 \cdot 10^{-17}$ & $[0.31, 0.44]$ \\
\bottomrule
\end{tabular}

%% now, a possible alternative
\bigskip\bigskip
\begin{tabular}{@{} cccccc @{}}
\toprule
\multicolumn{6}{c}{Pairwise Regression Comparisons}\\
\midrule
\multicolumn{2}{@{}c}{Baseline vs.\ ANN} & 
\multicolumn{2}{c}{Baseline vs.\ Logistic} & 
\multicolumn{2}{c@{}}{Logistic vs.\ ANN} \\
\cmidrule(r){1-2} \cmidrule(lr){3-4} \cmidrule(l){5-6}
$p$-value & 95\% CI & 
$p$-value & 95\% CI & 
$p$-value & 95\% CI \\
\midrule
$1.0 \cdot 10^{-17}$ & $[0.31, 0.44]$ & $1.0 \cdot 10^{-17}$ & $[0.31, 0.44]$ & $1.0 \cdot 10^{-17}$ & $[0.31, 0.44]$ \\
\bottomrule
\end{tabular}

\end{table}
\end{document}

相关内容