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'm using wrapfig to put a small figure at the start of each paragraph. For the first paragraph of the page, this lines up neatly with the top of the text. But for subsequent paragraphs, the figure lines up with the second line:

\documentclass{article}

\usepackage{lipsum, wrapfig}

\begin{document}
\begin{wrapfigure}{l}[1cm]{2cm}\rule{2cm}{2.67cm}\end{wrapfigure}
\lipsum[1]

\begin{wrapfigure}{l}[1cm]{2cm}\rule{2cm}{2.67cm}\end{wrapfigure}
\lipsum[3]

\end{document}

gives

Two paragraphs, the first with correct wrapfig vertical alignment, the second with a mysterious space.

The second box here should line up with "Nulla" (not "lutpat") in the same way as the first does with "Lorem".

Using the optional argument to specify the number of shortened lines does not change the actual picture placement at all. Nor does \raisebox, although I'm not sure why. And nor does placing the wrapfigure environment any earlier in the text (obviously not possible with lipsum, but I've tried putting this environment at several places through the preceding paragraph with no effect on the position of the figure).

This document is actually being typeset in LuaLaTeX, to use both ttf fonts and microtype, but the error is reproducible in pdfLaTeX (e.g., the MWE above). Obviously an automagic answer would be best, but there are sufficiently few of these pictures that a solution involving tweaking some length by hand would still be very helpful.

share|improve this question
1  
possible duplicate of Wrapped figure diverges from text level after sections –  Gonzalo Medina Sep 6 '11 at 20:08
add comment

1 Answer

up vote 11 down vote accepted

The explanation I give here is simply an extended version of the answer given some time ago by Ulrike Fischer in Wrapped figure diverges from text level after sections.

The wrapfigure package adds the length \intextsep to the figure and this length is responsible for the odd behaviour (the first figure dosn't get affected because \intextsep has no effect at the beginning of the page). One possible solution would be to set this length to 0pt; you have to be careful, though, since \intextsep is also used for other floats, so setting it globally to 0pt might have undesired effects. Here's a local redefinition of the length:

\documentclass{article}
\usepackage{lipsum, wrapfig}

\begin{document}

\begingroup
\setlength\intextsep{0pt}
\begin{wrapfigure}{l}[1cm]{2cm}\rule{2cm}{2.67cm}\end{wrapfigure}
\lipsum[1]
\endgroup

\begingroup
\setlength\intextsep{0pt}
\begin{wrapfigure}{l}[1cm]{2cm}\rule{2cm}{2.67cm}\end{wrapfigure}
\lipsum[3]
\endgroup

\end{document}

enter image description here

share|improve this answer
    
Many thanks for this---which worked like a charm---and apologies for not spotting the duplicate! –  Ant Sep 6 '11 at 21:20
add comment

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.