DEV Community

latexteada
latexteada

Posted on

More on LaTeX tables: Rotated text and Merging rows

Hello, in this post you can check how to create a table in LaTeX, and some examples at the end of the document.

I hope you have explored that environment, here, in this post, I bring you two useful tools that you may require while doing tables

Rotated Text

We need to import the rotating package and we need to use the command sideways

If you want to know more about some packages, you can check this post.

We must put the text which will be rotated in the sideways command, this command must be inside the column, as in the following example

code

Produces

Screenshot from 2021-02-23 10-19-20

Another example is

code

Produces

Screenshot from 2021-02-23 10-23-31

Merging Rows and Columns

We need to import the multirow package

  • We need to use multicolumn to merge columns, its structure is
\multicolumn{numberOfColumns}{Alignment}{text}
Enter fullscreen mode Exit fullscreen mode
  • We need to use multirow to merge rows, its structure is
\multirow{numberOfRows}{width}{text}
Enter fullscreen mode Exit fullscreen mode

We can put * in width to set a natural width

code

Produces

Screenshot from 2021-02-23 10-45-24

WAIT!!! What is this!? Why there are lines in that column, it is not supposed that there would not need to be lines in that column. Well, we have discovered a property of the \hline command.

  • The \hline command puts a line from the first column to the last column. we need to explore another command

cline Command

With this command, we can draw a horizontal line across the columns, its structure is \cline{i-j} where i is the first column and j the ending column

  • We start counting in 1

code

Produces

Screenshot from 2021-02-23 10-59-27

So, now we can modify our last example and obtain

code

Produces

Screenshot from 2021-02-23 11-01-25

I encourage you to play with these commands.

Do not forget to follow me on Twitter @latexteada

Thanks, see you :)

Top comments (0)