## Sunday, May 17, 2009

### Tabular Row Spacing

We've already covered how to deal with the row height in latex, but what if you want to make only certain rows separated. When designing a table with multiple lines per cell we will use the \hline structure to make the table seem like it has multiple rows.

In this case we need to separate the rows individually, which can be done at the end of the tabular line. Consider the following code:

\begin{tabular}{rl}
{\bf First Column} & {\bf Second Column} \\\hline \\ [-1.5ex]
First Item & First Attribute \\
& Second Attribute \\
& Third Attribute \\ [1ex] \hline \\ [-1.5ex]
Second Item & First Attribute \\
& Second Attribute \\
& Third Attribute \\
& Fourth Attribute \\ [1ex] \hline \\ [-1.5ex]
Third Item & First Attribute \\
& Second Attribute \\ [1ex] \hline \\ [-1.5ex]
Fourth Item & First Attribute \\
& Second Attribute \\
& Third Attribute \\ [1ex] \hline \\ [-1.5ex]
\end{tabular}

Putting [1ex] at the end of a line creates that much extra space after the line. The idea here is to make 1ex before the \hline, and then put a completely blank line after it. the [-1.5ex] moves the line after the \hline up, making the gap less than a full line. The result is in the following image:

1. Excellent! I've been looking for how to do this for ages. Thanks very much

2. Good trick. The only thing is that it doesn't look good with vertical lines.

3. Works great for me. Thanks.

4. Just what i needed too. It works well with vertical lines too, if you add enough '&'s along with the '\\'. Thank you!

5. The booktabs package is also perfect for this kind of considerations. It handles space above and below lines very well and provides the keywords toprule, midrule, and bottomrule which make your code more declarative.

6. Thanks a lot!

7. very useful. thanks

8. horrible with vertical lines

9. Thanks master :)

10. V V useful, thanks a lot!

11. Hi! Have you ever noticed, has your writting style gone any better lately?

12. Thanks a lot :)) It's really beneficial.

13. \renewcommand{\arraystretch}{1.5}
\begin{tabular}
....
\end{tabular}

this works better

14. Just use booktabs and be done with it.

15. Hi...!
Very nice post...
Good personality is a important in human life ayurveda is a best way to Increase