為什麼我會出現未滿和過滿錯誤?

為什麼我會出現未滿和過滿錯誤?

我正在嘗試編譯以下程式碼:

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

相關內容