# Wrapped figure diverges from text level after sections

I have a big problem. I want to print an book with reportages. Every reportage has a headline (created by the section command), a teaser and an article. The teaser should be wrapped text and should be at the same level as the article. This works when I leave out the section-command as in the first \teaser. As soon as I add the section line the teaser and the reportage level diverges. Has anyone an idea how to fix this problem? Here an example:

\documentclass{article}

\usepackage{wrapfig}

\newcommand{\teaser}[1]{\begin{wrapfigure}{l}{0.5\textwidth}\textbf{#1}\end{wrapfigure}}

\begin{document}

\teaser{sdfaasdfasdf asfasfa asdfasdf asdfasf  asfasfasdfaasdfasdf aasdfasf }
asfasfasdfaasdfasdf asdfasdf asdfasf  asfasfasdfaasdfasdf asdfasdf asdfasf  asfasfasdfaasdfasdf asdfasdf asdfasf  asfasfasdfaasdfassdfasf  asfasfasdfaasdfasdf asdfasdf asdfasf  asfasfasdfaasdfasdf asdfasdf asdfasf  asfasfasdfaasdfasdf asdfasdf asdfasf  asfasfasdfaasdfasdf

\teaser{sdfaasdfasdf asfasfa asdfasdf asdfasf  asfasfasdfaasdfasdf aasdfasf }
asfasfasdfaasdfasdf asdfasdf asdfasf  asfasfasdfaasdfasdf asdfasdf asdfasf  asfasfasdfaasdfasdf asdfasdf asdfasf  asfasfasdfaasdfassdfasf  asfasfasdfaasdfasdf asdfasdf asdfasf  asfasfasdfaasdfasdf asdfasdf asdfasf  asfasfasdfaasdfasdf asdfasdf asdfasf  asfasfasdfaasdfasdf

\end{document}

-
It's not just after sections; if you add some text before the first \teaser command, the teaser and the text won't level. –  Gonzalo Medina Mar 22 '11 at 2:03
Hi Philip, welcome to TeX.SE. I formatted your message by indenting code (use four spaces or hit the 10101010 button) and adding an image. –  Matthew Leingang Mar 22 '11 at 2:04
Welcome to tex.sx! A tip: If you indent lines by 4 spaces, then they are marked as a code sample. You can also highlight the code and click the "code" button (with "101010" on it). For inline code you can use backticks (). –  Alan Munn Mar 22 '11 at 2:04
Just so you don't get confused, Matthew and I edited your question simultaneously, which is why you have two of these comments. –  Alan Munn Mar 22 '11 at 2:06
Is your teaser always text? Or will it sometimes include graphics? –  Alan Munn Mar 22 '11 at 3:01

I don't know what's causing the odd behaviour; however, you can prevent it using a convenient vertical skip; this is not an optimum solution, since it will produce undesired results if, for example, the \teaser command starts a new page. However, since you said your reportages will always start with a headline (created with the \section command), you could give it a try:

\documentclass{article}
\usepackage{wrapfig}

\newcommand{\teaser}[1]{%
\begin{wrapfigure}{l}{0.5\textwidth}\vspace*{-1\baselineskip}%
\textbf{#1}\end{wrapfigure}}

\begin{document}

\section{Test section}
\teaser{teaser text teaser text teaser text teaser text teaser text teaser 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 text text text text text text text text text text text text text text text text

\end{document}


-
Hi guys, I dont understand all the things you advised me to do, but I tried this solution and it works perfectly well. So much thanks to all contributers! –  Philip Mar 22 '11 at 14:30
@Philip: If the answer solved your problem, please accept the answer by clicking the checkmark. (This also applies for the other question you've asked.) –  Torbjørn T. Mar 23 '11 at 6:58

The space is \intextsep. It is inserted before every wrapfig. You don't see it in the first teaser because it is at the start of a page where such vertical spaces disappear. intextsep is declared/defined by the latex format and it is used in floats which are inserted with "h" in the text. So if you set it globally to 0pt it will affect such floats too.

-
Thanks Ulrike. Of course, that's the reason, and now that you mention it I feel angry at myself for not having thought about it. –  Gonzalo Medina Mar 22 '11 at 15:06

You can replicate your output using the titlesec package instead of wrapfig. The only puzzle with this code is that with no text after a section, the vertical spacing of the following subsection heading is wrong. This is fixed by inserting \leavevmode in between the section and the subsection.

\documentclass{article}
\usepackage{titlesec}
\usepackage[nopar]{lipsum} % for dummy text.

\titleformat{\subsection}[wrap] {\normalfont\bfseries\filright} {}{0em}{}
\titlespacing*{\subsection} {.5\textwidth}{0ex}{1pc}

\begin{document}

\section{A section}
\leavevmode % required if no text between \section and \subsection
\subsection{Lorem ipsum dolor sit amet, consectetuer adipiscing elit.}
\lipsum[1]

\end{document}
`

-