Latex provides the wrapfig
package which lets you wrap text around figures. In not only saves place, but also embeds the figure nicely into your text.
Add the wrapfig package in your preamble:
\usepackage{wrapfig}
And place the figure where you want to have it:
\begin{wrapfigure}[1]{2}[3]{4} ... \end{wrapfigure}
and similarly for tables:
\begin{wraptable}[1]{2}[3]{4} ... \end{wraptable}
- Number of lines (optional)
- “r” for right and “l” for left figure placement.
- Overhang (optional)
- Width to be reserved.
Example:
\documentclass[11pt]{article} \usepackage{wrapfig, blindtext} \begin{document} \section{Example: Wrapping text around figure} \begin{wrapfigure}{r}{0.5\linewidth} \centering \rule{0.9\linewidth}{0.75\linewidth} \caption{Dummy figure.} \label{fig:myfig} \end{wrapfigure} \blindtext \end{document}
By default, the length \linewidth
is equal to the width of the text area. Setting the figure width to 0.5\linewidth
changes \linewidth
to that value within the floating environment. Therefore, the first \linewidth
command have a different value than the next two.
To reduce vertical space on top of the figure, between the figure and the caption as well as below the caption, use the following trick:
\vspace{-10pt}
Finally, the wrapfig
package also allows embedding a figure/table into text that is structured into multiple columns, with the figure stretching over several columns (see documentation for details).
Sper
Hi Tom,
I’m trying to wrap the contents of some cells of a table without much luck.
Here’s my table, and the solution I am currently using:
Could you please let me know if there is an easier way of getting the same result, without shrinking the size of the characters?
I hope pasting directly from LaTeX is okay, it’s the best way in which I could think of showing you my problem.
Thank you kindly for taking the time!
Sper
tom
Hi Sper,
Thank you for the code, that made things a lot easier. I suggest using the fixed width column type m. You’ll find your code below with some changes. First, define a new columntype that is centered horizontally (m) and vertically (centering). Replace
\\
by\tabularnewline
to avoid “Missplaced \noalign” errors. And, use*{number}{type}
to avoid repeating the same columntype over and over again.Best, Tom.
Sper
Thanks a lot, Tom, for taking the time. I’ll give it a try and see how it works.
Sper
Jörg Lenhard
Very helpful, thanks!
Signor D
Thank you, just what I was looking for!
D
boudiccas
I’m trying to use a graphic alongside a numbered list, but it just dumps the graphic at the end of the file. This is my code –
How can I do it please Tom?
Sharon.
tom
Try the
minipage
environment:bekimcakolli
How do i use the wrapfigure in the report.?
tom
Hi there,
It works exactly the same way as shown in the example for
article
. Just give it a try and let me know if you get stuck.Best, Tom