[Tex/LaTex] sidewaystable from rotating package cuts off table, even after changing margins

landscaperotatingtables

I'm using this code for my table:

\begin{sidewaystable}
{\small
\begin{tabular}{cccccccccccccccccc}
\toprule
\multicolumn{3}{l}{\texttt{Table 2}} \\
&&1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&16 \\
1&Data&1.0000 \\
2&Data&0.7685&1.0000 \\
3&Data&0.9929&0.6870&1.0000 \\
4&Data&-0.0216&0.0756&-0.0386&1.0000 \\
5&Data&0.1682&0.1553&0.1622&0.0823&1.0000 \\
6&Data&0.1066&0.1323&0.0965&0.7434&0.6545&1.0000 \\
7&Data&-0.1570&-0.0477&-0.1694&0.3213&0.2427&0.2640&1.0000 \\
8&Data&0.0039&0.1275&-0.0192&0.1459&0.2015&0.0787&0.8274&1.0000 \\
9&Data&-0.1124&-0.1614&-0.0977&0.0818&0.1552&0.2830&-0.5384&-0.6937&1.0000 \\
10&Data&0.1127&0.1826&0.0941&0.1503&0.1684&0.0683&0.8447&0.9113&-0.8103&1.0000 \\
11&Data&0.1331&0.2704&0.1009&0.1211&0.2973&0.0971&0.5977&0.6733&-0.6123&0.6838&1.0000 \\
12&Data&-0.2886&-0.1881&-0.2928&0.0119&-0.4912&-0.3414&-0.3289&-0.2965&0.0121&-0.3776&0.0198&1.0000 \\
13&Data&0.2114&0.1480&0.2126&-0.3154&-0.0074&-0.1077&-0.4319&-0.3966&0.3685&-0.4816&-0.4054&-0.0652&1.0000 \\
14&Data&0.5222&0.5811&0.4851&0.1099&-0.2678&-0.1150&-0.1544&0.0488&-0.1829&0.1368&0.1757&0.0065&-0.0244&1.0000 \\
15&Data&0.0968&0.1313&0.0855&0.1132&0.6050&0.3705&0.7226&0.5990&-0.3787&0.6492&0.6104&-0.4678&-0.2440&-0.2391&1.0000 \\
16&Data&-0.1973&-0.2324&-0.1809&-0.2069&0.2431&0.09601&-0.0418&-0.1090&0.2863&-0.1926&-0.2749&-0.2090&0.2203&-0.3292&0.0386&1.0000 \\
\bottomrule
\end{tabular}
}
\end{sidewaystable}

But the table is cut off from about column 11 onwards. I'm also using \usepackage{fullpage} because I need 1" inch margins. I've also tried using the pdflscape package, but as per this question that strategy is not successful either.

Best Answer

Resize the table to the line width and use right aligned columns if you have always the same number of decimals. With resizing it always fits into the margin:

\documentclass{article}
\usepackage{rotating,booktabs}
\def\MC#1{\multicolumn{1}{c}{#1}}
\begin{document}

\begin{sidewaystable}
\caption{Correlations}

\medskip
\resizebox{\linewidth}{!}{%
\tabcolsep=2pt
\begin{tabular}{@{}*{17}r@{}}\toprule
&\MC1&\MC2&\MC3&\MC4&\MC5&\MC6&\MC7&\MC8&\MC9&\MC{10}&\MC{11}&\MC{12}&\MC{13}&\MC{14}&\MC{15}&\MC{16} \\
1&1.0000 \\
2&0.7685&1.0000 \\
3&0.9929&0.6870&1.0000 \\
4&-0.0216&0.0756&-0.0386&1.0000 \\
5&0.1682&0.1553&0.1622&0.0823&1.0000 \\
6&0.1066&0.1323&0.0965&0.7434&0.6545&1.0000 \\
7&-0.1570&-0.0477&-0.1694&0.3213&0.2427&0.2640&1.0000 \\
8&0.0039&0.1275&-0.0192&0.1459&0.2015&0.0787&0.8274&1.0000 \\
9&-0.1124&-0.1614&-0.0977&0.0818&0.1552&0.2830&-0.5384&-0.6937&1.0000 \\
10&0.1127&0.1826&0.0941&0.1503&0.1684&0.0683&0.8447&0.9113&-0.8103&1.0000 \\
11&0.1331&0.2704&0.1009&0.1211&0.2973&0.0971&0.5977&0.6733&-0.6123&0.6838&1.0000 \\
12&-0.2886&-0.1881&-0.2928&0.0119&-0.4912&-0.3414&-0.3289&-0.2965&0.0121&-0.3776&0.0198&1.0000 \\
13&0.2114&0.1480&0.2126&-0.3154&-0.0074&-0.1077&-0.4319&-0.3966&0.3685&-0.4816&-0.4054&-0.0652&1.0000 \\
14&0.5222&0.5811&0.4851&0.1099&-0.2678&-0.1150&-0.1544&0.0488&-0.1829&0.1368&0.1757&0.0065&-0.0244&1.0000 \\
15&0.0968&0.1313&0.0855&0.1132&0.6050&0.3705&0.7226&0.5990&-0.3787&0.6492&0.6104&-0.4678&-0.2440&-0.2391&1.0000 \\
16&-0.1973&-0.2324&-0.1809&-0.2069&0.2431&0.0960&-0.0418&-0.1090&0.2863&-0.1926&-0.2749&-0.2090&0.2203&-0.3292&0.0386&1.0000 \\
\bottomrule
\end{tabular}}
\end{sidewaystable}

\end{document}

enter image description here

If you need more space to the top of the page you can say

\resizebox{\dimexpr \linewidth+2cm\relax}{!}{%
...