> For the complete documentation index, see [llms.txt](https://docs.overleaf.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.overleaf.com/writing-and-editing/generating-and-inserting-tables.md).

# Generating and inserting tables

This page explains how to generate, edit, and insert LaTeX tables in Overleaf. In practice, there are four options to create tables:

1. Using the [**Insert Table** button](#using-insert-table-to-generate-a-table) in the **Visual Editor** (or **Code Editor**) toolbar
2. [Pasting tables into your project](/writing-and-editing/generating-and-inserting-tables/pasting-tables-into-your-project.md) from another document while using **Visual Editor**
3. Writing the [LaTeX code for the table](https://www.overleaf.com/learn/latex/Tables) in **Code Editor**
4. Using **Overleaf**’s [LaTeX table generator](/writing-and-editing/generating-and-inserting-tables/ai-table-generator.md)

If you’re a confident LaTeX user you'll likely use option 3, which offers the most flexibility for generating tables. In that case, our detailed guidance on [how to create tables using LaTeX](https://www.overleaf.com/learn/latex/Tables) will serve you well. &#x20;

If you’re new to LaTeX, both the AI-powered LaTeX table generator and the toolbar in **Visual Editor** (option 1) provide excellent starting points.  You may also want to enroll in the free, self-paced course "[Structuring and Formatting Essentials](https://learn.overleaf.com/102-structuring-and-formatting-essentials)" to learn more about creating tables with Overleaf.

This page will focus on using the Visual Editor toolbar, from which you can switch between Visual Editor and Code Editor to observe the underlying table code.

## Using Insert Table to generate a table

{% stepper %}
{% step %}
Switch to **Visual Editor** using the toggle above the editor pane (or remain in **Code Editor** if you are comfortable editing LaTeX code).
{% endstep %}

{% step %}
Select the **Insert table** button <picture><source srcset="/files/kR7lkFnR5FIrMwCzXBCm" media="(prefers-color-scheme: dark)"><img src="/files/BGXzqhGpC130UxqatU4S" alt="Insert table button" data-size="line"></picture> on the toolbar:

<figure><picture><source srcset="/files/0oqUq2slxd9AycEJeK1m" media="(prefers-color-scheme: dark)"><img src="/files/wKhcgcMvjuT8r2C4lYof" alt="Location of the Insert Table button" width="319"></picture><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Click on **Select size** (see [AI Table Generator](/writing-and-editing/generating-and-inserting-tables/ai-table-generator.md) to learn how to **Insert from a text prompt or image**).
{% endstep %}

{% step %}
Using the pop-up selector, highlight the required number of rows and columns, then click the bottom-right selected cell to insert an empty table. Here, we insert a blank 3 x 3 table:

<div data-full-width="true"><figure><picture><source srcset="/files/jJps7vtCpAsleXUwYG7i" media="(prefers-color-scheme: dark)"><img src="/files/4cdXTDGNeBJjURPSg5eP" alt="The Insert Table pop-up selector" width="199"></picture><figcaption></figcaption></figure></div>
{% endstep %}

{% step %}
The empty table is now ready for you to edit. You can do this in **Code Editor** if you’re comfortable with LaTeX table code, or continue with **Visual Editor**, which provides additional table formatting functionality that’s currently unavailable in **Code Editor**.

{% tabs %}
{% tab title="Code Editor" %}
{% code title="Empty 3x3 table" %}

```latex
\begin{table}
    \centering
    \begin{tabular}{ccc}
         &  & \\
         &  & \\
         &  & \\
    \end{tabular}
    \caption{Caption}
    \label{tab:placeholder}
\end{table}
```

{% endcode %}
{% endtab %}

{% tab title="Visual Editor" %}

<figure><picture><source srcset="/files/zmm9dHStAcPm4mJbfOGn" media="(prefers-color-scheme: dark)"><img src="/files/LqUPfOaFYVwP9gJWU8vw" alt="Empty 3x3 table in Visual Editor" width="375"></picture><figcaption><p>Empty 3x3 table</p></figcaption></figure>
{% endtab %}
{% endtabs %}
{% endstep %}
{% endstepper %}

To learn more about how to incorporate the AI Table Generator in your writing, enroll in our free, self-paced course "[Leveraging Overleaf AI"](https://learn.overleaf.com/leveraging-overleaf-ai).

## FAQs about tables

<details>

<summary>Can the Visual Editor preview tables created in the Code Editor?</summary>

It depends on the table and its code, but the Visual Editor will try to preview as much as possible. Complex tables, such as those created using LaTeX packages, journal article templates, or custom user commands (macros), may be partially, or entirely displayed as LaTeX code when viewed in the Visual Editor.

If the table cannot be previewed, e.g., it contains LaTeX markup errors, you will see the following message:

<div align="center"><figure><img src="/files/oqRKpTrA2P8qNagE4Npx" alt="&#x22;Sorry, your table can&#x27;t be displayed at the moment&#x22; message" width="375"><figcaption></figcaption></figure></div>

</details>

<details>

<summary>Does the Visual Editor preview borders applied using <span class="math">\LaTeX</span> code?</summary>

Borders created within the tabular environment using `|` in the table’s specification, or `\hline` in the table body will be previewed in **Visual Editor**, as demonstrated by the next example.

```latex
\documentclass{article}
\begin{document}
\begin{table}
\centering
\begin{tabular}{c|c|c}
         R1C1&R1C2& \\
         \hline
         R2C1&  & \\
         \hline
         R3C1 &R3C2 &R3C3\\
\end{tabular}
    \caption{This is my table caption.}
    \label{tab:mynewtable}
\end{table}
\end{document}
```

[Open this example in Overleaf and switch to Visual Editor.](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Creating+table+borders+with+LaTeX+code\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cbegin%7Btable%7D%0A%5Ccentering%0A%5Cbegin%7Btabular%7D%7Bc%7Cc%7Cc%7D%0A+++++++++R1C1%26R1C2%26+%5C%5C%0A+++++++++%5Chline%0A+++++++++R2C1%26++%26+%5C%5C%0A+++++++++%5Chline%0A+++++++++R3C1+%26R3C2+%26R3C3%5C%5C%0A%5Cend%7Btabular%7D%0A++++%5Ccaption%7BThis+is+my+table+caption.%7D%0A++++%5Clabel%7Btab%3Amynewtable%7D%0A%5Cend%7Btable%7D%0A%5Cend%7Bdocument%7D)

Open the code above, then switch to **Visual Editor** to see the following preview:

<div align="center"><figure><picture><source srcset="/files/qZaIoDistdO7kDE61Uqb" media="(prefers-color-scheme: dark)"><img src="/files/vKRmqs2v65B99hpeiF1k" alt="Preview of table with borders" width="375"></picture><figcaption></figcaption></figure></div>

</details>

<details>

<summary>Does the Visual Editor support the <code>booktabs</code> package?</summary>

**Visual Editor** has some support for horizontal rules provided by the [`booktabs` package](https://ctan.org/pkg/booktabs?lang=en). The following example uses the `booktabs` package commands `\toprule`, `\midrule`, and `\bottomrule`.

```latex
\documentclass{article}
\usepackage{booktabs}
\usepackage{hologo} % for the XeTeX logo
\begin{document}
\begin{table}
\begin{tabular}{lcc}
\toprule 
    \TeX{} engine&Year released&Native UTF-8\\
\midrule 
    pdf\TeX&1996&No\\ 
    \hologo{XeTeX}&2004&Yes\\ 
    Lua\TeX&2007&Yes\\
    LuaHB\TeX&2019&Yes\\ 
\bottomrule
\end{tabular}
\end{table}
\end{document}
```

[Open this example in Overleaf and switch to Visual Editor.](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Previewing+a+booktabs+table+in+Visual+Editor\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bbooktabs%7D%0A%5Cusepackage%7Bhologo%7D+%25+for+the+XeTeX+logo%0A%5Cbegin%7Bdocument%7D%0A%5Cbegin%7Btable%7D%0A%5Cbegin%7Btabular%7D%7Blcc%7D%0A%5Ctoprule+%0A++++%5CTeX%7B%7D+engine%26Year+released%26Native+UTF-8%5C%5C%0A%5Cmidrule+%0A++++pdf%5CTeX%261996%26No%5C%5C+%0A++++%5Chologo%7BXeTeX%7D%262004%26Yes%5C%5C+%0A++++Lua%5CTeX%262007%26Yes%5C%5C%0A++++LuaHB%5CTeX%262019%26Yes%5C%5C+%0A%5Cbottomrule%0A%5Cend%7Btabular%7D%0A%5Cend%7Btable%7D%0A%5Cend%7Bdocument%7D)

Open the code above, then switch to **Visual Editor** to see the following preview:

<figure><picture><source srcset="/files/7g30csTput5WyRvNZpcP" media="(prefers-color-scheme: dark)"><img src="/files/tlDnrqTEGNsRxKvU2YQb" alt="Preview of booktabs table" width="375"></picture><figcaption></figcaption></figure>

</details>

<details>

<summary>What if I want more formatting options?</summary>

There are many ways to configure tables that aren’t yet possible using **Visual Editor** generated tables. For more complex formatting you’ll need to use LaTeX code. Read our detailed guidance on [how to create tables using LaTeX](https://www.overleaf.com/learn/latex/Tables).

</details>

## Learn More

* [Tables](https://www.overleaf.com/learn/latex/Tables)
* [Positioning images and tables](https://www.overleaf.com/learn/latex/Positioning_images_and_tables)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.overleaf.com/writing-and-editing/generating-and-inserting-tables.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
