Working with LaTeX: LaTeX Lists and Tables (2023)

Overview

Teaching: 0 min
Exercises: 0 min

Questions

  • How do I add a table to my document?

Objectives

  • Learn how to make an itemized list

  • Learn how to make an enumerated list

  • Learn how to make a descriptive list

  • Know how tables are arranged in LaTeX

  • Create a simple table

  • Be able to justify cells of a table

  • Deal with linebreaking within cells

  • Use line barriers to make a table easier to read

  • Make tables with multi-row or column stretches

  • Adjust sizes, spacing, and placement of a table

Itemized Content

Often it is useful to include itemized content in a document. This can take the form of bulletpoints, numbered lists, and descriptions. LaTeX can handle all of these forms of content. Eachis called with a different command, and the lists will be styled and ranked according to the rulesof the documentclass. All lists follow the same basic structure. An environment is called withthe type of list, and each point is an item within the list. Every time we want to “indent”(think 1.. 2a.. 2b.. 3..) we need to create a new list environment within the confines of anitem. The following list types will show how the same content can be represented in each type.

(Video) Learn LaTeX Tutorial - Lists and Tables

Itemized Lists

Itemized lists are also called “bullet point” lists. Each item is not ranked, but obeys hierarchy.Itemized lists are called with itemize:

\documentclass{article}\begin{document} \begin{itemize} \item The first item on our list \item The second item on our list \begin{itemize} \item The second item on our list, part 1 \item The second item on our list, part 2 \end{itemize} \item The third item on our list \end{itemize}\end{document}

Working with LaTeX: LaTeX Lists and Tables (1)

Note that text that follows item does not need to be within curly braces. All text followingan item is assumed to be part of that point when inside an itemize environment.

Enumerated Lists

Numbered lists are similar to itemized lists, except they are, obviously, numbered. Each item isranked in order that it appears and respects hierarchy. Numbered lists are called withenumerate:

\documentclass{article}\begin{document} \begin{enumerate} \item The first item on our list \item The second item on our list \begin{enumerate} \item The second item on our list, part 1 \item The second item on our list, part 2 \end{enumerate} \item The third item on our list \end{enumerate}\end{document}

Working with LaTeX: LaTeX Lists and Tables (2)

If we desire, we can also nest different types of lists. Hierarchy will be respected for allnested lists, even if the labeling scheme is not the same.

\documentclass{article}\begin{document} \begin{enumerate} \item The first item on our list \item The second item on our list \begin{itemize} \item The second item on our list, part 1 \item The second item on our list, part 2 \end{itemize} \item The third item on our list \end{enumerate}\end{document}

Working with LaTeX: LaTeX Lists and Tables (3)

Descriptive Lists

Descriptive lists are a bit like definitions. If we read a dictionary, we do not expect each wordto be numbered. So description lists can appear without a bullet or numeral. Descriptive listscan, however, use an option box. This will, depending on the style of the document declared indocumentclass, appear emboldened, with ample spacing, before the body of the item text.

\documentclass{article}\begin{document} \begin{description} \item[Primary] The first item on our list \item[Secondary] The second item on our list \begin{description} \item[alt-Secondary-a] The second item on our list, part 1 \item[alt-Secondary-a] The second item on our list, part 2 \end{description} \item[Tertiary] The third item on our list \end{description}\end{document}

Working with LaTeX: LaTeX Lists and Tables (4)

Advanced Lists

There are lots of options when working with lists, and they can be customized in many ways.Packages exist which can redefine the organization of a list, such that it appears horizontally,spaces definitions based on the longest entry, use a custom image as a bullet point, and muchmore. Exploring these options will be left to the user as need arises.

LaTeX Tables

Tables in LaTeX are declared using the tabular environment. When declaring this environment,you must know how many columns of data you will be presenting before you start. The firstargument required when preparing a table is the alignment of each piece of data within the cell.Then, data are listed in the environment with an ampersand & between each column.

(Video) Creating Table of contents, list of figures and tables in Latex

\documentclass{article} \begin{document} \begin{tabular}{ c c c } A1 & B1 & C1 \end{tabular}\end{document}

Working with LaTeX: LaTeX Lists and Tables (5)

Another Row? Another Line Break!

Rows are manually declared by starting a new line with \\.

\documentclass{article} \begin{document} \begin{tabular}{ c c c } A1 & B1 & C1 \\ A2 & B2 & C2 \\ A3 & B3 & C3 \end{tabular}\end{document}

Working with LaTeX: LaTeX Lists and Tables (6)

Column Alignment

Columns in the tabluar environment are declared in the first argument, surrounded by curlybraces. The alignment of the contents of each column is declared here. A column can be told toalign toward the left margin (l), toward the right margin (r), or to align itself in the centerof the cell (c)

