> For the complete documentation index, see [llms.txt](https://overleaf-pro.ayaka.space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://overleaf-pro.ayaka.space/latex/knowledge-base/067-how-to-generate-and-insert-latex-tables-in-overleaf.md).

# How to generate and insert LaTeX tables in Overleaf

## About this article

This article explains how to generate, edit, and insert LaTeX tables using **Visual Editor**, which is one way to generate LaTeX tables in Overleaf. In practice, there are four options to create tables:

1. Using the [**Insert Table** button](#using-insert-table-to-create-a-table-in-your-project) in the **Visual Editor** (or **Code Editor**) toolbar.
2. [Copying and pasting a table](/latex/knowledge-base/075-how-to-paste-formatted-content-into-overleaf.md#pastingtables) from another document while using **Visual Editor**.
3. Writing the [LaTeX code for the table](/latex/figures-and-tables/01-tables.md) in **Code Editor**.
4. Using **Writefull for Overleaf**’s [LaTeX table generator](https://blog.writefull.com/instantly-generate-tables-and-equations-in-writefull-for-overleaf/).

If you’re a confident LaTeX user you'll likely use option 3, which offers the most flexibility for generating tables. If you’re new to LaTeX, using the toolbar in **Visual Editor** (option 1) is a great way to get started and is the focus of this article—you can switch between **Visual Editor** and **Code Editor** to see the code behind the table. As you gain experience, take a look at our detailed guidance on [how to create tables using LaTeX](/latex/figures-and-tables/01-tables.md).

### Contents

Here are the main topics covered in this article.

* [Using Insert Table to create a table in your project](#using-insert-table-to-create-a-table-in-your-project)
* [How to edit or customize an inserted table](#how-to-edit-or-customize-an-inserted-table)
* [How to edit table cells](#how-to-edit-table-cells)
* [How to select one or more columns or rows](#how-to-select-one-or-more-columns-or-rows)
* [How to change the table caption](#how-to-change-the-table-caption)
* [How to add borders to table cells](#how-to-add-borders-to-table-cells)
* [How to change the table’s label](#how-to-change-the-tables-label)
* [How to change the alignment of a table column](#how-to-change-the-alignment-of-a-table-column)
* [How to set the width of table columns](#how-to-set-the-width-of-table-columns)
* [How to change the alignment of a table cell](#how-to-change-the-alignment-of-a-table-cell)
* [How to merge (or unmerge) table cells](#how-to-merge-or-unmerge-table-cells)
* [How to delete a table row or column](#how-to-delete-a-table-row-or-column)
* [How to add new rows or columns](#how-to-add-new-rows-or-columns)
* [FAQs about tables in Visual Editor](#faqs-about-tables-in-visual-editor)

## Using Insert Table to generate a table for your Overleaf project

*Please note: this feature is new and more functionality is planned, so keep checking back to this page to see what else is added. We’d also love your feedback on it, which you can provide in* [*this survey*](https://forms.gle/TYSftBB3dhrjtgFU9)*.*

1. Switch to **Visual Editor** using the toggle above the editor pane (or remain in **Code Editor** if you are comfortable editing LaTeX code).
2. Select the **Insert table** button (![""](/files/U7Y42MqPtqyoedifgcQx)) on the toolbar.

![""](/files/b341gUihXWwTokltKaz3)

4. 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:

![""](/files/y0ctS1yYFdfhlwrs2Mw6)

This short video clip shows a 3 × 3 table being added to a project.

{% embed url="<https://videos.ctfassets.net/nrgyaltdicpt/7F9YTneTbxZAkAoN5vH3oK/7f157cd637b9aca5827beb52cecbb645/TestingTableGenerator.mp4>" %}

8. 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**.

## How to edit or customize an inserted table

### Get to know the table editor menu

In **Visual Editor**, select one or more of your table’s cells to display the table editor menu.

![Image showing the insert table menu](/files/ji7qeGeo4ZhpV0EYKeyN)

Some menu icons remain grayed out (inactive) until you select a suitable range of cells required to complete those actions. For example, you can only merge cells after you’ve selected two or more cells in a row.

Here’s a short summary of the icons and drop-down menus.

* ![""](/files/ejsEG6OMnclnwdt9VmYL) Delete or move the table caption.
* ![""](/files/fRSilGeLWHX61tw8i580) Change the table borders.
* ![""](/files/utXKNUIAshWjlFbswrNP)Set the alignment of a column or merged cell.
* ![Icon for setting the table column width](/files/2Hz9GkUKPWoSy5e04V0s)Adjust column width.
* ![""](/files/bIe6iBL1A7Jt3Ig9acni) Merge cells in a row.
* ![""](/files/bAfLRwJDgDZSc2mW7uaE) Delete rows or columns.
* ![""](/files/9Ncn9MYOmYt6hYLEqlMM)Insert rows and columns.
* ![""](/files/vi2q0d8ixrDF1s3emDe8)Delete the entire table. To restore an accidentally deleted table, use the **Undo** button (![""](/files/XbmOhsbIFYrbcbQU2bEF)) on the toolbar located above the Visual Editor and Code Editor.
* ![""](/files/RO2NSzKQDpkF1jTQu6jo)Get help.
* ![""](/files/hDBir490KMTGG6Xy6ZzE)Send feedback to Overleaf.

## How to edit table cells

There are two ways to start editing a cell:

1. Double-click on the cell you want to edit.
2. Use the tab or arrow keys to navigate to a particular cell, then press Enter.

Here are some tips for editing cell content using **Visual Editor**:

* Use LaTeX commands, not the toolbar, to apply bold or italic styles to cell text:
* use [`\textbf{...}`](/latex/latex-basics/03-bold-italics-and-underlining.md#bold-text) for **bold** text.
* use [`\textit{...}`](/latex/latex-basics/03-bold-italics-and-underlining.md#italicized-text) for *italic* text.
* use `\textbf{... \textit{...}...}` for text in ***bold italic***.
* Cells can contain [inline mathematics](https://learn.overleaf.com/learn/Mathematical_expressions#Inline_math_mode) via `\( ... \)`.

**Visual Editor** will preview the styled text and inline math.

#### Example: styled text and math in table cells

The next screenshot shows **Visual Editor** previewing the following cell content

* `\(\sqrt{a^2+b^2}\)`
* `\textbf{bold}, \textit{italic}, \textbf{\textit{bold italic}}`

![""](/files/k23fUOQOIqBu7jtrWDZ4)

## How to select one or more columns or rows

1. Use the row or column selectors to select a particular row or column.
2. Hold down the Shift key to select multiple rows or columns.

![""](/files/duw72Rfcn0C2cwtA2xRE)

You can also select multiple rows or columns by clicking on (selecting) a cell and dragging the selection (mouse) pointer.

## How to change the table caption

### To edit the caption text

1. Click on the default caption text, which is the word **Caption.**

![""](/files/PSfJoHBkaUQSHsFdtXST)

3. The LaTeX `\caption` command is displayed.
4. Add your preferred caption between the braces `{...}`

![""](/files/2KyfnflDH3Y5bGDDJSPZ)

### To remove the caption or place it above or below the table

* Select any table cell to display the table editor menu.
* From the caption drop-down menu, select your preferred option:
* **No caption**: Remove it.
* **Caption above**: Place the caption above the table.
* **Caption below**: Place the caption below the table.

![""](/files/pqn7QOHaVplbs8ncgN5Q)

* **Note**: The caption dropdown is disabled if the [`tabular`](/latex/figures-and-tables/01-tables.md#creating-a-simple-table-in-latex) [environment](/latex/commands/02-environments.md) is not directly inside a [`table` environment](/latex/figures-and-tables/01-tables.md#positioning-tables). This is demonstrated by the following example in which the `tabular` environment is directly inside a `center` environment.

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

[Open this example in Overleaf and switch to Visual Editor.](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=A+tabular+not+immediately+inside+a+table\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bhologo%7D+%25+for+the+XeTeX+logo%0A%5Cbegin%7Bdocument%7D%0A%5Cbegin%7Bcenter%7D%0A%5Cbegin%7Btabular%7D%7Blcc%7D%0A%5Chline%0A++++%5CTeX%7B%7D+engine%26Year+released%26Native+UTF-8%5C%5C%0A%5Chline%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%5Chline%0A%5Cend%7Btabular%7D%0A%5Cend%7Bcenter%7D%0A%5Cend%7Bdocument%7D)

If you open the code above in Overleaf then switch to Visual Editor you’ll see the caption dropdown is greyed out (disabled):

![""](/files/FuunXUOmtHMp50jq4tB7)

## How to add borders to table cells

At the moment, **Visual Editor** provides basic support for borders, accessible from the borders drop-down menu which currently has two user-selectable options:

* **All borders**: All cells have a border.
* **No borders**: No cells have a border.

![""](/files/s0KMJMCnXZj8gMeOQhzN)

A table inserted from the toolbar starts with the **No borders** option. If you [add borders using LaTeX code](#does-visual-editor-preview-borders-applied-using-latex-code) the button will display **Custom borders**.

## How to change the table’s label

1. Click on the default label text `tab:my_label.`
2. The LaTeX `\label` command is displayed.
3. Add your preferred label between the braces {...}.

![""](/files/hOLKmjEHVyc6mJdcv5tH)

The label text is an identifier used to reference this table elsewhere in your document. You can read more about using labels in our [article on cross-referencing](/latex/more-topics/27-inserting-images.md#labels-and-cross-references).

## How to change the alignment of a table column

Table columns can be right-, left-, or center-aligned. Follow these steps to change a column’s alignment:

1. [Select the column(s)](#how-to-select-one-or-more-columns-or-rows) whose alignment you want to change.
2. The alignment icon (![""](/files/utXKNUIAshWjlFbswrNP)) becomes active.
3. Select the drop-down menu then choose the preferred alignment: left, centered, or right.
4. The following screenshot shows how to right-align all cells in column 1 of a table:

![""](/files/JRbiKid84lkUEPkfqc9p)

## How to set the width of table columns

Changes made to table column width settings will affect the *typeset table* only, not the *preview* provided by **Visual Editor**. You need to recompile your document to see the result of any changes made to column widths.

Follow these steps to set column width(s) to a fixed value, or allow the width(s) to vary according to the content in the column cells.

1. [Select the column(s)](#how-to-select-one-or-more-columns-or-rows) whose width you want to change. The column width icon (![Icon for setting the table column width](/files/2Hz9GkUKPWoSy5e04V0s)) is then enabled.
2. Select the drop-down menu:

![Menu options showing the width options](/files/355meEytJm1lOE2HOeHM)

4. Choose the preferred option for the selected column(s):

* **Stretch width to text:** this option allows the typeset column width(s) to be determined by the amount of content contained in the column's cells; e.g., the width of typeset text or mathematics.
* **Fixed width, wrap text**: sets the width of the column(s) to a fixed value which causes line breaking (text wrapping) within column cells. Selecting this option displays the **Set column width** window used to set fixed column width(s), as explained in the next section.

![Modal window used to set a fixed column width](/files/yjInj3uCyn0tUlo8XZnz)

### How to set a fixed column width

The **Set column width** pop-up window provides a drop-down list containing three ways to set fixed columns-widths:

* As a percentage (**%**) of the current environment's line width: the table column widths might then vary according to where the table is used (see [example below](#example-using-percentage-of-line-width)).
* Using explicit widths expressed in units of millimeters (mm), centimeters (cm), [inches](https://en.wikipedia.org/wiki/Inch) (in) or [points](https://en.wikipedia.org/wiki/Point_\(typography\)) (pt).
* A **Custom** option using LaTeX commands to calculate the width ([see example below](#example-using-custom-commands)).

The following image shows how **Visual Editor** uses a small icon to indicate columns with a fixed width. You can edit the fixed-width setting by selecting (clicking) the icon to display the **Set column width** window.

![Image showing how Visual Editor highlights fixed width columns](/files/vr6x1worJH1WBNYAXLBO)

### Example: using percentage of line width

The LaTeX command `\linewidth` holds the value of the current line width, which varies based on the document format, such as single-column or double-column layouts. Additionally, the value of `\linewidth` can change in specific environments, e.g., within a `minipage`.

This example uses the `multicol` package to typeset two identical tables with column widths set to `0.25\linewidth`. One table is typeset in a single-column section, the other in a two-column section, demonstrating how changes to `\linewidth` affects the table column widths.

```latex
\documentclass{article}
\usepackage{array}
\usepackage{multicol}
\begin{document}
\section{Section with a single column}
This part of the page is a single column with \verb|\linewidth|=\the\linewidth.\vskip12pt

\begin{tabular}{|p{0.25\linewidth}|p{0.25\linewidth}|}
\hline
A & B\\
\hline
C & D \\
\hline
\end{tabular}

\vskip12pt \noindent We now typeset the same table in a two-column section.
\begin{multicols}{2}
[
\section{Section with two columns}
]
Here, \verb|\linewidth|=\the\linewidth. The table column widths are smaller.

\begin{tabular}{|p{0.25\linewidth}|p{0.25\linewidth}|}
\hline
A & B\\
\hline
C & D \\
\hline
\end{tabular}
\end{multicols}
\end{document}
```

[Open this example in Overleaf and switch to Visual Editor.](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Using+line+width+to+set+table+column+widths\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Barray%7D%0A%5Cusepackage%7Bmulticol%7D%0A%5Cbegin%7Bdocument%7D%0A%5Csection%7BSection+with+a+single+column%7D%0AThis+part+of+the+page+is+a+single+column+with+%5Cverb%7C%5Clinewidth%7C%3D%5Cthe%5Clinewidth.%5Cvskip12pt+%0A%0A%5Cbegin%7Btabular%7D%7B%7Cp%7B0.25%5Clinewidth%7D%7Cp%7B0.25%5Clinewidth%7D%7C%7D%0A%5Chline%0AA+%26+B%5C%5C%0A%5Chline%0AC+%26+D+%5C%5C%0A%5Chline%0A%5Cend%7Btabular%7D%0A%0A%5Cvskip12pt+%5Cnoindent+We+now+typeset+the+same+table+in+a+two-column+section.%0A%5Cbegin%7Bmulticols%7D%7B2%7D%0A%5B%0A%5Csection%7BSection+with+two+columns%7D%0A%5D%0AHere%2C+%5Cverb%7C%5Clinewidth%7C%3D%5Cthe%5Clinewidth.+The+table+column+widths+are+smaller.%0A%0A%5Cbegin%7Btabular%7D%7B%7Cp%7B0.25%5Clinewidth%7D%7Cp%7B0.25%5Clinewidth%7D%7C%7D%0A%5Chline%0AA+%26+B%5C%5C%0A%5Chline%0AC+%26+D+%5C%5C%0A%5Chline%0A%5Cend%7Btabular%7D%0A%5Cend%7Bmulticols%7D%0A%5Cend%7Bdocument%7D)

This example produces the following output:

![Example document](/files/dh8rA8OBCOD8NAUb9njA)

### Example: using custom commands

The **Custom** option lets you set column widths using a wider range of units including [`em`, `ex` and `sp`](/latex/formatting/01-lengths-in-latex.md) together with LaTeX commands—provided those commands produce a valid width value in units LaTeX understands.

The next example demonstrates just a few of the many ways you can use the **Custom** option to set column widths, including use of the units `em` and `ex`, simple arithmetic expressions and more advanced calculations using LaTeX commands. The`\dimexpr` ("dimension expression") command is used to perform arithmetic operations on LaTeX lengths (also called dimensions) using addition, subtraction, multiplication, or division. In essence, `\dimexpr` enables use of dynamically-calculated lengths, including the width of table columns.

```latex
\documentclass{article}
\usepackage{array}
\begin{document}
\newdimen\mydim
\mydim=1.25cm
\newcommand{\Acol}{\dimexpr 1cm + 0.1in + 3pt + 2.5mm\relax}
\newcommand{\Bcol}{0.1\linewidth}

\begin{itemize}
    \item Width of column 1: 4em=\the\dimexpr 4em\relax
    \item Width of column 2: 3ex=\the\dimexpr 3ex\relax
    \item Width of column 3: \verb|\Acol| sets a width of \the\dimexpr 1cm + 0.1in + 3pt + 2.5mm\relax
    \item Width of column 4: \verb|\Bcol| sets a width of \the\dimexpr0.1\linewidth\relax
    \item Width of column 5: \verb|\dimexpr0.25\linewidth+2cm-\mydim\relax| sets a width of \the\dimexpr0.2\linewidth+2cm-\mydim\relax
\end{itemize}

\begin{table}
\centering
\caption{Using \LaTeX{} commands and units to set column widths}
\begin{tabular}{|p{4em}|p{3ex}|p{\Acol}|p{\Bcol}|p{\dimexpr0.2\linewidth+2cm-\mydim\relax}|}
\hline
A & B &C & D&E\\
\hline
F& G&H& I&J\\
\hline
\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=Using+LaTeX+commands+to+set+table+column+widths\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Barray%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cnewdimen%5Cmydim%0A%5Cmydim%3D1.25cm%0A%5Cnewcommand%7B%5CAcol%7D%7B%5Cdimexpr+1cm+%2B+0.1in+%2B+3pt+%2B+2.5mm%5Crelax%7D%0A%5Cnewcommand%7B%5CBcol%7D%7B0.1%5Clinewidth%7D%0A%0A%5Cbegin%7Bitemize%7D%0A++++%5Citem+Width+of+column+1%3A+4em%3D%5Cthe%5Cdimexpr+4em%5Crelax%0A++++%5Citem+Width+of+column+2%3A+3ex%3D%5Cthe%5Cdimexpr+3ex%5Crelax%0A++++%5Citem+Width+of+column+3%3A+%5Cverb%7C%5CAcol%7C+sets+a+width+of+%5Cthe%5Cdimexpr+1cm+%2B+0.1in+%2B+3pt+%2B+2.5mm%5Crelax%0A++++%5Citem+Width+of+column+4%3A+%5Cverb%7C%5CBcol%7C+sets+a+width+of+%5Cthe%5Cdimexpr0.1%5Clinewidth%5Crelax%0A++++%5Citem+Width+of+column+5%3A+%5Cverb%7C%5Cdimexpr0.25%5Clinewidth%2B2cm-%5Cmydim%5Crelax%7C+sets+a+width+of+%5Cthe%5Cdimexpr0.2%5Clinewidth%2B2cm-%5Cmydim%5Crelax%0A%5Cend%7Bitemize%7D%0A%0A%5Cbegin%7Btable%7D%0A%5Ccentering%0A%5Ccaption%7BUsing+%5CLaTeX%7B%7D+commands+and+units+to+set+column+widths%7D%0A%5Cbegin%7Btabular%7D%7B%7Cp%7B4em%7D%7Cp%7B3ex%7D%7Cp%7B%5CAcol%7D%7Cp%7B%5CBcol%7D%7Cp%7B%5Cdimexpr0.2%5Clinewidth%2B2cm-%5Cmydim%5Crelax%7D%7C%7D%0A%5Chline%0AA+%26+B+%26C+%26+D%26E%5C%5C%0A%5Chline%0AF%26+G%26H%26+I%26J%5C%5C%0A%5Chline%0A%5Cend%7Btabular%7D%0A%5Cend%7Btable%7D%0A%5Cend%7Bdocument%7D)

This example produces the following output:

![Using LaTeX commands to set table column widths](/files/ZfJMFRJwiFo1R7OYrny8)

## How to change the alignment of a table cell

* The alignment of individual, *non-merged*, cells can’t be changed in **Visual Editor**.
* The content of *merged* cells can be aligned (see the section [Merging two or more cells in a table row](#merging-two-or-more-cells-in-a-table-row)).

## How to merge (or unmerge) table cells

Table cells can be merged, horizontally, within a table *row*, but not vertically within a table column.

### Merging two or more cells in a table row

1. Select the cells you want to merge.
2. Select the **Merge cells** icon (![""](/files/bIe6iBL1A7Jt3Ig9acni)) to merge the cells.
3. Optionally, you can change the alignment of the merged cells.

### Unmerging two or more merged cells

1. Select the merged cell.
2. Select the **Merge cells** icon (![""](/files/bIe6iBL1A7Jt3Ig9acni)) to unmerge the cells.

The following video demonstrates merging three cells in a table row, changing alignment of the merged cell and unmerging the cell content.

{% embed url="<https://videos.ctfassets.net/nrgyaltdicpt/2g1bZr5H5PdCBdrD6MqXPN/7813a6c42b2ecbd4ac7cbb4a412b863c/MergingCells.mp4>" %}

* **Note**: All content contained in the merged cell is placed in the first cell of the unmerged set.

## How to delete a table row or column

1. [Select the rows or columns](#how-to-select-one-or-more-columns-or-rows) you want to delete.
2. Select the **Delete row or column** icon (![""](/files/bAfLRwJDgDZSc2mW7uaE)) to delete the selected rows or columns.

## How to add new rows or columns

The **Insert** button (![""](/files/9Ncn9MYOmYt6hYLEqlMM)) lets you add one or more new rows or columns before or after a selected location.

If you want to insert *m* rows and *n* columns, select an *m* × *n* group of cells covering the locations where you want to insert those rows and columns.

**Example**: In the following screenshot, a 3 × 2 group of cells straddling 3 rows and 2 columns has been selected.

![""](/files/AuBKUKgyKH5ME8vYfJwS)

* Selecting ![""](/files/9Ncn9MYOmYt6hYLEqlMM) provides the following options:

![""](/files/J1kkB0Vr65qf1BZ7hYI4)

* You can now insert any of the following:
* 2 columns to the left of column 1
* 2 columns to the right of column 2
* 3 rows above row 1
* 3 rows below row 3

## FAQs about tables in Visual Editor

### What if I want more formatting options?

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](/latex/figures-and-tables/01-tables.md).

### Can the Visual Editor preview tables I create using the Code Editor?

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:

![""](/files/5ZYSGAylt6BxqvwZrV8J)

### Does Visual Editor support the booktabs package?

**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:

![""](/files/jvDntHKlSRA0mVHmyLkL)

### Does Visual Editor preview borders applied using LaTeX code?

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:

![""](/files/8gGFHfvGgp0TkaMbTU6m)


---

# 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, and the optional `goal` query parameter:

```
GET https://overleaf-pro.ayaka.space/latex/knowledge-base/067-how-to-generate-and-insert-latex-tables-in-overleaf.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
