1

I try to put two images wrapped in the top of the page but in the same line, so I made the following MWE:

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

\begin{document}

\begin{wrapfigure}{l}[2cm]{0.3\textwidth}
  \vspace{-10pt}
    \includegraphics[width=0.23\textwidth]{example-image}
  \vspace{-10pt}
\end{wrapfigure}


\begin{wrapfigure}{r}[2cm]{0.3\textwidth}
  \vspace{-10pt}
    \includegraphics[width=0.23\textwidth]{example-image}
  \vspace{-10pt}
\end{wrapfigure}

\lipsum[2-18]
\end{document}

And this code give me the following ugly rendering:

But, mysteriously, when I only use the first or the second wrapfigure environment, the rendering work fine:

The problem only appear when I use it twice in the same time in the same page.

So, how can I put on the top of documenter two wrapfigure at the same page height?

fauve
  • 2,501

1 Answers1

3

You can't do this with wrapfigure. The setting of the second will destroy the settings of the first. You need to define your \parshape manually:

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

\begin{document}

\parshape 7  0pt            0.75\textwidth 
             0.25\textwidth 0.5\textwidth 
             0.25\textwidth 0.5\textwidth 
             0.25\textwidth 0.5\textwidth 
             0.25\textwidth 0.5\textwidth 
             0.25\textwidth 0.5\textwidth 
             0pt \textwidth  
\noindent\raisebox{-\height}[0pt][0pt]{%
 \makebox[0.25\textwidth][l]{%
  \makebox[\textwidth]{\includegraphics[width=0.23\textwidth]{example-image}\hfill \includegraphics[width=0.23\textwidth]{example-image}}}}%
\lipsum*

\end{document}

enter image description here

Ulrike Fischer
  • 327,261
  • Interesting solution, but it didn’t permit to put a part of the graphic in the margin, like we did it with [2cm] wrapfigure’s option. – fauve Dec 13 '17 at 16:36
  • Simply change the value in the raisebox. And for horizontal displacement you can add \hspace to the inner makebox, or use the trim key. – Ulrike Fischer Dec 13 '17 at 16:38