LaTeX tables – Tutorial with code examples | (2023)

Learn to create tables in LaTeX including all features such as multi row, multi column, multi page and landscape tables. All in one place.

  1. Your first table / table template
  2. Align numbers at decimal point
  3. Adding rows and columns
  4. Cells spanning multiple rows and multiple columns
    1. Using multirow
    2. Using multicolumn
    3. Combining multirow and multicolumn
  5. Prettier tables with booktabs
  6. Tables spanning multiple pages
  7. Landscape / sideways tables
  8. Tables from Excel (.csv) to LaTeX

In this tutorial we’re going to learn how to use the table and tabularenvironments to create tables in LaTeX. At first we’re going to create a simple table like this:

LaTeX tables – Tutorial with code examples | (1)

After showing you how to modify this table according to your needs, I will also show you how to make your tables prettier and turn the table above into this:

LaTeX tables – Tutorial with code examples | (2)

Of course it’s up to your personal preference, but most of the time, I’ve found that the second table is much more readable and easier on the eye than the first table.

Afterwards I’m also going to show you, how to do some more elaborate things such as having rows and colums spend multiple cells as well as orienting tables sideways on the page (useful for tables with many columns) and how to have tables span multiple pages (useful for tables with many rows).

I’ve also created a tool to edit LaTeX tables right in your browser. This feature is still experimental, but if you want to try it, you can find it here. I appreciate anyfeedback, so I can create a tool that you love using.

Your first table

Tables in LaTeX can be created through a combination of the tableenvironment and the tabular environment.The table environment part contains the caption and defines the float for our table, i.e. where in our document the table should be positioned and whether we want it to be displayed centered. The \caption and \label commands can be used in the same way as for pictures.The actual content of the table is contained within the tabular environment.

The tabular environment usesampersands & as column seperators and newline symbols \\ as row seperators. The vertical lines separating the columns of our table (|) are passed as an argument to the tabular environment (e.g.\begin{tabular}{l|c|r}) and the letters tell whether we want to align the content to the left (l), to the center (c) or to the right (r) for each column. There should be one letter for every column and a vertical line in between them or in front of them, if we want a vertical line to be shown in the table.Row seperators can be added with the \hline command.

Now let’s take a look at some actual code for a basic table, which you can easily copy-and-paste into your document and modify it to your needs.

\documentclass{article}\begin{document}\begin{table}[h!] \begin{center} \caption{Your first table.} \label{tab:table1} \begin{tabular}{l|c|r} % <-- Alignments: 1st column left, 2nd middle and 3rd right, with vertical lines in between \textbf{Value 1} & \textbf{Value 2} & \textbf{Value 3}\\ $\alpha$ & $\beta$ & $\gamma$ \\ \hline 1 & 1110.1 & a\\ 2 & 10.1 & b\\ 3 & 23.113231 & c\\ \end{tabular} \end{center}\end{table}\end{document}

The above code will print out the table which I’ve already shown you in the introduction and it looks like this:

LaTeX tables – Tutorial with code examples | (3)

While this table already works, it’s not very satisfying and readable that the numbers in the center column are not aligned at the decimal point. Fortunately, we don’t have to add spacing somehow manually, but we can use the siunitx package for this purpose.

Align numbersat decimal point

The first thing we have to do is to include the siunitx package in our preamble and use the command \sisetupto tell the package how many digital places it should display:

%...\usepackage{siunitx} % Required for alignment\sisetup{ round-mode = places, % Rounds numbers round-precision = 2, % to 2 places}\begin{document} %...

Afterwards we can use a new alignment setting in our tables, so besides left (l), center (c) andright (r), there’s now an additional setting S, which will align the numbers automatically. In our previous table, there was an alignment problem with the middle column, so I’ve now changed the alignment setting of the middle column from (c) to (S):

%...\begin{table}[h!] \begin{center} \caption{Table with aligned units.} \label{tab:table1} \begin{tabular}{l|S|r} % <-- Changed to S here. \textbf{Value 1} & \textbf{Value 2} & \textbf{Value 3}\\ $\alpha$ & $\beta$ & $\gamma$ \\ \hline 1 & 1110.1 & a\\ 2 & 10.1 & b\\ 3 & 23.113231 & c\\ \end{tabular} \end{center}\end{table}%...

