How to rotate a table and image in LaTeX?
In this tutorial, you will learn how to rotate a table and image or figure in LaTeX. There are multiple ways to rotate a figure in LaTeX, here I will show you all of them.
Rotate the table and image with adjustbox
To rotate a table or image you can use the \adjustbox
command or adjustbox
environment provided by the adjustbox
package. Take a look.
\adjustbox{angle=<value>}{
% table or image
}
or
\begin{adjustbox}{angle=<value>}
% table or image
\end{adjustbox}
\documentclass{article} \usepackage{float} % To fix floating objects \usepackage{graphicx} % For image \usepackage{adjustbox} \begin{document} Rotate a table with \verb|\adjustbox{angle=<x>}| command in \LaTeX :\\[4pt] \begin{table}[H] \centering \caption{Caption} \adjustbox{angle=60}{ \begin{tabular}{|c|c|c|} \hline A & B & C\\ \hline D & E & F\\ \hline \end{tabular} } \end{table} Rotate a table with \verb|adjustbox| environment in \LaTeX :\\[4pt] \begin{table}[H] \centering \caption{Caption} \begin{adjustbox}{angle=120} \begin{tabular}{|c|c|c|} \hline 1 & 2 & 3\\ \hline 4 & 5 & 6\\ \hline \end{tabular} \end{adjustbox} \end{table} Rotate an image with \verb|\adjustbox{angle=<x>}| command in \LaTeX :\\[4pt] \begin{figure}[H] \centering \caption{Caption} \begin{adjustbox}{angle=30} \includegraphics[width=.5\textwidth]{CodeSpeedy-Logo.png} \end{adjustbox} \end{figure} \end{document}
Output:
Rotate the table and image with \rotatebox
You can also use the \rotatebox
command to rotate the table or image in LaTeX. In this case, you have to load the graphicx
package. Use this command Like this.
\rotatebox{<angle>}{
% table or image
}
\documentclass{article} \usepackage{float} % To fix floating objects \usepackage{graphicx} \begin{document} Rotate a table with \verb|\rotatebox{<angle>}| command in \LaTeX :\\[4pt] \begin{table}[H] \centering \caption{Caption} \rotatebox{120}{ \begin{tabular}{|c|c|c|} \hline 1 & 2 & 3\\ \hline 4 & 5 & 6\\ \hline \end{tabular} } \end{table} Rotate an image with \verb|\rotatebox{<angle>}| command in \LaTeX :\\[4pt] \begin{figure}[H] \centering \caption{Caption} \rotatebox{30}{ \includegraphics[width=.5\textwidth]{CodeSpeedy-Logo.png} } \end{figure} \end{document}
Output:
Also read:
Leave a Reply