Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have included a picture with wrapfigure and everything is fine - the problem is that in my next formula environment, the formula is totally wrong! It seems to me, that the width which I set in the wrapfigure environment also effects the formula. How can I set the width back again to standard?

Here is my code:

\documentclass{book}
\usepackage{graphicx}
\usepackage{amsthm}
\usepackage{wrapfig}
\usepackage{mdframed}

\newtheoremstyle{mystyle}{}{}{}{}{}{}{0.5em}{}
\theoremstyle{mystyle}
\newmdtheoremenv{formel}{Formel}

\begin{document}
\begin{wrapfigure}{l}{8cm}
  \includegraphics[scale=0.48]{example-image-a}
\end{wrapfigure}
text text text text text text text text text text text text text text text text
text text text text text text text text text text text text text text text text
\begin{formel}[Formel]
$1+1=2$
\end{formel}
\end{document}

So the text wrapping around the figure is OK, but then width of the formula is wrong. It seems to me, that textwidth is set to the wrapfigure's textwidth, what results in a wrong display.

share|improve this question
1  
Welcome to TeX.SE! Your MWE contains a couple of typos (e.g., "docuemnt") and generates some option clashes. Please edit your MWE to eliminate these problems, so that it becomes compilable -- and still generates the error you're trying to fix. Please also consider eliminating all code that's not pertinent to the problem you're facing, so as to make the example code truly "minimalist". At the moment you're loading lots and lots of packages that don't seem to be related to the problem. –  Mico Aug 18 '12 at 13:23
    
Just a note: \usepackage{mwe} and \includegraphics[scale=0.48]{example-image-a} make your MWE compilable without using your picture.png (which is not generally available). See also New support package for MWEs. –  Stephen Aug 18 '12 at 14:07
    
Welcome to TeX.sx! Please register your account. Since you got a responses below that seems to answer your question (if it does not, please tell us!), please consider marking it as ‘Accepted’ by clicking on the tickmark below its vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). Additionally it is possible to upvote answers (with the upward pointing arrow to the left of it). –  Stephen Aug 24 '12 at 17:51

1 Answer 1

To cite the manual of the wrapfig package, page 1:

You must not specify a wrapfigure in any type of list environment or or immediately before or immediately after one. It is OK to follow a list if there is a blank line (\par) in between.

[...]

\linewidth is now adjusted within the wrapped text, but since it can only be set for whole paragraphs at a time, it will persist with the wrong value after the wrapping, until the paragraph is finished.

And at page 2:

For esthetic reasons, only plain text should wrap around the figure. Section titles and big equations look bad; lists are bad if the figure is on the left. (All these function properly, they just don’t look very good.) Small equations look fine.

Thus: Put a \par before \begin{formel}:

\documentclass{book}
\usepackage{graphicx}
\usepackage{amsthm}
\usepackage{wrapfig}
\usepackage{mdframed}

\newtheoremstyle{mystyle}{}{}{}{}{}{}{0.5em}{}
\theoremstyle{mystyle}
\newmdtheoremenv{formel}{Formel}

%\usepackage{picins}

\begin{document}
\begin{wrapfigure}{l}{8cm}
  \includegraphics[scale=0.48]{example-image-a}
\end{wrapfigure}
text 
\par
\makeatletter
\loop
\ifnum\c@WF@wrappedlines>3
\hspace*{1sp}\newline
\advance\c@WF@wrappedlines by -1
\repeat
\makeatother
\par
\begin{formel}[Formel]
$1+1=2$
\end{formel}
\end{document}

If the text to be wrapped is too short, the formula would be placed in the wrapped text, where it has the smaller width, of course. (And an additional \usepackage{picins} is needed, otherwise the formula is printed "over" the picture.) Using \c@WF@wrappedlines of the wrapfig package and automatically inserting the appropriate number of empty lines fixes this.

share|improve this answer
    
\par or a blank line before \begin{formel} does changing nothing for me in the edited MWE. I think you have to play with the definition of the formel environment. –  Kurt Aug 18 '12 at 15:14
    
@Kurt: Well, yes and no: There is a change, but when the wrapped text is so short, that the formula is inside of the wrapped text, it is still as small as the text (which it is supposed to be!). –  Stephen Aug 18 '12 at 18:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.