We can now observe, that LaTeX will now properly align the numbers at their decimal points and round the numbers to two decimal places:

LaTeX tables – Tutorial with code examples | (4)

Adding rows and columns

Now that we’ve setup our table properly, we can focus on adding more rows and columns. As I’ve mentioned before, LaTeX usescolumn separators (&) and row separators (\\) to layout the cells of our table. For the 5×3 table shown abovewe can count fivetimes (\\) behind each row and twotimes (&) per row, separating the content of three columns.

If we now want to add an additional column, it’s as simple as copy and pasting the previous column and changing the contents. I will be reusing the table from above for this example and add an additional column:

%...\begin{table}[h!] \begin{center} \caption{More rows.} \label{tab:table1} \begin{tabular}{l|S|r} \textbf{Value 1} & \textbf{Value 2} & \textbf{Value 3}\\ $\alpha$ & $\beta$ & $\gamma$ \\ \hline 1 & 1110.1 & a\\ 2 & 10.1 & b\\ 3 & 23.113231 & c\\ 4 & 25.113231 & d\\ % <-- added row here \end{tabular} \end{center}\end{table}%...

This will generate the following output:

LaTeX tables – Tutorial with code examples | (5)

Adding an additional column is also possible, but you have to be careful, because you have to add a column separator (&) to every column:

%...\begin{table}[h!] \begin{center} \caption{More columns.} \label{tab:table1} \begin{tabular}{l|S|r|l} \textbf{Value 1} & \textbf{Value 2} & \textbf{Value 3} & \textbf{Value 4}\\ % <-- added & and content for each column $\alpha$ & $\beta$ & $\gamma$ & $\delta$ \\ % <-- \hline 1 & 1110.1 & a & e\\ % <-- 2 & 10.1 & b & f\\ % <-- 3 & 23.113231 & c & g\\ % <-- \end{tabular} \end{center}\end{table}%...

We will now see an additional column in our output:

LaTeX tables – Tutorial with code examples | (6)

Cells spanning multiplerows ormultiple columns

  1. Using multirow
  2. Using multicolumn
  3. Combining multirow and multicolumn

Sometimes it’s necessary to make a row span several cells. For this purpose we can use the multirow package, so the first thing we’re going to do is adding the required package to our preamble:

%...\usepackage{multirow} % Required for multirows\begin{document} %...

We can now use multirow and multicolumn environments, which allow us to conveniently span multiple rows or columns.

Using multirow

In order for a cell to span multiple rows, we have to use the multirow command. This command accepts three parameters:


I usually use an asterisk (*) as a parameter for the width, since this basically means, that the width should be determined automatically.

Because we’re combining two rows in our example, it’s necessary to omit the content of the same row in the following line. Let’s look at how the actual LaTeX code would look like:

%...\begin{table}[h!] \begin{center} \caption{Multirow table.} \label{tab:table1} \begin{tabular}{l|S|r} \textbf{Value 1} & \textbf{Value 2} & \textbf{Value 3}\\ $\alpha$ & $\beta$ & $\gamma$ \\ \hline \multirow{2}{*}{12} & 1110.1 & a\\ % <-- Combining 2 rows with arbitrary with (*) and content 12 & 10.1 & b\\ % <-- Content of first column omitted. \hline 3 & 23.113231 & c\\ 4 & 25.113231 & d\\ \end{tabular} \end{center}\end{table}%...

The modified table looks like this:

LaTeX tables – Tutorial with code examples | (7)

You can now see, that the cell containing 12spans two rows.

Using multicolumn

If we want a cell to span multiple columns, we have to use the multicolumncommand. The usage differs a bit from multirow command, since we also have to specifiy the alignment for our column. The command also requires three parameters:


In our example, we will again combine two neighboring cells, note that in the row where we’re using multicolumn to span two columns, there’s only one column separator (&) (instead of two for all other rows):

%...\begin{table}[h!] \begin{center} \caption{Multicolumn table.} \label{tab:table1} \begin{tabular}{l|S|r} \textbf{Value 1} & \textbf{Value 2} & \textbf{Value 3}\\ $\alpha$ & $\beta$ & $\gamma$ \\ \hline \multicolumn{2}{c|}{12} & a\\ % <-- Combining two cells with alignment c| and content 12. \hline 2 & 10.1 & b\\ 3 & 23.113231 & c\\ 4 & 25.113231 & d\\ \end{tabular} \end{center}\end{table}%...

This will result in the following content:

LaTeX tables – Tutorial with code examples | (8)

Combining multirow and multicolumn

Of course it’s also possible to combine the two features, to make a cell spanning multiple rows and columns. To do this, we simply use the multicolumn command and instead of specifying content, we add a multirow command as the content. We then have to add another multicolumn statement for as many rows as we’re combining.

Because this is a little hard to explain, it will be much clearer when looking at the code. In this example, we’re going to combine two columns and two rows, so we’re getting a cell spanning a total of four cells:

%...\begin{table}[h!] \begin{center} \caption{Multirow and -column table.} \label{tab:table1} \begin{tabular}{l|S|r} \textbf{Value 1} & \textbf{Value 2} & \textbf{Value 3}\\ $\alpha$ & $\beta$ & $\gamma$ \\ \hline \multicolumn{2}{c|}{\multirow{2}{*}{1234}} & a\\ % <-- Multicolumn spanning 2 columns, content multirow spanning two rows \multicolumn{2}{c|}{} & b\\ % <-- Multicolumn spanning 2 columns with empty content as placeholder \hline 3 & 23.113231 & c\\ 4 & 25.113231 & d\\ \end{tabular} \end{center}\end{table}%...

Our document will now contain a table, with a huge cell:

LaTeX tables – Tutorial with code examples | (9)

Prettier tables with booktabs

Of course beauty is always in the eye of the beholder, but I personally think, that the default hlinesused by the table environment are not very pretty. For my tables, i always use the booktabs package, which provides much prettier horizontal separators and the usage is not harder compared to simply using hlines.

Again, we have to add the according booktabs package to our preamble:

%...\usepackage{booktabs} % For prettier tables\begin{document} %...

We can now replace the hlines in our example table with toprule, midrule and bottomrule provided by the booktabs package:

%...\begin{table}[h!] \begin{center} \caption{Table using booktabs.} \label{tab:table1} \begin{tabular}{l|S|r} \toprule % <-- Toprule here \textbf{Value 1} & \textbf{Value 2} & \textbf{Value 3}\\ $\alpha$ & $\beta$ & $\gamma$ \\ \midrule % <-- Midrule here 1 & 1110.1 & a\\ 2 & 10.1 & b\\ 3 & 23.113231 & c\\ \bottomrule % <-- Bottomrule here \end{tabular} \end{center}\end{table}%...

You can decide for yourself, if you prefer the hlines or the following output:

LaTeX tables – Tutorial with code examples | (10)

Multipage tables

If you have a lot of rows in your table, you will notice that by default, the table will be cropped at the bottom of the page, which is certainly not what you want. The package longtableprovides a convenient way, to make tables span multiple pages. Of course we have to add the package to our preamble before we can start using it:

%...\usepackage{longtable} % To display tables on several pages\begin{document} %...

It’s actually not harder, but easier to use than the previous code for tables. I will first show you what the code looks like and than explain the differences between longtable and tabular, in case they’re not obvious.

%...\begin{longtable}[c]{l|S|r} % <-- Replaces \begin{table}, alignment must be specified here (no more tabular) \caption{Multipage table.} \label{tab:table1}\\ \toprule \textbf{Value 1} & \textbf{Value 2} & \textbf{Value 3}\\ $\alpha$ & $\beta$ & $\gamma$ \\ \midrule \endfirsthead % <-- This denotes the end of the header, which will be shown on the first page only \toprule \textbf{Value 1} & \textbf{Value 2} & \textbf{Value 3}\\ $\alpha$ & $\beta$ & $\gamma$ \\ \midrule \endhead % <-- Everything between \endfirsthead and \endhead will be shown as a header on every page 1 & 1110.1 & a\\ 2 & 10.1 & b\\ % ... % ... Many rows in between % ... 3 & 23.113231 & c\\ \bottomrule\end{longtable}%...

In the previous examples, we’ve always used the table and tabular environments. The longtable environment replaces both of them or rather combines both of them into a single environment. We now use \begin{longtable}[POSITION_ON_PAGE]{ALIGNMENT} as an environment for our tables. Using this environment, we create a table, that is automatically split between pages, if it has too many rows.

The content on the table on the first page looks like this:

LaTeX tables – Tutorial with code examples | (11)

Imagine that this table has many rows (…) being a placeholder for more rows and that the tablecontinues the following page like this:

LaTeX tables – Tutorial with code examples | (12)

Note that there’s again a header on this page, but without the caption. This is because I’ve added the commands \endfirsthead and \endhead to my table, where everything written before \endfirsthead declares the header for the first page the table occurs on and everything between \endfirsthead and \endhead denotes the header, which should be repeated on every following page. If you don’t want a header on the following pages, you can simply remove everything in between \endfirsthead and \endheadincluding the\endhead command.

Landscape tables

Now that we have a solution for too many rows, we could also be facing the same problem if we had too many columns. If we add too many columns, we might be getting a table that’s too wide for the page. In this situation, it’s often best to simply rotate the table and print it in sideways. While there are many different ways to rotate the table, the only that I’ve found to be satisfying was using the rotating package.

First we include the requiredpackage in our preamble:

%...\usepackage{rotating} % To display tables in landscape\begin{document} %...

This package provides the sidewaystable environment, which is very easy to use. Just replace the table environment with the sidewaystable environmentlike this:

%...\begin{sidewaystable}[h!] % <-- \begin{center} \caption{Landscape table.} \label{tab:table1} \begin{tabular}{l|S|r} \toprule \textbf{Value 1} & \textbf{Value 2} & \textbf{Value 3}\\ $\alpha$ & $\beta$ & $\gamma$ \\ \midrule 1 & 1110.1 & a\\ 2 & 10.1 & b\\ 3 & 23.113231 & c\\ \bottomrule \end{tabular} \end{center}\end{sidewaystable}%...

This will automatically rotate the table for us, so it can be read when flipping the page sideways:

LaTeX tables – Tutorial with code examples | (13)

Tables from Excel (.csv) to LaTeX

There are two disadvantages of writing tables by hand as described in this tutorial. While it works for small tables similar to the one in our example, it can take a long time to enter a large amount of data by hand. Most of the time the data will be collected in form of a spreadsheet and we don’t want to enter the data twice. Furthermore once put into LaTeX tables, the data can not be plotted anymore and is not in a useful form in general. For this reason, the next lesson shows you, how to generate tables from .csv files (which can be exported from Excel and other tools) automatically.


  • LaTeX offers the table and tabular environment for table creation
  • The table environment acts like a wrapper for the tabularsimilar to the figure environment
  • Alignment and vertical separators are passed as an argument to the tabular environment (e.g. \begin{tabular}{l|c||r})
  • It’s possible to align the content left (l), centered (c) and right (r), where the number of alignment operators has to match the desired number of columns
  • The columns can be seperated by adding | in between the alignment operators
  • Rows can be seperated using the \hline command and columns using the ampersand & symbol
  • The newline \\ operator indicates the end of a row
  • It’s possible to refer to tables using \ref and \label
  • Align numbers at the decimal point using the siunitx package
  • Combine multiple rows and columns with the multirow package
  • Prettify your tables using the booktabs package
  • Make your tables span multiple pages with the longtable package
  • Display your tables in landscape using the rotating package

Next Lesson: 10 Pgfplotstable


What is tabular vs table LaTeX? ›

For beginners it may be a bit confusing, since LATEX provides two environments: tabular and table. To typeset material in rows and columns, tabular is needed, while the table environment is a container for floating material similar to figure, into which a tabular environment may be included.

How do you make a complex table in LaTeX? ›

With a tabular environment, you need to specify a column for each column in the most populated row. Then, where necessary, you can combine multiple columns together using the \multicolumn command. Alternatively you can use \begin{tabular}{|*{18}{c|}} for a more compact column definition. Indeed, forgot about that.

How do you create a code for a table? ›

An HTML table is created with an opening <table> tag and a closing </table> tag. Inside these tags, data is organized into rows and columns by using opening and closing table row <tr> tags and opening and closing table data <td> tags. Table row <tr> tags are used to create a row of data.

How do I create a table code? ›

We use the <table> tag, to create table in HTML. A table consist of rows and columns. Table heading, row and column and table data can be set using one or more <th>, <tr>, and <td> elements. A table row is defined by the <tr> tag.

What does table * do in LaTeX? ›

tabular* adjusts the space between text of adjacent columns to get a given table width, tabularx leaves this intercolumn space fixed, instead adjusts the text width within the "X" columns for same purpose.

How do I merge two cells in a table in LaTeX? ›

Merging cells

In LaTeX you can merge cells horizontally by using the \multicolumn command. It has to be used as the first thing in a cell.

What are the table style options? ›

The six Table Style Options that you can apply are: Header Row, Total Row, Banded Rows, First Column, Last Column and Banded Columns. If you have selected a plain table style, you may not notice any changes in the table formatting if you select different Table Style Options.

What are the two types of complex table? ›

For example, if there are two coordinate factors, the table is called a two-way table or bi-variate table; if the number of coordinate groups is three, it is a case of three-way tabulation, and if it is based on more than three coordinate groups, the table is known as higher order tabulation or a manifold tabulation.

What are the two ways to insert data into table? ›

The syntax of SQL INSERT has two forms:
  • Using INSERT with column names.
  • Using INSERT without column names.
Jul 8, 2021

How do you load data into a table? ›

Method 2: Using Command-Line and MySQL Workbench to Load Data from File to Table in MySQL.
  1. Step 1: Create Table. ...
  2. Step 2: Importing Data into your Table. ...
  3. Step 3: Transforming Data while Importing. ...
  4. Step 4: Importing File from Client to a remote MySQL Database Server. ...
  5. Step 5: Importing CSV Files using MySQL Workbench.
May 4, 2022

How do you put data into a table? ›

Try it!
  1. Select a cell within your data.
  2. Select Home > Format as Table.
  3. Choose a style for your table.
  4. In the Format as Table dialog box, set your cell range.
  5. Mark if your table has headers.
  6. Select OK.

What is a table code? ›

A code table is a Cúram specific datatype that is used for collections of commonly used constants. They allow for a locale independent way of encoding values. For example, a status code table might contain the values 'Open' and 'Closed'. In French these values would be 'Ouvert' and 'Ferme'.

Which code is used to create a new table? ›

The CREATE TABLE statement is used to create a new table in a database.

How do you create a code example? ›

Follow these recommendations to create clear sample code:
  1. Pick descriptive class, method, and variable names.
  2. Avoid confusing your readers with hard-to-decipher programming tricks.
  3. Avoid deeply nested code.
  4. Optional: Use bold or colored font to draw the reader's attention to a specific section of your sample code.
Aug 24, 2022

How do you create a simple data table? ›

How to Make a Data Table
  1. Name your table. Write a title at the top of your paper. ...
  2. Figure out how many columns and rows you need.
  3. Draw the table. Using a ruler, draw a large box. ...
  4. Label all your columns. ...
  5. Record the data from your experiment or research in the appropriate columns. ...
  6. Check your table.
Apr 12, 2011

How do you create a table in code first approach? ›

Project -> Add New Item…
  1. Project -> Add New Item…
  2. Select Data from the left menu and then ADO.NET Entity Data Model.
  3. Enter BloggingContext as the name and click OK.
  4. This launches the Entity Data Model Wizard.
  5. Select Code First from Database and click Next.
Mar 9, 2022

What does @{} mean in tabular? ›

@{} suppresses the space on the side of the column specifier where it is placed (i.e. placed to the left of the specifier it suppresses the leading space and, conversely, placed to the right it suppresses the trailing space)

What is the use of $$ in LaTeX? ›

In reality, the LaTeX delimiters \( , \) , \[ and \] are single-character macros which provide a sort of “insulating wrapper” around single and double $ characters. The LaTeX definitions of those delimiters (macros) do actually contain $ characters but with additional code that runs some tests/checks.

What are the column types in table LaTeX? ›

The standard column types are l , c , r and p which stands for left aligned , centered or right alignment and parbox . Only the p - type can have a width argument, i.e. p{somewidth} , where width can be specified with any dimension TeX / LaTeX knows of.

