The rotating package
Turns a figure or table with its caption by 90° on a page of its own (sidewaysfigure, sidewaystable) and rotates text by any angle.
Loading the package
\usepackage{rotating}A table with many columns can be wider than the page is high. sidewaystable sets the table and its caption turned by 90°, so the long side of the page becomes the width. The float always takes a page of its own, and the page stays a portrait page in the PDF: header, footer and page number are where they always are.
For small rotations the package has sideways (90°), turn (any angle) and rotate (any angle, without reserving space). It loads graphicx.
Main commands
\begin{sidewaystable} ... \end{sidewaystable} | Table float turned by 90° on its own page. |
\begin{sidewaysfigure} ... \end{sidewaysfigure} | The same for a figure. |
\begin{sideways} ... \end{sideways} | Turns its content by 90°, for example a long column heading. |
\begin{turn}{45} ... \end{turn} | Turns its content by 45° and reserves the space of the turned box. |
\usepackage[figuresright]{rotating} | Turns all sideways floats in the same direction; figuresleft is the opposite one. |
Complete example
\documentclass{article}
\usepackage{rotating}
\begin{document}
The table follows on a page of its own.
\begin{sidewaystable}
\centering
\caption{A wide table, turned by 90 degrees}
\begin{tabular}{lrrrrrr}
\hline
Year & Jan & Feb & Mar & Apr & May & Jun \\ \hline
2025 & 12 & 15 & 11 & 18 & 21 & 19 \\
2026 & 14 & 13 & 16 & 20 & 22 & 25 \\ \hline
\end{tabular}
\end{sidewaystable}
\begin{tabular}{lcc}
& \begin{sideways}Experiment A\end{sideways}
& \begin{sideways}Experiment B\end{sideways} \\ \hline
Passed & yes & no
\end{tabular}
\end{document}Compiled with pdfLaTeX from TeX Live 2023.
Pitfalls
- In a
twosidedocument the direction of the rotation depends on whether the float lands on a left or a right page. The optionsfiguresrightandfiguresleftfix one direction. - The reader has to turn the head or the screen, because the PDF page is not rotated.
pdflscaperotates the page in the viewer. - Inside the environment,
\linewidthand\textwidthhave the value of the portrait\textheight.width=\linewidthon an image fills the long side of the page.
Related pages
- How-to Rotate a table in LaTeX
- How-to Rotate an image in LaTeX
- How-to Rotate a single page to landscape in LaTeX
- Package
pdflscape - Package
graphicx