5

I have a table and want to rotate it with the caption by 90 degrees. The table is large and wouldn't even fit when rotated. Hence, I resize it first and rotate it by 90 degrees afterwards (since I don't want to resize the caption as well). To be precise, I resize it to textheight, put it into a minipage and rotate it using sideways. The problem is that the minipage is of width .95\textheight (which is obviously too large in portrait mode) which will create a blank page (i.e. the appendix is not starting on a RHS page). This hack was the closest I could get to the desired result.

I tried different solutions but all of them had a downside (e.g., varwidth inside sideways threw errors for multiline captions of the table).

Here's a full working example with a small table causing the same problem.

\documentclass[twoside,a5paper]{scrbook}

\usepackage{rotating}
\usepackage{setspace}

\begin{document}

\chapter{My chapter}

\begin{sideways}
    \begin{minipage}{.95\textheight}
        \resizebox{.95\textheight}{!}{%
            \setstretch{1.5}
            \begin{tabular}{llll}
            1 & 2 & 3 & 4 \\
            a & b & c & d \\
            \end{tabular}
        }
        \renewcommand\thetable{A.1}
        \captionof{table}{A veeeeeeeeeeeeeeeery loooooooooooooooooooong caption that does not fit into one line.}
        \label{tab:my_label}
    \end{minipage}
\end{sideways}

\end{document}

5
  • 1
    Temporary Landscape, in general: tex.stackexchange.com/questions/337/…. Table in particular: tex.stackexchange.com/questions/306855/…. It would be useful if you provided a complete working example to demonstrate your issue, rather than just a code snippet. Welcome to the site. Jan 9, 2019 at 11:47
  • Thanks for the fast response! I think my wording was a bit misleading. I want to rotate it and put it onto a page in portrait mode. I updated my question to clarify it.
    – user179157
    Jan 9, 2019 at 11:53
  • So that I understand, you want the data of the table rotated, but the caption in portrait mode? Jan 9, 2019 at 12:20
  • Everything shall be rotated. The complete example I provided works just fine except an empty page inserted before the table. Thanks for patiently asking, I hope the full example makes it clearer now. :)
    – user179157
    Jan 9, 2019 at 12:57
  • Oh, that's easy. The .95\textheight plus the height of the chapter heading exceeds the allowed \textheight. Whenever that happens, LaTeX inserts a blank page. Reduce .95 to .8 and the blank page goes away. Jan 9, 2019 at 13:16

1 Answer 1

5

The OP comments:

The complete example I provided works just fine except an empty page inserted before the table.

Now to the answer:

The combination of .95\textheight plus the height of the chapter heading exceeds the value of \textheight, thus a blank page is introduced (its standard LaTeX behavior to do this). The solution is to reduce .95 to, for example, .8. I also add some centering.

\documentclass[twoside,a5paper]{scrbook}

\usepackage{rotating}
\usepackage{setspace}

\begin{document}

\chapter{My chapter}

{\centering\begin{sideways}
    \begin{minipage}{.8\textheight}
        \resizebox{.8\textheight}{!}{%
            \setstretch{1.5}
            \begin{tabular}{llll}
            1 & 2 & 3 & 4 \\
            a & b & c & d \\
            \end{tabular}
        }
        \renewcommand\thetable{A.1}
        \captionof{table}{A veeeeeeeeeeeeeeeery loooooooooooooooooooong caption that does not fit into one line.}
        \label{tab:my_label}
    \end{minipage}
\end{sideways}\par}

\end{document}

enter image description here

Of course, other options could be pursued, such as \smashing the table height to allow it to exceed the margin.

In it's present configuration, of course, the table does not float, but the use of \clearpage would allow one to place it on its own separate page, using the .95\textheight value. For example,

\documentclass[twoside,a5paper]{scrbook}

\usepackage{rotating}
\usepackage{setspace}
\usepackage{lipsum}
\begin{document}

\chapter{My chapter}
\lipsum[1-2]
\clearpage
\begin{sideways}
    \begin{minipage}{.95\textheight}
        \resizebox{.95\textheight}{!}{%
            \setstretch{1.5}
            \begin{tabular}{llll}
            1 & 2 & 3 & 4 \\
            a & b & c & d \\
            \end{tabular}
        }
        \renewcommand\thetable{A.1}
        \captionof{table}{A veeeeeeeeeeeeeeeery loooooooooooooooooooong caption that does not fit into one line.}
        \label{tab:my_label}
    \end{minipage}
\end{sideways}
\clearpage\lipsum[3]
\end{document}

enter image description here

Finally, you could just make it float:

\documentclass[twoside,a5paper]{scrbook}

\usepackage{rotating}
\usepackage{setspace}
\usepackage{lipsum}
\begin{document}

\chapter{My chapter}
\lipsum[1-2]
\begin{table}[p]
\begin{sideways}
    \begin{minipage}{.95\textheight}
        \resizebox{.95\textheight}{!}{%
            \setstretch{1.5}
            \begin{tabular}{llll}
            1 & 2 & 3 & 4 \\
            a & b & c & d \\
            \end{tabular}
        }
        \renewcommand\thetable{A.1}
        \captionof{table}{A veeeeeeeeeeeeeeeery loooooooooooooooooooong caption that does not fit into one line.}
        \label{tab:my_label}
    \end{minipage}
\end{sideways}
\end{table}
\lipsum[3]
\end{document}

enter image description here

1
  • 1
    Thanks for you detailed explanations. I see that my table is too large to be printed on the same page with the chapter headline and that forcing the headline to be printed at the very top of the page will create a new page before.
    – user179157
    Jan 10, 2019 at 17:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .