0

I am trying to include a graphic which need to be rotated, along with the caption and fill the text to the textheight(in my example, this is set to 0.6 of textheight, for demonstration with the example image). This is inside a wrap figure, and I would like to align the wrapfigure to the right side(with the bottom of the captiontext aligned to the right). As of now, This works okey, but the width of the wrap figure is wrong. Changing the value will change the placement of the whole image and caption, but now I need to tweak it. There must be a better way of doing this. I have looked into the rotating-package, but it doesn't give me quite the result I'm after.

\documentclass[11pt]{article}
\usepackage{wrapfig,adjustbox, graphicx, lipsum}
\begin{document}

\begin{wrapfigure}{r}{0.6\textheight}
\vspace{-35pt}
  \begin{adjustbox}{addcode={\begin{minipage}{\width}}{\caption{%
      Image is huge} \end{minipage}},rotate=90,center}
      \includegraphics[width=0.6\textheight]{example-image-b}%
  \end{adjustbox}
\end{wrapfigure}
\section{Section text}
\lipsum
\end{document}

An alternative would be to include a section in with the text rotated according to the image, but on top of it. The problem with this approach is that I also have some fancy headers with the \firstleftmark which then produces some wrong results.

1

The main problem is that adjustbox creates a square box using the larger dimension, which can be demonstrated using \fbox. This approach uses \rotatebox and \savebox instead.

\documentclass[11pt]{article}
\usepackage{wrapfig,adjustbox, graphicx, lipsum}
\usepackage{caption, showframe}

\newsavebox{\tempbox}

\begin{document}

\savebox{\tempbox}{\includegraphics[width=0.6\textheight]{example-image-b}}%

\savebox{\tempbox}{\rotatebox{90}{%
   \begin{minipage}{\wd\tempbox}
      \usebox\tempbox
      \captionof{figure}{Image is huge}
   \end{minipage}}}

\section{Section text}
\begin{wrapfigure}{r}{\wd\tempbox}
\raisebox{0pt}[\dimexpr \ht\tempbox-\baselineskip]{\usebox\tempbox}
\end{wrapfigure}
\sloppy\lipsum
\end{document}

full page

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.