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}


* We need to use `multirow` to merge rows, its structure is

Enter fullscreen mode Exit fullscreen mode

\multirow{numberOfRows}{width}{text}


We can put `*` in *width* to set a natural width 

![code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gg2toa9q6dzz5so380aa.png)

Produces

![Screenshot from 2021-02-23 10-45-24](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hognjw03n1j1idhmicop.png)


**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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/85y93zzkn4pep7iwwxek.png) 

Produces

![Screenshot from 2021-02-23 10-59-27](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/07xm2jrwng1t73l2mx42.png)

So, now we can modify our last example and obtain

![code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/szt32bahbtbkrc2ml9ob.png)

Produces

![Screenshot from 2021-02-23 11-01-25](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q5zosalttgaqut2tejzh.png)

I encourage you to play with these commands.

Do not forget to follow me on Twitter `@latexteada`

Thanks, see you :) 



Enter fullscreen mode Exit fullscreen mode

Top comments (0)