\documentclass{article} \begin{document} \begin{tabular}{ l r c } A1 & B1 & C1 \\ A222 & B22 & C2 \\ A3 & B333 & C33 \end{tabular}\end{document}

Working with LaTeX: LaTeX Lists and Tables (7)

Table environments are types of floats. They can be told where to position (h, t, b, p)much in the same way as figure floats. However, they should NOT use the centering command.Telling a table to use centering will cause all content within the table to be centered. This isoften undesirable. Instead, to center a table, place the tabular environment within a centerenvironment.

\documentclass{article} \begin{document} \begin{center} \begin{tabular}{ l r c } A1 & B1 & C1 \\ A222 & B22 & C2 \\ A3 & B333 & C33 \end{tabular} \end{center}\end{document}

Working with LaTeX: LaTeX Lists and Tables (8)

It is a best practice to organize your columns inyour LaTeX file by the size of their content. This will make it easier for you to read and makeedits. Most editors should use a monospace font, making this easy to implement.

Horizontal and Vertical Separators

A table with dividing lines can be generated by declaring horizontal bars (|) in the columnalignment description. Bars placed between the alignment characters will become vertical linesthroughout the table.

\documentclass{article} \begin{document} \begin{center} \begin{tabular}{ l | r | c } A1 & B1 & C1 \\ A222 & B22 & C2 \\ A3 & B333 & C33 \end{tabular} \end{center}\end{document}
(Video) LaTeX Tutorial 3 - Tables

Working with LaTeX: LaTeX Lists and Tables (9)

Horizontal lines are generated using the hline command. These are generally added next to thenewline commands \\ for rows in the table.

\documentclass{article} \begin{document} \begin{center} \begin{tabular}{ l | r | c } A1 & B1 & C1 \\ \hline A222 & B22 & C2 \\ \hline A3 & B333 & C33 \end{tabular} \end{center}\end{document}

Working with LaTeX: LaTeX Lists and Tables (10)

Stretching or Merging Cells

To combine the contents of cells, a special cell is declared using either multicolumn ormultirow, depending on the context. These commands are defined in the multirow package. Themulticolumn command requires one set of curly braces declaring the number of columns or rows tostretch, a second set of curly braces which describes the alignment and bars to use with the cell,and a third set of curly braces for the contents.

The multirow command uses a similar structure, save the contents of the second set of braces.In the multirow second set of braces, the width of the new row is defined. It is recommended tosimply place * in this spot, which allows the multirow to stretch dynamically based on theother rows. A multirow cell will require a column, so don’t forget to leave room for it.

\documentclass{article}\usepackage{multirow} \begin{document} \begin{center} \begin{tabular}{ c || l | r | c } \multicolumn{4}{|c|}{Columns} \\ \hline \hline \multirow{3}{*}{Rows} & A1 & B1 & C1 \\ \hline & A222 & B22 & C2 \\ \hline & A3 & B333 & C33 \end{tabular} \end{center}\end{document}

Working with LaTeX: LaTeX Lists and Tables (11)

Controlling hline can become challenging when using a multirow. In the example above, theoverzealous lines look ugly when they cut across the combined cell. To cope with this, we changeour hline commands to cline. The cline is exactly the same, but with the ability to specifythe rows for the line to be visible on. With some careful arrangement, we can make our simpletable look professional.

\documentclass{article}\usepackage{multirow} \begin{document} \begin{center} \begin{tabular}{ c || l | r | c } & \multicolumn{3}{c}{Columns} \\ \hline \hline \multirow{3}{*}{Rows} & A1 & B1 & C1 \\ \cline{2-4} & A222 & B22 & C2 \\ \cline{2-4} & A3 & B333 & C33 \end{tabular} \end{center}\end{document}

Working with LaTeX: LaTeX Lists and Tables (12)

Text Wrapping and Cell Size

Sometimes, a large amount of text will be entered into a cell. However, LaTeX does notautomatically wrap text within a cell. The size of the cell is fit to the contents, so a verylong sentance in a cell can make the size strange, or even extend it beyond the page. A specialalignment can be used in this case, p. Compare these two examples:

\documentclass{article}\usepackage{multirow} \begin{document} \begin{center} \begin{tabular}{ c || l | r | c } & \multicolumn{3}{c}{Columns} \\ \hline \hline \multirow{3}{*}{Rows} & A1 & B1 & This is column C with row number one \\ \cline{2-4} & A222 & B22 & This is column C with row number two \\ \cline{2-4} & A3 & B333 & This is column C with row number three \end{tabular} \end{center} ~ \begin{center} \begin{tabular}{ c || l | r | p{3.3cm} } & \multicolumn{3}{c}{Columns} \\ \hline \hline \multirow{3}{*}{Rows} & A1 & B1 & This is column C with row number one \\ \cline{2-4} & A222 & B22 & This is column C with row number two \\ \cline{2-4} & A3 & B333 & This is column C with row number three \end{tabular} \end{center}\end{document}

Working with LaTeX: LaTeX Lists and Tables (13)

Float the Table

Since the LaTeX tabular environment is a float, we can apply options to it in much the same wayas figures. As we have seen, the location on the page can be controlled with h, t, b, p.We can also take advantage of the float rules to scale contents. Floats can be thought of asminiature pages within our page. If we place this into a new environment that changes the sizeof the tabular environment to meet our needs. In this way, very large tables can fit onrelatively smaller sized pages.

(Video) Tables in LaTeX || Full Tutorial || Intro to LaTeX Episode 8

The resizebox and scalebox commands provided by the graphicx package can be used to changethe size of a float. The resizebox command takes the form of width, height, and contents inseparate sets of curly braces (the character ! is used as a wildcard). Likewise, the scaleboxcommand requires a ratio and the contents in two separate sets of curly braces.

\documentclass{article}\usepackage{multirow}\usepackage{graphicx} \begin{document} \begin{center} \resizebox{10cm}{!}{ \begin{tabular}{ c || l | r | c } & \multicolumn{3}{c}{Columns} \\ \hline \hline \multirow{3}{*}{Rows} & A1 & B1 & C1 \\ \cline{2-4} & A222 & B22 & C2 \\ \cline{2-4} & A3 & B333 & C33 \end{tabular} } \end{center} ~ \begin{center} \scalebox{2}{ \begin{tabular}{ c || l | r | c } & \multicolumn{3}{c}{Columns} \\ \hline \hline \multirow{3}{*}{Rows} & A1 & B1 & C1 \\ \cline{2-4} & A222 & B22 & C2 \\ \cline{2-4} & A3 & B333 & C33 \end{tabular} } \end{center}\end{document}

As long as we are treating the table as a float, it is worth noting that other properties presentin the figure environment can be applied to the table environment such as captions. Note thatthis requires the table environment in addition to the tabular environment.

\documentclass{article}\usepackage{multirow} \begin{document} \begin{table}[t] \begin{center} \begin{tabular}{ c || l | r | c } & \multicolumn{3}{c}{Columns} \\ \hline \hline \multirow{3}{*}{Rows} & A1 & B1 & C1 \\ \cline{2-4} & A222 & B22 & C2 \\ \cline{2-4} & A3 & B333 & C33 \end{tabular} \end{center} \caption{A table of values} \end{table}\end{document}

Working with LaTeX: LaTeX Lists and Tables (14)

Key Points

  • Convert text to a bulleted list with itemize

  • Convert sequential to a numbered list with enumerate

  • Define terms with a description list

  • Create a basic table with tabular

  • Justify cells with l, c, and r

  • Position text within cells vertically with t, c, and b

  • Use p to wrap lines of text within a cell

  • Create vertical barriers between columns with |

  • Create horizontal barriers between rows with hline

  • Use multicolumn and multirow to make joined cells

  • Adjust the size scale of a table using resizebox

  • Influence page position with float positioning arguments h, t, b, and p

    (Video) LaTeX – Full Tutorial for Beginners

Videos

1. List of symbols in LaTeX, Tables detailed discussion | LaTeX KTÜ Thesis 6
(Coding Master)
2. Tables in LaTeX with overleaf (v2)
(Vincent Knight)
3. LaTeX CSV Automation 1 - Creating LaTeX Tables from CSV Files
(TM Quest)
4. LaTeX tutorial-3 of 7- How to add tables, lists and figures in technical document
(Rajendra Choure)
5. Figures, columns, list and tables - Part 3 - Beamer LaTeX course
(Federico Tartarini)
6. Table of contents, List of Figures and Tables - LaTeX in 100 seconds
(Federico Tartarini)
Top Articles
Latest Posts
Article information

Author: Eusebia Nader

Last Updated: 03/14/2023

Views: 6480

Rating: 5 / 5 (80 voted)

Reviews: 87% of readers found this page helpful

Author information

Name: Eusebia Nader

Birthday: 1994-11-11

Address: Apt. 721 977 Ebert Meadows, Jereville, GA 73618-6603

Phone: +2316203969400

Job: International Farming Consultant

Hobby: Reading, Photography, Shooting, Singing, Magic, Kayaking, Mushroom hunting

Introduction: My name is Eusebia Nader, I am a encouraging, brainy, lively, nice, famous, healthy, clever person who loves writing and wants to share my knowledge and understanding with you.