How to rotate figure with caption in LaTeX?

Rotating figures or images is an important task in LaTeX, which supports document requirements and design. In this article, we’ll discuss different ways to turn figures, with example code and explanations for each method.

Use angle option in includegraphics

LaTeX’s graphicx package provides the most common and simple way to rotate images. After loading this package, you can use angle option in includegraphics command.

\includegraphics[angle=θ]{figure-path}
\documentclass[12pt]{article}
\usepackage{graphicx,lipsum,caption,subcaption}
\begin{document}

\lipsum[6][1-4]

\begin{figure}[ht]
\begin{subfigure}[b]{0.3\textwidth} 
    \includegraphics[angle=45,width=\textwidth]{example-image-a}
    \caption{\textit{45 degree}}
    \label{fig:image1}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.3\textwidth}
    \includegraphics[angle=60,width=\textwidth]{example-image-b}
    \caption{\textit{60 degree}}
    \label{fig:image2}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.3\textwidth}
    \includegraphics[angle=180,width=\textwidth]{example-image-c}
    \caption{\textit{180 degree}}
    \label{fig:image3}
\end{subfigure}
\end{figure}

\end{document}

Output :

Easiest method is to pass the angle option into includegraphics command.

Use rotating package

The rotating package provides a more advanced option, specialized for rotating images through the sidewaysfigure and turn environments.

Figure is rotated 90 degrees by sidewaysfigure environment

Sidewaysfigure environment rotates both the image and caption by 90 degrees. It especially displays images in landscape orientation. And within this package, you cannot pass custom angles.

\documentclass[12pt]{article}
\usepackage{rotating,lipsum,graphicx}
\begin{document}

\begin{sidewaysfigure}
\centering
  \includegraphics[width=0.4\textwidth]{example-image-a}
    \caption{Simple Image A}
\end{sidewaysfigure}

\end{document}

Output :

This figure shows the use of sidewaysfigure in which custom angles cannot be passed.

If you need a degree other than 90 degrees (such as 45 degrees or 270 degrees), you can use another method instead of sidewaysfigure environment.

Use of turn environment

The turn environment is part of rotating package. In this case, you can add angle values as you wish which is not possible in sidewaysfigure.

\begin{turn}{angle}
.......
.......
\end{turn}

angle is the degree of rotation. It will rotate clockwise (clockwise) if positive and counter-clockwise if negative.

\documentclass[12pt]{article}
\usepackage{graphicx,rotating,lipsum}
\begin{document}

\lipsum[5][1-4]
\begin{figure}[h]
    \centering
    \begin{turn}{45}        
    \includegraphics[width=0.4\textwidth]{example-image-c}
    \end{turn}
    \label{fig:figure_ref}
    \caption{Example Image C - $45^o$ turn}
\end{figure}

\end{document}

Output :

 This figure shows how the desired angle is passed to turn command.

Use of rotatebox command

This command takes two main parameters. For example, first is rotation angle, which indicates how many degrees you want to rotate the object, and second is object itself.

\rotatebox{angle}{object}
\documentclass[12pt]{article}
\usepackage{graphicx}
\begin{document}

\begin{figure}
  \centering
  \rotatebox{45}{
    \includegraphics[width=.35\linewidth]{example-image-a}}
    \caption{\textit{This is a rotated image without caption.}}
  \label{fig:figure_ref}
\end{figure}

\end{document}

Output :

Using rotatebox command without captions.

Here, 90 is the degree of rotation and \includegraphics[...] is image command. This rotatebox command provides the ability to easily rotate any floating element by a specified angle.

Caption with rotatebox command

Rotating captions using rotatebox command in LaTeX is usually uncommon and obsolete, but in some cases, it can be useful.

If you want to rotate an image with a caption, you can put both caption and image in a minipage environment.

\documentclass[12pt]{article}
\usepackage{graphicx}
\begin{document}
\begin{figure}
  \centering
  \rotatebox{45}{
    \begin{minipage}{.35\textwidth}
      \includegraphics[width=1\linewidth]{example-image-c}
      \caption{\textit{This is a rotated image with caption.}}
    \end{minipage}}
  \label{fig:figure_ref}
\end{figure}

\end{document}

Output :

Rotatebox command also effects captions with figures.

Using newcommand to reduce repetition

If you need to rotate images repeatedly in a document, instead of manually using rotatebox or includegraphics option for each figure, you can define a new command that will automatically do this.

\newcommand{\myfig}[4]{
    \begin{figure}[h]
        \centering
        \includegraphics[angle=#1,width=#2\textwidth]{#3}
        \caption{#4}
    \end{figure}
}

Here, the new command myfig takes four parameters: degree of rotation (#1), image width (#2), filename (#3), and caption (#4). This method reduces the repetition of your code.

\documentclass{article}
\usepackage{graphicx}

\newcommand{\myfig}[4]{
    \begin{figure}[h]
        \centering        
        \includegraphics[angle=#1,width=#2\textwidth]{#3}
        \caption{#4}
    \end{figure}
}

\begin{document}
Donec vehicula augue eu neque. Pellentesque habitant morbi tristique senectus et netus et
malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus rhoncus sem.

\myfig{45}{0.3}{example-image-a}{Simple Image A}

Integer sapien est, iaculis in, pretium quis, viverra ac, nunc. Praesent eget sem vel leo ultrices bibendum.
Aenean faucibus. Morbi dolor nulla, malesuada eu, pulvinar at, mollis ac, nulla. 

\myfig{60}{0.3}{example-image-c}{Simple Image C}

\end{document}

Output :

This figure shows how repeating code is reduced using the new command.

Conclusion

The rotatebox, turn, and angle option provides a great solution for figures with captions in LaTeX. Using these commands and environments, any element can be rotated accurately to any degree, which improves the visual quality of the document. This is especially essential in graphical design and presentation.

Md Jidan Mondal

LaTeX expert with over 10 years of experience in document preparation and typesetting. Specializes in creating professional documents, reports, and presentations using LaTeX.

Leave a Comment

Your email address will not be published. Required fields are marked *