# sidewaystable from rotating package cuts off table, even after changing margins

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.

-
While code snippets are useful in explanations, it is always best to compose a fully compilable MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. –  Jake Dec 6 '11 at 1:54
@pythinscript Try with pdflscape and scriptsize for font. Also \setlength{\tabcolsep}{3pt}. Worked with article class and does not look that bad. Sorry too busy to post a full answer. –  Yiannis Lazarides Dec 11 '11 at 8:24

resize the table to the line width and use right aligned columns if you have always the same numer 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}


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

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

-
Great suggestions that work perfectly; the table looks great! –  Ricardo Altamirano Dec 16 '11 at 0:45
I think alternatively you can use: \resizebox{\columnwidth}{!} –  mostar Dec 24 '12 at 21:56

I think the main adjustment you should make is to reduce the value of \tabcolsep, a macro whose value equals (half) the width of the inter-column whitespace. You can also get rid of the second column, which contains "Data" over and over, right? Finally, I'd use the dcolumn package to align all the positive and negative numbers on the decimal points.

Another possibility: Showing the main diagonal of a correlation matrix is unnecessary because it contains 1s by construction. Dropping all those 1.0000 would let you save an entire column (as well as a row) in the table.

Here's the resulting, modified MWE (which doesn't implement the idea of the not showing the main diagonal):

\documentclass{article}
\usepackage{fullpage,rotating,booktabs,dcolumn}
\newcolumntype{.}{D{.}{.}{4}} %% 4 digits after decimal point
\setlength\tabcolsep{3pt}
\begin{document}
\begin{sidewaystable}
\caption{Correlations}
\medskip
\small
\begin{tabular}{@{}r*{16}{.}@{}}
\toprule
&1&2&3&4&5&6&7&8&9&10&11&12&13&14&15&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}


Addendum: another possibility for saving space is to print fewer digits of the correlation numbers. Ask yourself: is it absolutely necessary for you to show 4 digits after the decimal? Or are you doing this at the moment because that was the default setting of the software that generated the correlation matrix? Try redoing the table with only 3 digits after the decimal; you may find that its readability soars as a result. Of course, you'll also need to adjust the definition of the . column type, to \newcolumntype{.}{D{.}{.}{3}}.

-
I can't remove the second column, because in my paper the contents are more than just "Data." I can't post the column titles because the research is still in its infancy. I'll try this when I'm back at my flat and post the results. –  Ricardo Altamirano Dec 6 '11 at 3:16
Since I need to leave the "Data" column in the table, your suggestion still doesn't allow it to fit on the page. –  Ricardo Altamirano Dec 11 '11 at 0:06