7

I have just had some problem with wrapfigure where I used the following code:

\documentclass[a4paper, 12pt]{article} 

\usepackage{wrapfig} % to have text around figures
\usepackage{graphicx}   
\usepackage{amsmath}

\begin{document}
\subsubsection*{Sample Subsection}
\begin{wrapfigure}{r}{0.25\textwidth}
    \includegraphics[width=0.23\textwidth]{sampleFigure}
    \caption{Heat Balance for the ceiling node}
\end{wrapfigure}
\begin{equation*}
    a^2+b^2=c^2
\end{equation*}
with 
\begin{align*}
    a^2+b^2&=c^2 & a^2+b^2&=c^2 \\
    a^2+b^2&=c^2 & a^2+b^2&=c^2 \\
    a^2+b^2&=c^2 & a^2+b^2&=c^2
\end{align*}
can be solved to
\begin{equation}
   a^2+b^2=c^2
\end{equation}

\subsubsection*{Sample Subsection}
\begin{wrapfigure}{r}{0.25\textwidth}
    \includegraphics[width=0.23\textwidth]{sampleFigure}
    \caption{Heat Balance for the ceiling node}
\end{wrapfigure}
-> With some text it is working!
\begin{equation*}
    a^2+b^2=c^2
\end{equation*}
with 
\begin{align*}
    a^2+b^2&=c^2 & a^2+b^2&=c^2 \\
    a^2+b^2&=c^2 & a^2+b^2&=c^2 \\
    a^2+b^2&=c^2 & a^2+b^2&=c^2
\end{align*}
can be solved to
\begin{equation}
   a^2+b^2=c^2
\end{equation}

\end{document}

In the first subsection there is a problem, whereas the second subsection looks as I expected. The only difference between the two sections is the line starting with "->".

Does anyone have an explanation for this behaviour?

4
  • 3
    Please, make this into a compilable example.
    – egreg
    Apr 20, 2014 at 10:49
  • @egreg I have made the example compilable now. However I have not found any place to upload my sample image.
    – MatoBehr
    Apr 20, 2014 at 15:46
  • The sample image is not a problem; can you give an estimate for its height? In this way we can simply change it into a black rectangle.
    – egreg
    Apr 20, 2014 at 15:48
  • @egreg A square would be ok. I have done this with different images and the height does not seem to be of great importance. It needs to be heigh enough to reach down into the aligned set of equations though.
    – MatoBehr
    Apr 20, 2014 at 17:21

1 Answer 1

8

I can't profess to understand the internals of what brought on the problem to begin with; however, placing a \leavevmode after the \end{wrapfigure} resolves the issue.

I inferred the answer from the observed behavior that adding some text after the wrapfigure also resolves the issue. One thing that adding text does is take you out of vertical mode, so I tried leaving vertical mode as a solution, and it worked. Is that a bug with wrapfig? I couldn't say.

(For the rest of the readers, commenting that one line will re-create the problem.)

\documentclass[a4paper, 12pt]{article} 

\usepackage{wrapfig} % to have text around figures
\usepackage[demo]{graphicx}   
\usepackage{amsmath}

\begin{document}
\subsubsection*{Sample Subsection}
\begin{wrapfigure}{r}{0.25\textwidth}
    \includegraphics[width=0.23\textwidth]{sampleFigure}
    \caption{Heat Balance for the ceiling node}
\end{wrapfigure}
\leavevmode% THIS RESOLVED IT
\begin{equation*}
    a^2+b^2=c^2
\end{equation*}
with 
\begin{align*}
    a^2+b^2&=c^2 & a^2+b^2&=c^2 \\
    a^2+b^2&=c^2 & a^2+b^2&=c^2 \\
    a^2+b^2&=c^2 & a^2+b^2&=c^2
\end{align*}
can be solved to
\begin{equation}
   a^2+b^2=c^2
\end{equation}

\subsubsection*{Sample Subsection}
\begin{wrapfigure}{r}{0.25\textwidth}
    \includegraphics[width=0.23\textwidth]{sampleFigure}
    \caption{Heat Balance for the ceiling node}
\end{wrapfigure}
-> With some text it is working!
\begin{equation*}
    a^2+b^2=c^2
\end{equation*}
with 
\begin{align*}
    a^2+b^2&=c^2 & a^2+b^2&=c^2 \\
    a^2+b^2&=c^2 & a^2+b^2&=c^2 \\
    a^2+b^2&=c^2 & a^2+b^2&=c^2
\end{align*}
can be solved to
\begin{equation}
   a^2+b^2=c^2
\end{equation}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .