Positioning images and tables (2023)

LaTeX is an editing tool that takes care of the format so you only have to worry about the contents of your document; nevertheless, better control of floating elements is sometimes necessary. This article explains how to position images and tables in a LaTeX document.

Contents

  • 1 Introduction
  • 2 Positioning images
    • 2.1 Basic positioning
    • 2.2 The figure environment
    • 2.3 Multiple images in one figure
    • 2.4 Wrapping text around a figure
  • 3 Positioning tables
    • 3.1 Basic positioning
    • 3.2 The table environment
    • 3.3 Wrapping text around a table
  • 4 Reference guide
  • 5 Further reading

The default alignment for images and tables is set to left

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam lobortis facilisis sem. Nullam nec mi et neque pharetrasollicitudin.\includegraphics[width=0.5\textwidth]{overleaf-logo}Praesent imperdiet mi necante. Donec ullamcorper, felis non sodales commodo, lectus velitultrices augue, a dignissim nibh lectus placerat pede. Vivamus nunc nunc, molestie ut, ultriciesvel, semper in, velit. Ut porttitor.

Positioning images and tables (1)

This is a simple example, for a description of this and other ways to include images in your LaTeX file see the article Inserting Images.

Open an example in Overleaf

Basic positioning

To change the default alignment of an image from left or right, an easy option is to add

\usepackage[export]{adjustbox}

to the preamble of your file and then use an additional option in your image-importing statement

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam lobortis facilisis sem. Nullam nec mi et neque pharetra sollicitudin.\includegraphics[width=0.5\textwidth, right]{overleaf-logo}Praesent imperdiet mi necante. Donec ullamcorper, felis non sodales commodo, lectus velit ultrices augue,a dignissim nibh lectus placerat pede. Vivamus nunc nunc, molestie ut, ultriciesvel, semper in, velit. Ut porttitor.

Positioning images and tables (2)

(Video) LATEX 101 12 Float Specifiers: Positioning Figures and Tables

The package adjustbox enables an additional option in the \includegraphics command, in the example the picture is aligned to right. The available values are: left, right, center, outer and inner, the last two are intended for two-sided documents.

Open an example in Overleaf

The figure environment

The figure environment (see Inserting Images) is intended to provide automatic positioning.

Praesent in sapien. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis fringilla tristique neque. Sed interdum libero ut metus. Pellentesque placerat. Nam rutrum augue a leo. Morbi sed elit sit amet ante lobortis sollicitudin.\begin{figure}[h]\includegraphics[width=0.5\textwidth, inner]{overleaf-logo}\caption{Caption}\label{fig:figure2}\end{figure}

Positioning images and tables (3)

This environment uses a positioning parameter passed inside brackets, it can take the next values:

ParameterPosition
hPlace the float here, i.e., approximately at the same point it occurs in the source text (however, not exactly at the spot)
tPosition at the top of the page.
bPosition at the bottom of the page.
pPut on a special page for floats only.
!Override internal parameters LaTeX uses for determining "good" float positions.
HPlaces the float at precisely the location in the LaTeX code. Requires the float package. This is somewhat equivalent to h!.

You can put more than one value in the parameter, for instance, if you write [ht] LaTeX will try to position the figure here, but if it's not possible (the space may be insufficient) then the figure will appear at the top of the page. It is recommended to use more than one positioning parameter to prevent unexpected results.

Open an example in Overleaf

Multiple images in one figure

It is possible to insert several images in one figure, each one with its own reference and label

Praesent in sapien. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis fringilla tristique neque...\begin{figure}[h]\begin{subfigure}{0.5\textwidth}\includegraphics[width=0.9\linewidth, height=6cm]{overleaf-logo} \caption{Caption1}\label{fig:subim1}\end{subfigure}\begin{subfigure}{0.5\textwidth}\includegraphics[width=0.9\linewidth, height=6cm]{mesh}\caption{Caption 2}\label{fig:subim2}\end{subfigure}\caption{Caption for this figure with two images}\label{fig:image2}\end{figure}Praesent blandit blandit mauris. Praesent lectus tellus, aliquet aliquam, luctus a, egestas a, turpis. Mauris lacinia lorem sit amet ipsum. Nunc quis urna dictum turpis accumsan semper.
(Video) Word - Images in Tables - How to place & position pictures in Word Tables

Positioning images and tables (4)

First, you must import the package subcaption by adding to the preamble

\usepackage{subcaption}

then you can use the environment \subfigure that takes one parameter, the width of the figure. This environment must be used inside a figure environment, captions and labels can be set to each subfigure.

Open an example in Overleaf

Wrapping text around a figure

The package wrapfig provides a useful feature, text can be floated around the images.

Praesent in sapien. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis fringilla tristique neque. Sed interdum libero ut metus. Pellentesque placerat.\begin{wrapfigure}{l}{0.25\textwidth}\includegraphics[width=0.9\linewidth]{overleaf-logo} \caption{Caption1}\label{fig:wrapfig}\end{wrapfigure}Praesent in sapien. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis fringilla tristique neque. Sed interdum

Positioning images and tables (5)

First import the package wrapfig by adding

\usepackage{wrapfig}

to the preamble.

After that you can use the environment wrapfig, it takes two parameters that are passed inside braces: the alignement that can be l, r, c, i or o; this letters stand for left, right, centre, inner and outer (the last two intended for two-sided documents). The second parameter is the width of the figure, in the example is 0.25 the width of the text. See the reference guide for a list of possible length units.

Open an example in Overleaf

(Video) Learn CSS Position In 9 Minutes

Options for table positioning are similar to those available for figures.

Basic positioning

Default position of the tabular environment is centre.

Praesent in sapien. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis fringilla tristique neque. Sed interdum libero ut metus. Pellentesque placerat. Nam rutrum augue a leo. Morbi sed elit sit amet ante lobortis sollicitudin.\arrayrulecolor[HTML]{DB5800}\begin{tabular}{ |s|p{2cm}|p{2cm}| }\hline\rowcolor{lightgray} \multicolumn{3}{|c|}{Country List} \\\hlineCountry Name or Area Name& ISO ALPHA 2 Code &ISO ALPHA 3 \\\hlineAfghanistan & AF &AFG \\\rowcolor{gray}Aland Islands & AX & ALA \\Albania &AL & ALB \\Algeria &DZ & DZA \\American Samoa & AS & ASM \\Andorra & AD & \cellcolor[HTML]{AA0044} AND \\Angola & AO & AGO \\\hline\end{tabular}Praesent in sapien. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis fringilla tristique neque. Sed interdum libero ut metus. Pellentesque placerat. Nam rutrum augue a leo. Morbi sed elit sit amet ante lobortis sollicitudin.

Open this code fragment in Overleaf


The following graphic shows the result of the code fragment above:

Positioning images and tables (6)

You can also open a complete project example project in Overleaf.

To learn about how to create tables see the Tables article.

The table environment

The table environment is intended to automatically position tables so they fit nicely in the flow of your document.

Praesent in sapien. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis fringilla tristique neque. Sed interdum libero ut metus. Pellentesque placerat. Nam rutrum augue a leo.Morbi sed elit sit amet ante lobortis sollicitudin.\begin{table}[ht]\arrayrulecolor[HTML]{DB5800}\centering\begin{tabular}{ |s|p{2cm}|p{2cm}| }\hline\rowcolor{lightgray} \multicolumn{3}{|c|}{Country List} \\\hlineCountry Name or Area Name& ISO ALPHA 2 Code &ISO ALPHA 3 \\\hlineAfghanistan & AF &AFG \\\rowcolor{gray}Aland Islands & AX & ALA \\Albania &AL & ALB \\Algeria &DZ & DZA \\American Samoa & AS & ASM \\Andorra & AD & \cellcolor[HTML]{AA0044} AND \\Angola & AO & AGO \\\hline\end{tabular}\caption{Table inside a floating element}\label{table:ta}\end{table}Praesent in sapien. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis fringilla tristique neque. Sed interdum libero ut metus. Pellentesque placerat. Nam rutrum augue a leo. Morbi sed elit sit amet ante lobortis sollicitudin.

Open this code fragment in Overleaf


The following graphic shows the output produced by the Overleaf link:

(Video) Automatic numbering of captions for images and tables in a Word document

Positioning images and tables (7)

A position parameter, inside brackets, can be passed to the table environment. This parameter can take the next values:

ParameterPosition
hPlace the float here, i.e., approximately at the same point it occurs in the source text (however, not exactly at the spot)
tPosition at the top of the page.
bPosition at the bottom of the page.
pPut on a special page for floats only.
!Override internal parameters LaTeX uses for determining "good" float positions.
HPlaces the float at precisely the location in the LaTeX code. Requires the float package. This is somewhat equivalent to h!.

You can set more than one value in the parameter, for instance, if you write [ht] LaTeX will try to position the table here, but if it's not possible (the space may be insufficient) then the table will appear at the top of the page. It is recommended to use more than one positioning parameter to prevent unexpected results.

Notice also the command \centering. This changes the alignment of the table within its container to centre instead of the default left.

Open an example in Overleaf

Wrapping text around a table

If your table don't take all available space and you want to put text next or before it, is possible with the package wrapfig.

First, import the package

\usepackage{wrapfig}

then you can use the environment wraptable which takes two parameters: The first one is the alignment that can be l, r, c, i or o for left, right, centre, inner and outer respectively. The second one is the width of the table container, keep in mind that this latter parameter must be the same as the width of the table, otherwise things may not be properly aligned.

Praesent in sapien. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis fringilla tristique neque. Sed interdum libero ut metus. Pellentesque placerat. Nam rutrum augue a leo. Morbi sed elit sit amet ante lobortis sollicitudin.\begin{wraptable}{r}{8cm}\arrayrulecolor[HTML]{DB5800}\centering\begin{tabular}{ |s|p{2cm}| }\hline\rowcolor{lightgray} \multicolumn{2}{|c|}{Country List} \\\hlineCountry Name or Area Name& ISO ALPHA 2 Code \\\hlineAfghanistan & AF \\\rowcolor{gray}Aland Islands & AX \\Albania &AL \\Algeria &DZ \\American Samoa & AS \\Andorra & \cellcolor[HTML]{AA0044} AD \\Angola & AO \\\hline\end{tabular}\caption{Table inside a wraptable}\label{table:ta2}\end{wraptable}Praesent in sapien. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis fringilla tristique neque. Sed interdum libero ut metus. Pellentesque placerat. Nam rutrum augue a leo. Morbi sed elit sit amet ante lobortis sollicitudin...

Open this wrapfig code fragment in Overleaf


The following graphic shows the output produced by the Overleaf link:

Positioning images and tables (8)

LaTeX units and lengths

(Video) How to fix the position of Figures and Tables in MS Word Paper Templates

AbbreviationDefinition
ptA point, is the default length unit. About 0.3515mm
mma millimetre
cma centimetre
inan inch
exthe height of an x in the current font
emthe width of an m in the current font
\columnsepdistance between columns
\columnwidthwidth of the column
\linewidthwidth of the line in the current environment
\paperwidthwidth of the page
\paperheightheight of the page
\textwidthwidth of the text
\textheightheight of the text
\unitlengthunits of length in the picture environment.

For more information see:

FAQs

How do I fix table and figure position in LaTeX? ›

If you add [hbt!] after the \begin{figure} , like this: \begin{figure}[hbt!] this then tells LaTeX to place the image right here (as close to the position in the source code as possible); or if that's not possible (e.g. it's too large to fit on the current page) at the top of the next page, or bottom of the next page.

How do I fix the position of an image in LaTeX? ›

The short answer: use the “float” package and then the [H] option for your figure. The longer answer: The default behaviour of figures is to float, so that LaTeX can find the best way to arrange them in your document and make it look better.

What are the captions for the tables and figures? ›

A figure caption is centered under the figure; a table caption is centered above the table (if a caption is more than one line, make it left justified). A Figure and its caption should appear on the same page. All captions should start with a capitalized word and end with a period.

How do you label figures and tables in a lab report? ›

Figures should be labeled with a number followed by a descriptive caption or title. Captions should be concise but comprehensive. They should describe the data shown, draw attention to important features contained within the figure, and may sometimes also include interpretations of the data.

How do you fix a table of figures? ›

Update a table of figures
  1. Click on the table of figures in your document. This will highlight the entire table.
  2. Click References > Update Table. Note: Update Table becomes an option only when you click the table of figures in your document. ...
  3. Select an Update in the in the Update Table of Figures dialog box. ...
  4. Click OK.

Videos

1. Stack Items Without Absolute Positioning #shorts #css
(241 Coding)
2. HTML 4 - Tables with Images
(s1perry)
3. Choosing where to position captions of figures and tables
(LDC SHLS GCU)
4. Positioning Figures and Tables - LaTeX Tutorial (Part 23)
(Coding Perspective)
5. How to make table captions and a list of tables in word
(Karina Adcock)
6. LaTeX: Images, Figures, Wrapping and the Logic Behind Them
(Luke Smith)
Top Articles
Latest Posts
Article information

Author: Errol Quitzon

Last Updated: 11/13/2022

Views: 6593

Rating: 4.9 / 5 (79 voted)

Reviews: 86% of readers found this page helpful

Author information

Name: Errol Quitzon

Birthday: 1993-04-02

Address: 70604 Haley Lane, Port Weldonside, TN 99233-0942

Phone: +9665282866296

Job: Product Retail Agent

Hobby: Computer programming, Horseback riding, Hooping, Dance, Ice skating, Backpacking, Rafting

Introduction: My name is Errol Quitzon, I am a fair, cute, fancy, clean, attractive, sparkling, kind person who loves writing and wants to share my knowledge and understanding with you.