How do I create two columns of text inside of a single cell within a table? ›

Text columns inside table cell
  1. Convert text into a table with two table-columns. ...
  2. Create a single-cell table, paste text inside it, and then divide the text into two text-columns. ...
  3. Create a single-cell table, paste the text inside it, select the text, and then divide the table into two table-columns.
Dec 26, 2019

How do I split a column into multiple columns in LaTeX? ›

LaTeX Multiple Columns

Text with two or double columns can be created by passing the parameter \twocolumn to the document class statement. If you want to create a document with more than two columns, use the package multicol, which has a set of commands for the same.

How do I make two columns single column in LaTeX? ›

Most classes take a [twocolumn] option (e.g. \documentclass[twocolumn]{article} is possible). The \onecolumn command switches to single column output and the \twocolumn command switches back, but both commands start a new page.

What are the 3 types of tables? ›

The most common types are work tables, dining room tables, living room or bedroom tables, office tables, gaming tables, and decorative or pedestal tables.

What are the five 5 basic types of table set up? ›

What are the 5 types of table setting? The five most common table settings are formal, informal, Basic, Buffet and five-course.

How do you modify a table style? ›

Use Table Styles to format an entire table
  1. Click in the table that you want to format.
  2. Under Table Tools, click the Design tab.
  3. In the Table Styles group, rest the pointer over each table style until you find a style that you want to use. ...
  4. Click the style to apply it to the table.

What are the difference between dynamic and static tables? ›

In a static data column, users can manually enter text data. In a dynamic data column, the data is displayed as retrieved from any mapping, such as context data or API response. The API value mapping depends on the dynamic data root node that you select.

How do you make a table automatically expand? ›

Go to the Home tab and open the Cell ribbon to choose the Format option. From the menu, choose AutoFit Row Height option.

How do I make a table Swing? ›

JTable(): A table is created with empty cells. JTable(int rows, int cols): Creates a table of size rows * cols. JTable(Object[][] data, Object []Column): A table is created with the specified name where []Column defines the column names.

What is the font size of LaTeX table? ›

The default font size for Latex is 10pt.

How do I make a table a certain size? ›

Resize an entire table manually
  1. Rest the cursor on the table until the table resize handle. appears at the lower-right corner of the table.
  2. Rest the cursor on the table resize handle until it becomes a double-headed arrow .
  3. Drag the table boundary until the table is the size you want.

How do I make a 3 column table in LaTeX? ›

You can create a tabular environment using the commands \begin{tabular}{….} and \end{tabular}. The above code creates three-column latex tables, each with three rows not separated by a line. We used the command { |c|c|c| } to first declare three columns separated by vertical lines.

What are the two main parts of a table? ›

The data is arranged in rows and columns.

What are the four types of tables? ›

Types Of Tables
  • Dining Table.
  • Coffee Table.
  • Kitchen Table.
  • Computer Table.
  • Metal Table.
  • Glass Table.
  • Accent Table.
  • Console Table.

What are the four types of tabulation? ›

Types of Tabulations:
  • Simple Tabulation or One-way Tabulation: ...
  • Double Tabulation or Two-way Tabulation: ...
  • Three-way Tabulation: ...
  • Complex Tabulation: ...
  • Tally Method (Direct) – ...
  • Card Sort and Count Method – ...
  • List and Tally Method –

Can we insert multiple values to a table at a time? ›

INSERT-SELECT-UNION query to insert multiple records

Thus, we can use INSERT-SELECT-UNION query to insert data into multiple rows of the table. The SQL UNION query helps to select all the data that has been enclosed by the SELECT query through the INSERT statement.

What are different data types within a table? ›

Numeric data types such as: INT , TINYINT , BIGINT , FLOAT , REAL , etc. Date and Time data types such as: DATE , TIME , DATETIME , etc. Character and String data types such as: CHAR , VARCHAR , TEXT , etc. Unicode character string data types such as: NCHAR , NVARCHAR , NTEXT , etc.

What are two advantages to putting data into a table? ›

Tables provide fast and efficient readability across issues displayed in rows and columns. They can serve as a common means for benefit-risk communications because of their simple structure, flexibility and the ease with which they can be adapted.

How do you display data from a table? ›

