39

How to text-wrap an image in LaTeX.

Ex: In technical documents, authors names will be text wrapped tights, with their images.

65

Just to add another answer here in case anyone else has this question - you can wrap text around figures quite nicely with the wrapfig package. Here's a short example showing left and right aligned images with captions, with the text wrapped around.

This example is also viewable on writeLaTeX if you want to see the pdf output next to the code.

\documentclass[a4paper]{article}

\usepackage[english]{babel}  % force American English hyphenation patterns
\usepackage[utf8x]{inputenc}  % unicode
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{lipsum}  % generates filler text

\title{Package Example: wrapfig}
\author{writeLaTeX}

\begin{document}
\maketitle

\begin{wrapfigure}{R}{0.3\textwidth}
\centering
\includegraphics[width=0.25\textwidth]{frog.jpg}
\caption{\label{fig:frog1}This is a figure caption.}
\end{wrapfigure}

\lipsum[1]

\begin{wrapfigure}{L}{0.3\textwidth}
\centering
\includegraphics[width=0.25\textwidth]{frog.jpg}
\caption{\label{fig:frog2}This is a figure caption.}
\end{wrapfigure}

\lipsum[2-3]

\end{document}

How it looks:

Text wrapped around an image using the wrapfig package

Edit: Meant to add a note to say I'm one of the developers of writeLaTeX, and any feedback is appreciated! Thanks :-)

  • thank you for your anwswer. I was looking for a way to do this in LaTeX. Just one question, in case you know: wrapfig documentation says that wrapped figures may be wrongly ordered when listed together with regular floats. Do you know a solution for that? – Vicent Apr 12 '14 at 17:33
  • 3
    You should replace “writeLaTeX” by “overleaf”… – yannis Dec 26 '14 at 10:53
  • Thanks for the heads up Yannis, yes, we have a fair few things to change. For info, the company name is still Writelatex, so it is still applicable, just not front-and-center anymore. – John Hammersley Dec 27 '14 at 22:37
  • I get the picture overlapped with the text :( – Twink Sep 30 '17 at 22:43
  • @Twink the example above still works fine for me -- here it is in Overleaf: overleaf.com/11362188bphvnscnhfbq Are you having problems after adding your own images? – John Hammersley Oct 1 '17 at 23:13
16

Since author names are usually not that long that it could used as text to wrap around their images, I think you want to put the images inside text mode?

That can be done with \includegraphics that does not depend on environment figure or similar. Also there are many ways for scaling an image, the image can be rotated and positioned differently. The following example scales the image that it fits inside a line (\baselineskip. 30% is taken for the depth and 70% for the height of the image, values taken from \strut).

Example file:

\documentclass{article}
\usepackage{graphicx}

\newcommand*{\authorimg}[1]{%
  \raisebox{-.3\baselineskip}{%
    \includegraphics[
      height=\baselineskip,
      width=\baselineskip,
      keepaspectratio,
    ]{#1}%
  }%
}

\begin{document}
\begin{itemize}
\item[\authorimg{PeterM_Foxhead.png}] Author of Firefox
\item[\authorimg{Andy_ant.png}] Author of Apache Ant
\end{itemize}
\end{document}

Result

The images are taken from Openclipart:

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.