74

I want to place an image on my document and have it appear, say, on the right part of the page with text flowing on the left. How can I do that with LaTeX? Just like one would do with HTML and images “floating” to the right (or left).

(when searching I found some similar questions which, however, were closed. I'm actually asking the question because I think it is a good question and should have a good answer on the site. Btw, assume I'm not using beamer nor anything fancy.)

2

2 Answers 2

77

The wrapfig package is perhaps the best package to provide such functionality. The following is an example of how to use such package

\documentclass{article}
\usepackage{graphicx,wrapfig,lipsum}
%------------------------------------------
\begin{document}
This is where the table goes with text wrapping around it. You may 
embed tabular environment inside wraptable environment and customize as you like.
%------------------------------------------
\begin{wrapfigure}{r}{5.5cm}
\caption{A wrapped figure going nicely inside the text.}\label{wrap-fig:1}
\includegraphics[width=5.5cm]{sample}
\end{wrapfigure} 
%------------------------------------------
\lipsum[2-3]

Figure~\ref{wrap-fig:1} is a wrapped figure.
%------------------------------------------
\end{document}

Which produces the following output:

enter image description here

8
  • Do you know a way to make wrapfig respect margins, like graphicx does? If I put the image less than its height from the page end, the image trespasses margins and even page dimensions, getting cut out, instead of going in the next page, so I have to adjust it manually. Feb 3, 2016 at 15:57
  • @JeffreyLebowski Not sure. Maybe you want to write a small example showing the undesired behaviour and post as a new question! Feb 4, 2016 at 9:04
  • Done! Feb 5, 2016 at 11:17
  • 3
    How does your code work? There is a { besides \lipsum[2-3], but no closing bracket. And then there is a mysterious \par
    – Fraïssé
    Dec 8, 2018 at 1:45
  • 1
    Note that replacing the r with an R after \begin{wrapfigure} causes the figure to float, which can help prevent the figure from protruding into the margins of the page.
    – littleO
    Sep 9, 2023 at 4:51
10

The wrapfig package is perhaps the package that provides functionality most like a html/css float.

There are 142 posts returned from a search of this site for wrapfig. Yiannis gives one in his comment above, another useful example is

Wrap text around a tabular

3
  • 1
    Thanks, could you please provide a simple example of usage? (Just want to make this an excellent answer!) May 9, 2012 at 19:17
  • 1
    I wasn't asking for me. I was asking for other people stumbling with this question. May 9, 2012 at 19:32
  • I stumbled across this answer and it did not help me. We need an example.
    – Tvde1
    Nov 12, 2018 at 12:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .