[Tex/LaTex] How to avoid overfull \hbox warning when using tabularx with \textwidth

koma-scriptparskiptabularxwarnings

Question

How do I avoid the warning

Overfull \hbox (10.95003pt too wide) in paragraph at lines […]

produced by the following document?

\documentclass[parskip=half]{scrartcl}

\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{blindtext}

\begin{document}

\blindtext

%\begin{center}
\begin{tabularx}{\textwidth}{XX}
  \toprule
  Test  & Test
  \\\bottomrule
\end{tabularx}
%\end{center}

\blindtext

\end{document}

The output looks okay:

output

Explanation

From the KOMA script manual scrguide.pdf:

half
Absätze werden durch einen vertikalen Abstand von einer halben Zeile gekennzeichnet. Absatzenden durch einen Leerraum von mind. ein Geviert (1em) der normalen Schrift am Ende gekennzeichnet.

Using \textwidth contradicts this, hence the warning.

half-
Absätze werden durch einen vertikalen Abstand von einer halben Zeile gekennzeichnet. Absatzenden werden nicht gekennzeichnet.

This avoids the warning.

Using center environment

Wrapping the tabularx in \begin{center}...\end{center} seems to work. Why? And is this a good idea? How do I avoid the additional vertical spacing?

Answer:

As egreg explained,
in the center environment, \parfillskip is set to zero.

Other ideas

The usual suggestion of adding \noindent has no effect. There is no indentation when using parskip=half. (The problem is at the end of the line, see the answers.)

Writing {.97\textwidth} is of course not a solution.

Using {@{}XX@{}} does not get rid of the warning.

Best Answer

The parskip=half option sets a parfillskip with a nonzero natural width (precisely to one em). It does so in order to avoid that a paragraph ends flush with the right margin, but, of course, this disallows an object fills a line by itself.

The correct way of solving this is not using a nonzero parskip under any circumstance, except, perhaps, business letters. Of course this recommendation reflects my opinion, that, however, I share with several great typographers.

If you really want to use this abominable ;-) typesetting style, just locally set \parfillskip to zero:

\documentclass[draft,parskip=half]{scrartcl}

\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{blindtext}

\begin{document}

\blindtext

\begin{tabularx}{\textwidth}{XX}
  \toprule
  Test  & Test
  \\\bottomrule
\end{tabularx}{\parfillskip=0pt\par}

\blindtext

\end{document}