To display the table data it is best to use HTML, which upon filling in some data on the page invokes a PHP script which will update the MySQL table. The above HTML code will show the user 5 text fields, in which the user can input data and a Submit button.

Which data can be entered in a table? ›

A table has records (rows) and fields (columns). Fields have different types of data, such as text, numbers, dates, and hyperlinks. A record: Contains specific data, like information about a particular employee or a product.

When coding a table How is a table row coded? ›

<tr> - represents rows. <td> - used to create data cells. <th> - used to add table headings.

How do you code a table in Javascript? ›

function generateTableHead(table, data) { let thead = table. createTHead(); let row = thead. insertRow(); for (let key of data) { let th = document. createElement("th"); let text = document.

Which command will create table of contents in LaTeX? ›

A table of contents is produced with the \tableofcontents command. You put the command right where you want the table of contents to go; LaTeX does the rest for you. It produces a heading, but it does not automatically start a new page.

Which of the following command is used to create a table in LaTeX? ›

You can create a tabular environment using the commands \begin{tabular}{….} and \end{tabular}. The above code creates three-column latex tables, each with three rows not separated by a line. We used the command { |c|c|c| } to first declare three columns separated by vertical lines.

Which is a basic rule of formatting tables? ›

Tables should be prepared using a roman font. Bold may be used for emphasis. Except for basic horizontal lines (see “Lines” below), tables should be free of lines, boxes, arrows, or other devises unless they indicate the structure of the data. Alternating white and gray rows are standard style shading for all tables.

Can you put a script in a table? ›

You can use JSL to add a script to a data table using the "Add Properties to Table()" or "Add Scripts to Table()" message. By default, this appends the added script to end of the list of scripts (at the bottom in the table properties pane).

How to insert data in table using JavaScript? ›

To insert cells inside a row we use the insertCell() method. It creates a <td> element inside the table row. It takes a number as a parameter that specifies the index of the cell inside that row.

How to display data in a table in JavaScript? ›

try the following code. var table = '<table>'; for(int i=0;i<1000;i++) { console. log("received broadcast: " + msg + ", " + msg. data[i]); table += '<tr>' table += '<td>' table += msg.

How to format table of contents in LaTeX? ›

How to Create a LaTeX Table of Contents – 6 steps to create and custom ToC
  1. Change the List Headings.
  2. Add “Page” Above the Page Numbers.
  3. Change the Depth of Table of Contents Entries.
  4. Use Different Styles For Table of Contents Page Numbers.
  5. Add Lists of Table of Contents.
  6. Add a List of Figures in Table of Contents.
Jul 13, 2022

How do you create a custom table of contents? ›

Go to References > Table of Contents. Select Custom table of contents. Use the settings to show, hide, and align page numbers, add or change the tab leader, set formats, and specify how many levels of headings to show. For more info, see Custom table of contents .

How do I merge cells in a table in LaTeX? ›

Merging cells

In LaTeX you can merge cells horizontally by using the \multicolumn command. It has to be used as the first thing in a cell.

What are the basic commands of LaTeX? ›

Use commands \= (set tab), \> (tab), \< (backtab), \+ (indent one tab stop), \- (outdent one tab stop), \' (flush right), \' (flush left), \pushtabs, \poptabs, \kill, \\. \begin{table}[pos] begins a floating environment, which may be optionally placed at pos (see positions on page 8).

How do tables work in LaTeX? ›

Tables in LaTeX can be created through a combination of the table environment and the tabular environment. The table environment part contains the caption and defines the float for our table, i.e. where in our document the table should be positioned and whether we want it to be displayed centered.


Top Articles
Latest Posts
Article information

Author: Neely Ledner

Last Updated: 12/10/2023

Views: 6484

Rating: 4.1 / 5 (42 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Neely Ledner

Birthday: 1998-06-09

Address: 443 Barrows Terrace, New Jodyberg, CO 57462-5329

Phone: +2433516856029

Job: Central Legal Facilitator

Hobby: Backpacking, Jogging, Magic, Driving, Macrame, Embroidery, Foraging

Introduction: My name is Neely Ledner, I am a bright, determined, beautiful, adventurous, adventurous, spotless, calm person who loves writing and wants to share my knowledge and understanding with you.