Javatpoint Logo
Javatpoint Logo


The tables are common feature used in academic writing. This topic will explain the steps to create the table and perform different functions in the table. Tables are an efficient way to represent the information and are often used in most of the documents or files. When discussing the scientific papers, the tables are used to present the data.

Creating the table in Latex is a little complicated compared to others. But here, the steps and the process to create a table from the basics will make the process easier.

The Latex is not a spreadsheet, but it is a dedicated tool to build tables and to export these tables to your document.

The tables in Latex are created with a combination of a tabular environment and the table environment. The tabular environments contain the actual content of the table, while others include the caption.

The commands used to create table environment are:




The commands used to create tabular environment are:




Here, the table signifies the tabular environment, together with the \caption command. The command where is used to determine the location for the table. For example, \begin{table}{t} means, the table will appear at the top of the page.

The tabular environment uses & (ampersands) symbol for the column separation.

The letters used to align the content to the left, center, and right are l, c, and r for each of the columns. The command passed for aligning is \begin{tabular}{l c r}.

The command used to draw vertical lines separating the columns of the table is \begin{tabular}{l|c|r}, where the (|) is passed as an argument. The | symbol is used to draw the vertical lines between the columns.

You can also use the \vline command to draw vertical lines. The \vline command draws the vertical line along with the height of the row.

If we want to draw a horizontal line as a row separator, then we can use the \hline command.

The command \cline{i-j} is used to draw the partial horizontal line beginning with i and ending with j.

Let's consider few examples of a table by using the commands discussed above.










Now, look at the below code for creating a basic table:



  • \label command is used as the marker of the table or to label the table.
  • \caption is included in the table itself.

In place of \begin{center}… \end{center}, the \centering command at the beginning of the document\table can be used.



Combined Rows and Columns

For the combined columns, the\multicolumn{num}{col}{text} command is used. The num command is used to combine the num columns into a single column along with the width. The command col contains the symbols l, c, or r. The text contains the content for the column.

For combined rows \raisedbox{lift}{text} command is used. It prints the text, which is raised above the current baseline by the amount of the lift. For the single space between the rows, the [-lex] command is used. For the double space between the first and the second rows, the [1ex] command is used.

You can also align many identical columns by using the *{num}{str} syntax. It is useful when your table has many columns. The command will be written as:


Let's consider an example. The code is written below:



You can also change the mode to the landscape mode by using the \usepackage{adjustbox} command.

The table here begins with the \begin{adjustbox} and ends with the \end{adjustbox}.

Let's consider a simple example of a table to understand this.

The code is given below:



For example, if we set the angle to 150 degrees in the same code as mentioned above, the output will look like the image given below:


Some common commands used for the creation of a table are explained below:

  • array: It adds columns m{<width>} and b{<width>} similar to the p command, but vertically aligned to the center or the bottom.
  • bookstab: It provides creative commands for a horizontal line with the spacing above and below.
  • tabularx: It introduces the column type X, which works like the p- command with an automatic width calculating feature.
  • \raggedright: It is recognized as the end of the table rows.
  • \tabularnewline: This command is used instead of \\.
  • \arraybackslash: It is used for the restoration process.

For the space between columns the \setlength{\tabcolsep}{5pt} command is used. The default size is 6pt. This command is inserted between the columns for spacing.

For the space between rows, the \arraystretch command is used.

Text Wrapping in Tables

Latex algorithms have some shortcomings. If the text overruns the width of the page, Latex does not adjust/wraps the text automatically. For this purpose, special command p (predefined width) is used to set the width.

The example is given below.

This example explains both the processes that are without setting the width and with the width. You can notice the difference between these two methods.

  • First process (without specifying the width}

The code is given below:



You can notice, that the information is not displayed because the width is not specified.

  • Now consider the second process, where the width is specified using the p The code is given below:



Multirow and Multicolumn

It is used to format the data, which contain several rows and columns. In this, multiple rows are split into subrows using the multirow package.

Note:The column wrapping within the multirow environment will not work with the syntax used.

Let's understand with an example. The code is given below:



You can draw as much lines using the \hline command. Consider the similar image as the above with more lines:


Tables with booktabs

The booktabs command is used to make the document much professional because the \hline command doesn’t do so. The commands such as toprule, midrule, and bottomrule provided by the bookstab package are used instead of the \hline command.

The code for the bookstab package is given below:



Multipage Tables

If your table contains multiple rows, then the table will be cropped from the bottom. The commandlongtable is used to make span numerous pages, which has to be added to the package.

There is no use of a table or tabular commands when the longtable command is in use. It replaces the use of tables and tabular command and combines both environments into a single environment. Thus, instead, the environment longtable is used for the tables.

The code for the above topic is given below:


  • \endfirsthead: It is the line that appears as the head of the table on the first page.
  • \endhead: A line which appears at the top of every page except first
  • \endfoot: A line which appears at the bottom of every page except last
  • \endlastfoot: It is the line which appears at the end of the table


The output for the above code will be listed in two pages, as shown below:

The two pages are divides into three images.

The images are given below:


You can notice that the table was divided into multiple pages using the longtable column, without any loss of data.

Aligning the decimal point

The example discussed below will align the expression and the corresponding value according to its decimal point.

The code is given below:



Tabular Material

The two environments are used for the tabular material namely tabbing environment (\begin{tabbing}…\end{tabbing}) and tabular environment (\begin{tabular}…\end{tabular}).

The tabular allows making a fancy environment with commands used to draw the horizontal and vertical lines. However, the table cannot be broken into pages. For that purpose, the table command is used to break the table into multiple pages, as discussed above.

The tabbing environment is used to set the tabs, behaving similarly to the typewriter. The set tabs then move from one to another. Since each line in the tabbing environment is processed individually, the page breaks are allowed within the tabbing.

The commands used for the tabbing are listed below:

  • \= set a tab stop
  • \> move right to the next tab stop
  • \\ terminates a line
  • \kill a line ending with this command is used to set the tab, but not to print that line

The two examples of the tabbing environment are given below:

1. The code for this example is given below:

Here, we have used two \\ for the two new lines.



2. The code for the second example is given below:


Next TopicLatex Colors

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA