3

I'm working a wide complicated table and I thought the best way to make it easily readable is to use sideways table so that it is in landscape mode. Unfortunately, its font is too small (even with resize box). I actually generated the table from here. Here is my code:

\begin{sidewaystable}[htbp]
\centering
\resizebox{\textwidth}{!}{%
\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|c|c|}
\hline
\textbf{} & \multicolumn{3}{c|}{\textbf{Start State = $S_1$}} & \multicolumn{3}{c|}{\textbf{Start State = $S_2$}} & \multicolumn{3}{c|}{\textbf{Start State = $S_3$}} & \multicolumn{3}{c|}{\textbf{Start State = $S_4$}} \\ \hline
\textbf{Statistic} & \textbf{\begin{tabular}[c]{@{}c@{}}Common Human\\ Policy\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Learned Robot\\ Policy\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Random\\ Policy\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Common Human\\ Policy\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Learned Robot\\ Policy\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Random\\ Policy\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Common Human\\ Policy\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Learned Robot\\ Policy\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Random\\ Policy\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Common Human\\ Policy\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Learned Robot\\ Policy\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Random\\ Policy\end{tabular}} \\ \hline
\textbf{Minimum} &  &  &  &  &  &  &  &  &  &  &  &  \\ \hline
\textbf{Maximum} &  &  &  &  &  &  &  &  &  &  &  &  \\ \hline
\textbf{Mean} &  &  &  &  &  &  &  &  &  &  &  &  \\ \hline
\textbf{Mode} &  &  &  &  &  &  &  &  &  &  &  &  \\ \hline
\textbf{Median} &  &  &  &  &  &  &  &  &  &  &  &  \\ \hline
\textbf{Variance} &  &  &  &  &  &  &  &  &  &  &  &  \\ \hline
\textbf{Std} &  &  &  &  &  &  &  &  &  &  &  &  \\ \hline
\end{tabular}%
}
\caption{My caption}
\label{my-label}
\end{sidewaystable}

Here is link to how it looks like. Is there a way to make it fit the entire page?

Thanks.

  • 1
    Welcome! Please complete your code so that it can be compiled. But basically, I don't know what you mean by fitting the entire page. Do you want to change the margins for this page? – cfr Jul 9 '16 at 23:45
2

Edit: Something like this:

enter code here

It seams that page with sidewaystable had to have different page layout than rest of the document. This can be done with geometry package macros \newgeometry{top=3pt,bottom=3pt} and \restoregeometry as they are used in changed code below. With this the font size in table can be \large.

To the MWE below is also added lipsum macro from packagelipsum for demonstrating how changes of page layout work (and indicate the problem of placing sidewaystable in document). To see added text from \lipsum[...] you need to make your own test of the proposed MWE.

MWE:

\documentclass{article}
\usepackage{rotating}

\usepackage[a4paper,showframe]{geometry}
\usepackage{makecell,tabularx}
\renewcommand\tabularxcolumn[1]{b{#1}}

 \begin{document}
     \lipsum[1-3]

    \newgeometry{top=3pt,bottom=3pt}
\begin{sidewaystable}[htbp]
    \centering
    \large
    \setlength\tabcolsep{3pt}% default is 6pt
        \setcellgapes{5pt}
        \makegapedcells
\begin{tabularx}{\textheight}{@{}|c|*{12}{>{\centering\arraybackslash}X|}@{}}
    \hline
    &   \multicolumn{3}{c|}{\textbf{Start State = $S_1$}} 
        &   \multicolumn{3}{c|}{\textbf{Start State = $S_2$}} 
            &   \multicolumn{3}{c|}{\textbf{Start State = $S_3$}} 
                &   \multicolumn{3}{c|}{\textbf{Start State = $S_4$}}       \\ 
    \hline
\textbf{Statistic}  &   \textbf{Common Human Policy}    &   \textbf{Learned Robot Policy} 
    &   \textbf{Random Policy}  &   \textbf{Common Human Policy}    &   \textbf{Learned Robot Policy} 
        &   \textbf{Random Policy}  &   \textbf{Common Human Policy}    &   \textbf{Learned Robot Policy} 
            &   \textbf{Random Policy}  &   \textbf{Common Human Policy}    &   \textbf{Learned Robot Policy} 
                & \textbf{Random Policy}                \\ \hline
\textbf{Minimum}    &  &  &  &  &  &  &  &  &  &  &  &  \\ \hline
\textbf{Maximum}    &  &  &  &  &  &  &  &  &  &  &  &  \\ \hline
\textbf{Mean}       &  &  &  &  &  &  &  &  &  &  &  &  \\ \hline
\textbf{Mode}       &  &  &  &  &  &  &  &  &  &  &  &  \\ \hline
\textbf{Median}     &  &  &  &  &  &  &  &  &  &  &  &  \\ \hline
\textbf{Variance}   &  &  &  &  &  &  &  &  &  &  &  &  \\ \hline
\textbf{Std}        &  &  &  &  &  &  &  &  &  &  &  &  \\ \hline
\end{tabularx}%
\caption{My caption}
\label{my-label}
\end{sidewaystable}
    \restoregeometry
    \lipsum[4-12]
\end{document}

In the MEW, I have added three packages: makecell, which is used to make cell higher, and tabularx, which fits the table in available space. Since your table is very wide, I reduced the fontsize to \footnotesize and distributed some column heads over three lines. Also, I add the geometry package with option showframe to show page layout. In your final use of the above code, it should be omitted.

  • 1
    Thank you. That helped a lot. Just out of curiosity, isn't it possible to adjust the table to stretch to the full page with some scale factor? – shaun Jul 10 '16 at 1:13
  • 1
    see edit of my answer – Zarko Jul 10 '16 at 2:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.