为什么我会收到欠满和过满的错误?

为什么我会收到欠满和过满的错误?

我正在尝试编译以下代码:

\documentclass{article}
\usepackage{graphicx,algpseudocode,algorithm,multirow,hyperref,subfig,cancel,natbib,epstopdf,xspace}

\begin{document}

\clubpenalty=10000
\widowpenalty = 10000

\begin{table}
%\newcommand{\tabcolwidth}[1]{\parbox[c]{3cm}{\centering #1}}
\renewcommand\multirowsetup{\centering}
\caption{caption}

\subfloat
{
\resizebox{1.0\linewidth}{!}
{
\begin{tabular}{lrrrr}
\hline
\multirow{2}{*}{A} & \multicolumn{4}{c}{B} \\
  & $20 \%$ & $40 \%$ & $60 \%$ & $80 \%$ \\
\hline
Alg1 & $48.21$ & $48.64$ & $51.13$ & $52.46$ \\
Alg2 & $42.72$ & $46.31$ & $48.56$  & $51.64$ \\
\hline
\end{tabular}
}
}\\

\end{table}

\end{document}

使用 pdflatex。

我在编译过程中收到以下错误:

Overfull \hbox (6.71255pt too wide) in paragraph at lines 28--29
[][] 

Underfull \hbox (badness 10000) in paragraph at lines 28--29

我无法找出这里的原因!

答案1

overfull \hbox是因为行尾有空格。您应该注释掉这些行尾。

underfull \hbox是因为\\绝不应该用那个来伪造段落:

\documentclass{article}
\usepackage{graphicx,multirow,subfig,hyperref}% Load only used packages

% settings moved to preamble
\clubpenalty=10000 
\widowpenalty = 10000

\begin{document}

\begin{table}
%\newcommand{\tabcolwidth}[1]{\parbox[c]{3cm}{\centering #1}}
\renewcommand\multirowsetup{\centering}
\caption{caption}

\subfloat{%
  \resizebox{1.0\linewidth}{!}{%
    \begin{tabular}{lrrrr}
      \hline
      \multirow{2}{*}{A} & \multicolumn{4}{c}{B} \\
                         & $20 \%$ & $40 \%$ & $60 \%$ & $80 \%$ \\
      \hline
      Alg1 & $48.21$ & $48.64$ & $51.13$ & $52.46$ \\
      Alg2 & $42.72$ & $46.31$ & $48.56$  & $51.64$ \\
      \hline
    \end{tabular}%
  }%
}

\end{table}

相关内容