0

I have to insert two pictures of different width one below the other on the side of a text, and wrap the text around. I'd like the pictures to stay close to each other, so I don't want any text but the captions between the images.

Therefore I tried to put both the pictures inside the same wrapfigure environment, as in the following code:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{wrapfig}
\usepackage{lipsum}
\usepackage{tikz}

\begin{document}

\begin{wrapfigure}{o}{4cm}
    \begin{tikzpicture}
        \draw (0,0) -- (4,0) -- (4,4) -- (0,4) -- (0,0);
    \end{tikzpicture}
    \caption{A big square}
    \vspace{5mm}

    \begin{flushright}
    \begin{tikzpicture}
        \draw (0,0) -- (2,0) -- (2,2) -- (0,2) -- (0,0);
    \end{tikzpicture}
    \end{flushright}
    \caption{A small square}
\end{wrapfigure}

\lipsum[1-2]

\end{document}

Output: enter image description here

How do I get rid of the whitespace between the text and the second figure?

  • 2
    I won't do it. I will add \centering instead. – user156344 Mar 30 at 11:18
  • 3
    Don't use flushright - that's internally a list and adds space, use e.g. \raggedleft or \mbox{}\hfill \includegraphics ... – Ulrike Fischer Mar 30 at 11:19
  • 2
    It is possible to manually insert a wrapfig in the middle of a paragraph (but not using \lipsum or \blandtext). However, in this case it would look better to keep the width constant (especially with captions). – John Kormylo Mar 30 at 12:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.