2

I have tried to make a simple table for showing my confidence intervals and p-values (Default just inserted for now). However, when I insert math I get the error for overfull hbox. Can anyone help me how to deal with this?

\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}
2
  • 1
    Welcome to TeX.SE.
    – Mico
    Commented Mar 24 at 19:00
  • Off-topic: By encasing the contents of each and every data cell in curly braces, you're overriding the settings of the S column types. You might as well (a) write \begin{tabular}{cccccc} and (b) get rid of the encasing curly braces.
    – Mico
    Commented Mar 24 at 19:07

1 Answer 1

3

The overfull lines are not caused by the mathy material. Instead, they are caused by the header cells, which simply contain too much material. The following screenshot contrasts the looks of the OP's table and of a possible alternative which does fit within the default-width text block.

enter image description here

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .