Wie erzwinge ich die Position einer Tabelle?

Wie erzwinge ich die Position einer Tabelle?

Wie erzwingt man die Position einer Tabelle mithilfe sidewaystableeines rotatingPakets?

Mein Beispiel:

\documentclass[12pt]{article}
\usepackage{float}
\usepackage{multirow}
\usepackage{rotating}

\begin{document}

\textbf{The house is black. The house is black. The house is black. The house is black. The house is black. The house is black. The house is black. The house is black. The house is black. The house is black. The house is black. The house is black. The house is black. The house is black. The house is black. The house is black. The house is black. The house is black. The house is black. The house is black. The house is black. The house is black. The house is black. The house is black.}

%I need table here. 
\begin{sidewaystable}%I tried to use [H] and variations
    \centering
    \caption{Comparation between models with one regressor}
    \label{tab:eqm_regressor}
    \scalebox{.8}{
        \begin{tabular}{ccccccccc}
            \hline
            \multicolumn{3}{c}{Scenario $C_1$} & \multicolumn{2}{c}{Scenario $C_2$} & \multicolumn{2}{c}{Scenario $C_3$} & \multicolumn{2}{c}{Scenario $C_4$} \\
            \hline
            \multicolumn{2}{c}{PLR model} & CRM & PLR model & CRM & PLR model & CRM & PLR model & CRM\\ \hline
            $N$                  & $\overline{MSE} \pm dp$ & $\overline{MSE} \pm sd$  & $\overline{MSE} \pm dp$ & $\overline{MSE} \pm dp$ & $\overline{MSE} \pm dp$ & $\overline{MSE} \pm dp$ & $\overline{MSE} \pm dp$ & $\overline{MSE} \pm dp$  \\ 
            \hline
            \multirow{1}{*}{3}   & $20.21 \pm 2.19$   & $100.35 \pm 3.73$    & $4.90 \pm 0.54$   & $81.75 \pm 2.20$ & $32.64 \pm 3.02$   & $233.71 \pm 12.50$ & $8.14 \pm 3.02$   & $231.98 \pm 12.50$ \\
            \multirow{1}{*}{4}   & $20.11 \pm 2.21$   & $105.26 \pm 3.86$   & $4.91 \pm 0.53$   & $85.93 \pm 2.43$ & $32.71 \pm 3.02$   & $247.62 \pm 12,82$ & $8.11 \pm 0.75$   & $245,78 \pm 11,88$\\
            \multirow{1}{*}{6}   & $20.07 \pm 2.25$   & $105.00 \pm 3.82$   & $4.87 \pm 0.56$   & $85.93 \pm 2.40$ & $32.71 \pm 3.05$   & $247.51 \pm 12.72$ & $8.15 \pm 0.77$   & $246.01 \pm 11.56$\\
            \multirow{1}{*}{100} & $20.07 \pm 2.23$   & $104.88 \pm 3.77$   & $4.91 \pm 0.54$   & $86,03 \pm 2.30$ & $32,62 \pm 2,95$   & $247.96 \pm 12.92$ & $8.18 \pm 0.73$   & $245.20 \pm 12.07$\\ \hline
    \end{tabular}}%
\end{sidewaystable}

The quick brown fox jumped over the lazy dog.
The quick brown fox jumped over the lazy dog.
The quick brown fox jumped over the lazy dog.
The quick brown fox jumped over the lazy dog.
The quick brown fox jumped over the lazy dog.
The quick brown fox jumped over the lazy dog.
The quick brown fox jumped over the lazy dog.
The quick brown fox jumped over the lazy dog.
The quick brown fox jumped over the lazy dog.
The quick brown fox jumped over the lazy dog.
\end{document}

Antwort1

Torbjorn hat bereits eine Antwort bereitgestellt, um zu zeigen, wie \clearpageSie mit einer Anweisung Ihre Layoutziele erreichen.

Ich möchte vorschlagen, dass Sie, anstatt die Breite des (gedrehten) Textblocks mit den „Hämmern“ \scaleboxoder \resizebox„Hämmern“ einzustellen, die Abstände lieber von Hand anpassen. Auf diese Weise erhalten Sie eine viel besser lesbare Tabelle. Der Screenshot zeigt die vorgeschlagene Lösung über der Lösung Ihres Codes.

Bildbeschreibung hier eingeben

\documentclass[12pt]{article}
\usepackage{booktabs,multirow,graphicx}
\usepackage{rotating}
\usepackage[skip=0.333\baselineskip]{caption}
\usepackage{array}
\newcolumntype{C}{>{$}c<{$}}
\begin{document}

\begin{sidewaystable}
\small
\setlength\tabcolsep{0pt} % make LaTeX figure out column spacing
\caption{Proposed new look}
\label{tab:eqm_regressor}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} l*{8}{C} }
\toprule
$N$ & \multicolumn{2}{c}{Scenario $C_1$} 
& \multicolumn{2}{c}{Scenario $C_2$} 
& \multicolumn{2}{c}{Scenario $C_3$} 
& \multicolumn{2}{c}{Scenario $C_4$} \\
\cmidrule{2-3} \cmidrule{4-5} \cmidrule{6-7} \cmidrule{8-9}
& \mbox{PLR model} & \mbox{CRM} & \mbox{PLR model} & \mbox{CRM} 
& \mbox{PLR model} & \mbox{CRM} & \mbox{PLR model} & CRM\\ 
\addlinespace
& \overline{MSE} {\pm} dp & \overline{MSE} {\pm} sd 
& \overline{MSE} {\pm} dp & \overline{MSE} {\pm} dp 
& \overline{MSE} {\pm} dp & \overline{MSE} {\pm} dp 
& \overline{MSE} {\pm} dp & \overline{MSE} {\pm} dp \\ 
\midrule
3  & 20.21 {\pm} 2.19 & 100.35 {\pm} 3.73 
   &  4.90 {\pm} 0.54 &  81.75 {\pm} 2.20 
   & 32.64 {\pm} 3.02 & 233.71 {\pm} 12.50 
   &  8.14 {\pm} 3.02 & 231.98 {\pm} 12.50 \\
4  & 20.11 {\pm} 2.21 & 105.26 {\pm} 3.86 
   &  4.91 {\pm} 0.53 &  85.93 {\pm} 2.43 
   & 32.71 {\pm} 3.02 & 247.62 {\pm} 12.82 
   &  8.11 {\pm} 0.75 & 245.78 {\pm} 11.88\\
6  & 20.07 {\pm} 2.25 & 105.00 {\pm} 3.82 
   &  4.87 {\pm} 0.56 &  85.93 {\pm} 2.40 
   & 32.71 {\pm} 3.05 & 247.51 {\pm} 12.72 
   &  8.15 {\pm} 0.77 & 246.01 {\pm} 11.56\\
100& 20.07 {\pm} 2.23 & 104.88 {\pm} 3.77 
   &  4.91 {\pm} 0.54 &  86.03 {\pm} 2.30 
   & 32.62 {\pm} 2.95 & 247.96 {\pm} 12.92 
   &  8.18 {\pm} 0.73 & 245.20 {\pm} 12.07\\ 
\bottomrule
\end{tabular*}

\bigskip
\caption{Original Look}
\setlength\tabcolsep{6pt} % restore default value
\centering
\scalebox{.8}{
        \begin{tabular}{ccccccccc}
            \hline
            \multicolumn{3}{c}{Scenario $C_1$} & \multicolumn{2}{c}{Scenario $C_2$} & \multicolumn{2}{c}{Scenario $C_3$} & \multicolumn{2}{c}{Scenario $C_4$} \\
            \hline
            \multicolumn{2}{c}{PLR model} & CRM & PLR model & CRM & PLR model & CRM & PLR model & CRM\\ \hline
            $N$                  & $\overline{MSE} \pm dp$ & $\overline{MSE} \pm sd$  & $\overline{MSE} \pm dp$ & $\overline{MSE} \pm dp$ & $\overline{MSE} \pm dp$ & $\overline{MSE} \pm dp$ & $\overline{MSE} \pm dp$ & $\overline{MSE} \pm dp$  \\ 
            \hline
            \multirow{1}{*}{3}   & $20.21 \pm 2.19$   & $100.35 \pm 3.73$    & $4.90 \pm 0.54$   & $81.75 \pm 2.20$ & $32.64 \pm 3.02$   & $233.71 \pm 12.50$ & $8.14 \pm 3.02$   & $231.98 \pm 12.50$ \\
            \multirow{1}{*}{4}   & $20.11 \pm 2.21$   & $105.26 \pm 3.86$   & $4.91 \pm 0.53$   & $85.93 \pm 2.43$ & $32.71 \pm 3.02$   & $247.62 \pm 12,82$ & $8.11 \pm 0.75$   & $245,78 \pm 11,88$\\
            \multirow{1}{*}{6}   & $20.07 \pm 2.25$   & $105.00 \pm 3.82$   & $4.87 \pm 0.56$   & $85.93 \pm 2.40$ & $32.71 \pm 3.05$   & $247.51 \pm 12.72$ & $8.15 \pm 0.77$   & $246.01 \pm 11.56$\\
            \multirow{1}{*}{100} & $20.07 \pm 2.23$   & $104.88 \pm 3.77$   & $4.91 \pm 0.54$   & $86,03 \pm 2.30$ & $32,62 \pm 2,95$   & $247.96 \pm 12.92$ & $8.18 \pm 0.73$   & $245.20 \pm 12.07$\\ \hline
    \end{tabular}}%
