This article explains how to create and edit tables using Visual Editor, which is one way to produce tables in Overleaf. In practice, there are three options to create tables:
If you’re a confident LaTeX user you'll likely use option 3, which offers the most flexibility for creating 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.
Here are the main topics covered in this article.
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.
This short video clip shows a 3 × 3 table being added to a project.
In Visual Editor, select one or more of your table’s cells to display the table editor menu.
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.
There are two ways to start editing a cell:
Here are some tips for editing cell content using Visual Editor:
Visual Editor will preview the styled text and inline math.
The next screenshot shows Visual Editor previewing the following cell content
You can also select multiple rows or columns by clicking on (selecting) a cell and dragging the selection (mouse) pointer.
\documentclassarticle> \usepackagehologo> % for the XeTeX logo \begindocument> \begincenter> \begintabular>lcc> \hline \TeX<> engine&Year released&Native UTF-8\\ \hline pdf\TeX&1996&No\\ \hologoXeTeX>&2004&Yes\\ Lua\TeX&2007&Yes\\ LuaHB\TeX&2019&Yes\\ \hline \endtabular> \endcenter> \enddocument>
If you open the code above in Overleaf then switch to Visual Editor you’ll see the caption dropdown is greyed out (disabled):
At the moment, Visual Editor provides basic support for borders, accessible from the borders drop-down menu which currently has two user-selectable options:
A table inserted from the toolbar starts with the No borders option. If you add borders using LaTeX code the button will display Custom borders.
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.
Table columns can be right-, left-, or center-aligned. Follow these steps to change a column’s alignment:
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.
The Set column width pop-up window provides a drop-down list containing three ways to set fixed columns-widths:
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.
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.
\documentclassarticle> \usepackagearray> \usepackagemulticol> \begindocument> \sectionSection with a single column> This part of the page is a single column with \verb|\linewidth|=\the\linewidth.\vskip12pt \begintabular>|p0.25\linewidth>|p0.25\linewidth>|> \hline A & B\\ \hline C & D \\ \hline \endtabular> \vskip12pt \noindent We now typeset the same table in a two-column section. \beginmulticols>2> [ \sectionSection with two columns> ] Here, \verb|\linewidth|=\the\linewidth. The table column widths are smaller. \begintabular>|p0.25\linewidth>|p0.25\linewidth>|> \hline A & B\\ \hline C & D \\ \hline \endtabular> \endmulticols> \enddocument>
This example produces the following output:
The Custom option lets you set column widths using a wider range of units including em , ex and sp 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.
\documentclassarticle> \usepackagearray> \begindocument> \newdimen\mydim \mydim=1.25cm \newcommand\Acol>\dimexpr 1cm + 0.1in + 3pt + 2.5mm\relax> \newcommand\Bcol>0.1\linewidth> \beginitemize> \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 \enditemize> \begintable> \centering \captionUsing \LaTeX<> commands and units to set column widths> \begintabular>|p4em>|p3ex>|p\Acol>|p\Bcol>|p\dimexpr0.2\linewidth+2cm-\mydim\relax>|> \hline A & B &C & D&E\\ \hline F& G&H& I&J\\ \hline \endtabular> \endtable> \enddocument>
This example produces the following output:
Table cells can be merged, horizontally, within a table row, but not vertically within a table column.
The following video demonstrates merging three cells in a table row, changing alignment of the merged cell and unmerging the cell content.
The Insert button ( ) 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.
Selecting provides the following 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.
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:
Visual Editor has some support for horizontal rules provided by the booktabs package. The following example uses the booktabs package commands \toprule , \midrule , and \bottomrule .
\documentclassarticle> \usepackagebooktabs> \usepackagehologo> % for the XeTeX logo \begindocument> \begintable> \begintabular>lcc> \toprule \TeX<> engine&Year released&Native UTF-8\\ \midrule pdf\TeX&1996&No\\ \hologoXeTeX>&2004&Yes\\ Lua\TeX&2007&Yes\\ LuaHB\TeX&2019&Yes\\ \bottomrule \endtabular> \endtable> \enddocument>
Open the code above, then switch to Visual Editor to see the following preview:
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.
\documentclassarticle> \begindocument> \begintable> \centering \begintabular>c|c|c> R1C1&R1C2& \\ \hline R2C1& & \\ \hline R3C1 &R3C2 &R3C3\\ \endtabular> \captionThis is my table caption.> \labeltab:mynewtable> \endtable> \enddocument>
Open the code above, then switch to Visual Editor to see the following preview: