46

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.)

47

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]
\par
Figure~\ref{wrap-fig:1} is a wrapped figure.
%------------------------------------------
\end{document}

Which produces the following output:

enter image description here

  • 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. – Jeffrey Lebowski Feb 3 '16 at 15:57
  • @JeffreyLebowski Not sure. Maybe you want to write a small example showing the undesired behaviour and post as a new question! – Juan A. Navarro Feb 4 '16 at 9:04
  • Done! – Jeffrey Lebowski Feb 5 '16 at 11:17
  • How about the figure on the left? – Peaceful Nov 11 '17 at 6:29
  • 2
    How does your code work? There is a { besides \lipsum[2-3], but no closing bracket. And then there is a mysterious \par – Carlos - the Mongoose - Danger Dec 8 '18 at 1:45
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

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

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.