[Tex/LaTex] LaTeX places table outside of page margin

floatspositioningtables

I'm using the KOMA class scrbook with the font Tex Gyre Pagella (11pt) and onehalf-spacing. I am placing a table float with the position options "htb", but both pdflatex and lualatex place the table outside the textbody. The table is positioned at the bottom at the page but goes way into the bottom margin.

I am using TeXLive 2014 on archlinux x64. lualatex --version prints Version beta-0.79.1 (TeX Live 2014/Arch Linux) (rev 4971).

MWE (include Tex Gyre Pagella and one half spacing). I used showframe to visualize the margins:

\documentclass[paper=a4,
                twoside=true,
                parskip=half,
                fontsize=11pt,
                BCOR=3mm]{scrbook}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
% both font and onehalfspacing are imperative for this example
\usepackage{tgpagella}
\usepackage{setspace}
\onehalfspacing{}
\usepackage{booktabs}

\usepackage{multirow}
\usepackage{blindtext}
\usepackage{showframe}

\begin{document}
Dies hier ist ein Blindtext zum Testen von Textausgaben. Dies hier ist ein Blindtext zum Testen von Textausgaben.
Dies hier ist ein Blindtext zum Testen von Textausgaben. Dies hier ist ein Blindtext zum Testen von Textausgaben.

Dies hier ist ein Blindtext zum Testen von Textausgaben. Dies hier ist ein Blindtext zum Testen von Textausgaben.
Dies hier ist ein Blindtext zum Testen von Textausgaben. Dies hier ist ein Blindtext zum Testen von Textausgaben.
Dies hier ist ein Blindtext zum Testen von Textausgaben. Dies hier ist ein Blindtext zum Testen von Textausgaben.
Dies hier ist ein Blindtext zum Testen von Textausgaben. Dies hier ist ein Blindtext zum Testen von Textausgaben.
Dies hier ist ein Blindtext zum Testen von Textausgaben. Dies hier ist ein Blindtext zum Testen von Textausgaben.
Dies hier ist ein Blindtext zum Testen von Textausgaben. Dies hier ist ein Blindtext zum Testen von Textausgaben.
Dies hier ist ein Blindtext zum Testen von Textausgaben. Dies hier ist ein Blindtext zum Testen von Textausgaben.
Dies hier ist ein Blindtext zum Testen von Textausgaben. Dies hier ist ein Blindtext zum Testen von Textausgaben.
Dies hier ist ein Blindtext zum Testen von Textausgaben. Dies hier ist ein Blindtext zum Testen von Textausgaben.


\begin{table}[htb]
\caption{Table caption}
\label{tab:label1}
\vspace{2mm}
{\small
\begin{quote} 
Dies hier ist ein Blindtext zum Testen von Textausgaben. Dies hier ist ein Blindtext zum Testen von Textausgaben.
Dies hier ist ein Blindtext zum Testen von Textausgaben. Dies hier ist ein Blindtext zum Testen von Textausgaben.
Dies hier ist ein Blindtext zum Testen von Textausgaben.
\end{quote}
}
\begin{center}
    \begin{tabular}{cccc}
        \toprule 
        \multirow{2}{*}{
            Parameter~$b$
        } & \multicolumn{3}{c}{Parameter $h$} \\
        \cmidrule{2-4}
         & 4 & 2 & 1\\ \midrule     
        360 & 0.0123 & 0.0123 & 0.0123\\[-2mm]
         ~ & {\scriptsize $\times 20$} & {\scriptsize $\times 20$}& {\scriptsize $\times 20$}\\[1mm]
        360 & 0.0123 & 0.0123 & 0.0123\\[-2mm]
         ~ & {\scriptsize $\times 20$} & {\scriptsize $\times 20$}& {\scriptsize $\times 20$}\\[1mm]
        360 & 0.0123 & 0.0123 & 0.0123\\[-2mm]
         ~ & {\scriptsize $\times 20$} & {\scriptsize $\times 20$}& {\scriptsize $\times 20$}\\[1mm]
        360 & 0.0123 & 0.0123 & 0.0123\\[-2mm]
         ~ & {\scriptsize $\times 20$} & {\scriptsize $\times 20$}& {\scriptsize $\times 20$}\\
        \bottomrule
    \end{tabular}
\end{center}
\end{table}

\subsection{next subsection}
\blindtext{}

\end{document}

Table gets positioned inside the page margin

Can anyone help me?

PS: Trying out different placement options like "bt" or "tb" helps in this MWE, but that doesn't change the fact that the behaviour using "htb" is not expected. I can't change every float.

PPS: Depending on text size, I also had latex place the float above the text:
Table gets positioned above text

Best Answer

Using \centering instead of \begin{center}...\end{center} fixed the problem (Miktex with Lualatex on Windows) [2].

When using \begin{center}...\end{center} additional vertical space is introduced inside the float environment. I suspect this might throw off LaTeXs computing of margins.

In general the usage of \begin{center}...\end{center} is discouraged in floating environments and you should use \centering instead[1].

Update:

As suggested by user egreg, the combination of the setspace package and the center environment in floats is especially dangerous. Despite positioning of the table using the center environment works when removing the setspace package, I would suggest sticking with \centering to avoid future headaches.


Example usage of \centering

\begin{table}[htb]
    \caption{Table caption}
    \label{tab:label1}
    \centering
    Descriptive text
    \begin{tabular}{cccc}
        ...
    \end{tabular}
\end{table}

[1] Section 3.1 of "An essential guide to LATEX 2ε usage - Obsolete commands and packages" (http://mirrors.ctan.org/info/l2tabu/english/l2tabuen.pdf)

[2]

positioning of fixed table

Related Question