[Tex/LaTex] Wrapping text around multiple figures

floatspositioningwrapfigure

I am a beginner in LaTex, but I have to to do this in a hurry:

enter image description here

I need to write a macro to handle 2 cases (or one macro for both).

1st case: i have 1 – 3 pictures on the right side, and the left text should "flow" around it.

2nd case (nasty one 🙁 ): i have 1 – 6 pictures and text should do the same.

My problem is this : how to layout pictures in page because pictures should be "anchored" to some paragraph (for example 1st picture to paragraph 1, 2nd picture to paragraph 4, 3rd to paragraph 5). I have to write a macro to handle such cases.

Can anyone help me or direct me to the right web instructions, plz ?

Best Answer

As already mentioned by others this can be done using the wrapfig package. You need to place the wrapfigure just before the paragraph. See the example code below. However, it only supports rectangular figures. You will need to use two of them for the last example but need to place at least one paragraph between them, which makes it a little tricky. If you need captions for the images use the caption of capt-of package which both provide the macro \captionof{figure}{<your caption>}. The subfig package is normally used if you want sub-figures with (a), (b), etc. sub-captions, but I think it doesn't work outside a normal float.

\documentclass{article}
\usepackage{wrapfig}

\usepackage{xcolor}
\usepackage{lipsum}% dummy text only

\begin{document}

\lipsum[1]

\begin{wrapfigure}{r}{3cm}
    \begin{tabular}{@{}c@{}}
    \textcolor{blue}{\rule{3cm}{3cm}} \\% Dummy image replacement
    \textcolor{green}{\rule{3cm}{3cm}} \\% Dummy image replacement
    \textcolor{red}{\rule{3cm}{3cm}} \\% Dummy image replacement
    \end{tabular}
\end{wrapfigure}

\lipsum[2-4]


\newpage

\lipsum[1]

\begin{wrapfigure}{r}{3cm}
    \begin{tabular}{@{}c@{}}
    \textcolor{blue}{\rule{3cm}{3cm}} \\% Dummy image replacement
    \textcolor{green}{\rule{3cm}{3cm}} \\% Dummy image replacement
    \end{tabular}
\end{wrapfigure}

\lipsum[2-4]


\newpage

\lipsum[1]

\begin{wrapfigure}{r}{3cm}
    \begin{tabular}{@{}c@{}}
    \textcolor{blue}{\rule{3cm}{3cm}} \\% Dummy image replacement
    \end{tabular}
\end{wrapfigure}

\lipsum[2-3]


\newpage



\lipsum[1]

\begin{wrapfigure}{r}{6.5cm}
    \begin{tabular}{@{}cc@{}}
    \textcolor{blue}{\rule{3cm}{3cm}} &% Dummy image replacement
    \textcolor{orange}{\rule{3cm}{3cm}} \\% Dummy image replacement
    \textcolor{green}{\rule{3cm}{3cm}} &% Dummy image replacement
    \textcolor{yellow}{\rule{3cm}{3cm}} \\% Dummy image replacement
    \textcolor{red}{\rule{3cm}{3cm}} &% Dummy image replacement
    \textcolor{brown}{\rule{3cm}{3cm}} \\% Dummy image replacement
    \end{tabular}
\end{wrapfigure}

\lipsum[2-3]

\newpage

\lipsum[1]

\begin{wrapfigure}{r}{6.5cm}
    \begin{tabular}{@{}cc@{}}
    \textcolor{blue}{\rule{3cm}{3cm}} &% Dummy image replacement
    \textcolor{green}{\rule{3cm}{3cm}} \\% Dummy image replacement
    \end{tabular}
\end{wrapfigure}

\lipsum[2]
\begin{wrapfigure}{r}{3cm}
    \begin{tabular}{@{}c@{}}
    \textcolor{red}{\rule{3cm}{3cm}} \\% Dummy image replacement
    \end{tabular}
\end{wrapfigure}

\lipsum[3]


\newpage

\end{document} 

Result

Related Question