Positioning of Figures
Open an example to learn how to place figures in the document Overleaf
To change the positioning of an image (and add caption and reference to it), we need to be able to treat it as an object inside the LaTeX document. This object needs to have a few desirable properties -
- The contents of this object, i.e., the image, cannot be broken over a page.
- We should be able to specify the position of this object in the document.
- We should be able to add a caption to this object.
- We should be able to add a reference to this object, so that it can be cross-referenced elsewhere in the document.
This is where floats come in handy.
Floats
In LaTeX, floats are used to contain things that must be placed inside a single page, i.e., they cannot be broken over multiple pages. floats can be used to contain tables and figures, but we can define new custom floats as well. Here is how floats address the issues mentioned above -
- The entity contained in a float is placed in a single page. If the entity (an image, for example) can not be contained in the space left in the current page, it is placed at the top of the next page.
- floats can be positioned wherever we specify - top, middle, bottom, left, right, and so on.
- They can have a caption describing them.
- They are numbered (so we can add references to them). This lets us produce a list of figures or a list of tables that we can include in our document.
To create floats to contain images, we use the figure environment.
Figures
Here is how we create a floating figure -
\begin{figure}[''placement specifier'']
... figure contents...
\end{figure}
The placement specifier parameter allows us to have a greater control over where a figure is placed. But while LaTeX will do its best to follow the placement we specify, it may not always be possible for it to adhere to it. Let us take a look at different placement specifiers and what they do before we dive into examples.
Specifier | Permission |
---|---|
h | Place the float here, i.e., approximately at the same point it occurs in the source text (however, not exactly at the spot) |
t | Position at the top of the page. |
b | Position at the bottom of the page. |
p | Put on a special page for floats only. |
! | Override internal parameters LaTeX uses for determining "good" float positions. |
H | Places the float at precisely the location in the LaTeX code. Requires the float package (\usepackage{float}). This is somewhat equivalent to h!, though some errors may arise if you have too many consecutive floats with [H]. |
- Example
\begin{figure}[hbt!]
... figure contents...
\end{figure}
Centering a Figure
We often need to center figures, particularly in presentations. This can be achieved by using \centering -
\begin{figure}[hbt!]
\centering
\includegraphics{birds}
\end{figure}
Overleaf guides
- Creating a document in Overleaf
- Uploading a project
- Copying a project
- Creating a project from a template
- 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
- Debugging Compilation timeout errors
- How-to guides
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
- 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
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 in LaTeX
- Bibliography management with biblatex
- Biblatex bibliography styles
- Biblatex citation styles
- Bibliography management with natbib
- Natbib bibliography styles
- Natbib citation styles
- Bibliography management with bibtex
- Bibtex bibliography styles
Languages
- Multilingual typesetting on Overleaf using polyglossia 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 and equations
- 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
- Typing 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
- Tips