# Create a wrapfigure with side caption and place it in the upper right corner?

I want to use the wrapfig packet to wrap text around an image. Since the image is longer than wide I'd like the caption to be aside of the image. Finally, the image should be placed in the upper right corner of my document. Currently it looks like this:

I tried to place the caption on the right side of the image. Therefore I tried to use the sidecap package and the SCfigure environment. Here is an example code (with an example image) that demonstrates my attempt:

\documentclass{article}
\usepackage{mwe}% for this example only
\usepackage{wrapfig}
\usepackage{sidecap}

\begin{document}

\begin{wrapfigure}{r}{1.8cm}
\begin{SCfigure}
\begin{center}
\includegraphics[width=1.5cm]{example-image}
\end{center}
\caption{Example side caption text for example image}
\end{SCfigure}
\end{wrapfigure}

\lipsum[2]

\end{document}


Unfortunately this won't work. The image doesn't get printed. Hence I have two questions:

1. How can one combine wrapfig and sidecap?
2. How can one place a wrapfigure in the upper right corner?

Edit: "how can one place a wrapfigure"

The wrapfigure is defined between two paragraphs. I do not know where the page break occurs. So I am looking for a solution that ensures that the wrapfigure will always be in the upper right corner, something like: \begin{table}[t].

Cras nec ante. Nam dui ligula, fringilla a, euismod sodales, sollicitudin vel,
wisi.

\begin{wrapfigure}{r}{1.8cm}
\begin{center}
\includegraphics[width=1.5cm]{example-image}
\end{center}
\caption{Example side caption text for example image}
\end{wrapfigure}

Morbi auctor lorem non justo. Nam lacus libero, pretium at,
lobortis vitae, ultricies et, tellus. Donec aliquet, tortor sed accumsan bibendum,
erat ligula aliquet magna, vitae ornare odio metus a mi. Morbi ac orci et
nisl hendrerit mollis. Suspendisse ut massa. Cras nec ante.

-

You don't need sidecap!. What you need is two minipages:

\documentclass{article}
\usepackage{mwe} %% for this example only
\usepackage{wrapfig}
% \usepackage{sidecap}

\begin{document}

\begin{wrapfigure}{r}{4.5cm}
\begin{minipage}{2cm}
%\begin{SCfigure}
\centering
\includegraphics[width=1.5cm]{example-image}
\end{minipage}%
\begin{minipage}{2cm}
\caption{Example side caption text for example image}
%  \end{SCfigure}
\end{minipage}
\end{wrapfigure}

\lipsum[2]

\end{document}


You can adjust the bad boxes by adjusting the width of second minipage in your actual file.

You have to place the wrapfigure code snippet at appropriate place in your code so that it appears at upper right corner and try not to float it.

-
@Harish Kumar: Thank you very much for your answer. The minipage solution works great! Unfortunately I cannot adopt your advice for the wrapfigure placement. Please check my edited question. I have now described in more detail what the problem is about. –  Flying Rocket Jan 5 '13 at 15:45
@FlyingRocket: That is more of manual work I am afraid. If you try to float them, then it is your luck. I suggest to do it manually. Please refer to section 1, page 2 of the wrapfig manual (on Placement and Floating) –  Harish Kumar Jan 5 '13 at 16:15
I just know how you put a frame around the output image. See my own frame for your output above. –  stalking is prohibited Jan 5 '13 at 16:30
@AdorableCreature It is simple for my case. I use snipping tool in windows 7 and there I can make it default. But how did you do it? –  Harish Kumar Jan 5 '13 at 17:04
I just posted an answer about How does one add a LaTeX output to a question/answer?. –  stalking is prohibited Jan 6 '13 at 4:58