\end{sidewaystable}

\end{document}

Antwort2

Sie können \clearpagedirekt nach dem ein hinzufügen sidewaystable. Dies führt natürlich zu einem sehr schlechten Seitenumbruch vor der Tabelle.

Unten habe ich die Tabelle auch noch ein wenig bearbeitet, dabei die Regeln aus dem booktabsPaket verwendet und am Anfang der ersten beiden Überschriftenzeilen eine leere Zelle hinzugefügt, damit man die erste Scenariound PLR modeldie gesamte NSpalte nicht zusätzlich hat.

\documentclass[12pt]{article}
\usepackage{rotating}
\usepackage{booktabs} % for \toprule, \midrule, \cmidrule, \bottomrule   

\begin{document}

\textbf{The house is black. The house is black. The house is black. The house is black. The house is black. The house is black. The house is black. The house is black. The house is black. The house is black. The house is black. The house is black. The house is black. The house is black. The house is black. The house is black. The house is black. The house is black. The house is black. The house is black. The house is black. The house is black. The house is black. The house is black.}

\begin{sidewaystable}
    \centering
    \caption{Comparation between models with one regressor}
    \label{tab:eqm_regressor}
    \resizebox{\textwidth}{!}{%
        \begin{tabular}{*{9}{c}}
            \toprule
            & \multicolumn{2}{c}{Scenario $C_1$} & \multicolumn{2}{c}{Scenario $C_2$} & \multicolumn{2}{c}{Scenario $C_3$} & \multicolumn{2}{c}{Scenario $C_4$} \\
            \cmidrule(lr){2-3}\cmidrule(lr){4-5}\cmidrule(lr){6-7}\cmidrule(lr){8-9}
            & PLR model & CRM & PLR model & CRM & PLR model & CRM & PLR model & CRM\\ \midrule
            $N$                  & $\overline{MSE} \pm dp$ & $\overline{MSE} \pm sd$  & $\overline{MSE} \pm dp$ & $\overline{MSE} \pm dp$ & $\overline{MSE} \pm dp$ & $\overline{MSE} \pm dp$ & $\overline{MSE} \pm dp$ & $\overline{MSE} \pm dp$  \\ 
            \midrule
            3   & $20.21 \pm 2.19$   & $100.35 \pm 3.73$    & $4.90 \pm 0.54$   & $81.75 \pm 2.20$ & $32.64 \pm 3.02$   & $233.71 \pm 12.50$ & $8.14 \pm 3.02$   & $231.98 \pm 12.50$ \\
            4   & $20.11 \pm 2.21$   & $105.26 \pm 3.86$   & $4.91 \pm 0.53$   & $85.93 \pm 2.43$ & $32.71 \pm 3.02$   & $247.62 \pm 12,82$ & $8.11 \pm 0.75$   & $245,78 \pm 11,88$\\
            6   & $20.07 \pm 2.25$   & $105.00 \pm 3.82$   & $4.87 \pm 0.56$   & $85.93 \pm 2.40$ & $32.71 \pm 3.05$   & $247.51 \pm 12.72$ & $8.15 \pm 0.77$   & $246.01 \pm 11.56$\\
            100 & $20.07 \pm 2.23$   & $104.88 \pm 3.77$   & $4.91 \pm 0.54$   & $86,03 \pm 2.30$ & $32,62 \pm 2,95$   & $247.96 \pm 12.92$ & $8.18 \pm 0.73$   & $245.20 \pm 12.07$\\ \bottomrule
    \end{tabular}}%
\end{sidewaystable}
\clearpage% added

The quick brown fox jumped over the lazy dog.
The quick brown fox jumped over the lazy dog.
The quick brown fox jumped over the lazy dog.
The quick brown fox jumped over the lazy dog.
The quick brown fox jumped over the lazy dog.
The quick brown fox jumped over the lazy dog.
The quick brown fox jumped over the lazy dog.
The quick brown fox jumped over the lazy dog.
The quick brown fox jumped over the lazy dog.
The quick brown fox jumped over the lazy dog.
\end{document}

verwandte Informationen