DEV Community

latexteada
latexteada

Posted on

LaTeX Tables: The Tabular Environment

Hello, in this post I talk about tables and the tabular environment.

Why is that environment (the tabular environment) so important? well, this is a float environment, which means it is an easy-to-manipulate environment. We can modify the position, alignment, create captions, labels, etc.
The syntax of that command is

\begin{tabular}
Your Table Here
\end{tabular}
Enter fullscreen mode Exit fullscreen mode

We must put the tabular environment inside the table environment. This command has some optional commands, the full command to create a table is the following

\begin{table}[position]
   align
    \begin{tabular}{columns}
      My Table
    \end{tabular}
\end{table}
Enter fullscreen mode Exit fullscreen mode

position options

We can specify the position of the table with the following options

  • h to put the table here, it is, at the current position of your cursor in the code
  • b to put the table at the bottom of the current page
  • t to put the table at the top of the current page

If we want to put the table in the current position and we can put !, this ignores the restrictions and the table is attempted to put in the specified position

align options

We can align our table with the following commands

  • \centering
  • \flushleft
  • \flushright

columns options

Here we specify the number of columns and their position

  • l text to the left
  • c centered text
  • r text to the right
  • | put a vertical line between columns

Until now we have checked how to align and create new columns, let's start our table

  • \hline generates a horizontal line
  • & jumps to the next column (we have declared the number of columns in the columns option. If we put more columns there will be an error)
  • \\ jumps to the next row

Examples

You can find some examples here

I encourage you to play with these commands and create your table.

This is all for today, thanks :)

Top comments (0)