Wrapping text around figures
At times, it might be desirable to wrap text around a float (a figure, in our case) so as not to break the flow of the text. There are a number of packages in LaTeX to accomplish this task, though they require some amount of manual tuning in most of the cases.
Using wrapfig
To use wrapfig, we need to include the following line in preamble:
\usepackage{wrapfig}
This makes the wrapfigure environment available to us, and we can put a \includegraphics command inside it to create a figure around which text will be wrapped. Here is how we can specify a wrapfigure environment:
\begin{wrapfigure}[lineheight]{position}{width}
...
\end{wrapfigure}
The position parameter has eight possible values:
r | R | right side of the text |
l | L | left side of the text |
i | I | inside edge–near the binding (in a twoside document) |
o | O | outside edge–far from the binding |
The uppercase version allows the figure to float. The lowercase version means exactly here.
Here is an example:
\begin{wrapfigure}{r}{0.5\textwidth}
\begin{center}
\includegraphics[width=0.48\textwidth]{birds}
\end{center}
\caption{Birds}
\end{wrapfigure}
It may be noted that the width of the image included was specified relative to width of the text (\textwidth). It is a good idea to use relative sizes to define lengths (height, width, etc), particularly when using wrapfigure.
In the example above, the figure covers exactly half of the the textwidth, and the actual image uses a slightly smaller width, so that there is a pleasing small white frame between the image and the text. The image should always be smaller (less wide) than the wrap, or it will overrun the text.
Take care while using adding wrapfigures very near the top or bottom of a page, as this can often cause unwanted effects that are hard or near-impossible to solve. It is not advisable to try to use wrapfigures alongside equations or sectional headers. They also cannot be used in lists, such as itemize
and enumerate
environments.
Dealing with Images with white space
In case the image has undesirable white space, we can use any of the following options to remove the extra whitespace:
- trim the white space when using \includegraphics
- The picins package may be used instead of wrapfigure, which removes the extra white space out of the box without any manual tuning.
- The package floatflt is another alternative.
- Avoid using \begin{center} to center the image, it adds extra space. Use \centering instead.
- The program pdfcrop (included in most TeX installations) may be used to remove the white space permanently.
Overleaf guides
- Creating a document in Overleaf
- Uploading a project
- Copying a project
- Creating a project from a template
- Using the Overleaf project menu
- Including images in Overleaf
- Exporting your work from Overleaf
- Working offline in Overleaf
- Using Track Changes in Overleaf
- Using bibliographies in Overleaf
- Sharing your work with others
- Using the History feature
- Debugging Compilation timeout errors
- How-to guides
- Guide to Overleaf’s premium features
LaTeX Basics
- Creating your first LaTeX document
- Choosing a LaTeX Compiler
- Paragraphs and new lines
- Bold, italics and underlining
- Lists
- Errors
Mathematics
- Mathematical expressions
- Subscripts and superscripts
- Brackets and Parentheses
- Matrices
- Fractions and Binomials
- Aligning equations
- Operators
- Spacing in math mode
- Integrals, sums and limits
- Display style in math mode
- List of Greek letters and math symbols
- Mathematical fonts
- Using the Symbol Palette in Overleaf
Figures and tables
- Inserting Images
- Tables
- Positioning Images and Tables
- Lists of Tables and Figures
- Drawing Diagrams Directly in LaTeX
- TikZ package
References and Citations
- Bibliography management with bibtex
- Bibliography management with natbib
- Bibliography management with biblatex
- Bibtex bibliography styles
- Natbib bibliography styles
- Natbib citation styles
- Biblatex bibliography styles
- Biblatex citation styles
Languages
- Multilingual typesetting on Overleaf using polyglossia and fontspec
- Multilingual typesetting on Overleaf using babel and fontspec
- International language support
- Quotations and quotation marks
- Arabic
- Chinese
- French
- German
- Greek
- Italian
- Japanese
- Korean
- Portuguese
- Russian
- Spanish
Document structure
- Sections and chapters
- Table of contents
- Cross referencing sections, equations and floats
- Indices
- Glossaries
- Nomenclatures
- Management in a large project
- Multi-file LaTeX projects
- Hyperlinks
Formatting
- Lengths in LaTeX
- Headers and footers
- Page numbering
- Paragraph formatting
- Line breaks and blank spaces
- Text alignment
- Page size and margins
- Single sided and double sided documents
- Multiple columns
- Counters
- Code listing
- Code Highlighting with minted
- Using colours in LaTeX
- Footnotes
- Margin notes
Fonts
Presentations
Commands
Field specific
- Theorems and proofs
- Chemistry formulae
- Feynman diagrams
- Molecular orbital diagrams
- Chess notation
- Knitting patterns
- CircuiTikz package
- Pgfplots package
- Typesetting exams in LaTeX
- Knitr
- Attribute Value Matrices
Class files
- Understanding packages and class files
- List of packages and class files
- Writing your own package
- Writing your own class