Latex \hline spacing

I think that your problem is that the vertical lineskip in tables is not big enough when hlines are between each row. The solution is to add

\usepackage{tabularx}

\setlength{\extrarowheight}{3pt}

into your preamble.


Create a new row with \hline and trim it with negative spacing:

\multicolumn{2}{c}{Hello!} \\

\hline & \\[-1.5ex]

\textit{Hi!} & \textit{Ho!}

While trying to answer this question for myself, I came across the following hack from https://www.msu.edu/~harris41/latex_tablespacing.html

I was using the solution mentioned by M456, but this does not play nicely with vertical rules in the tabular environment, and so I think this is a bad choice as a default solution (generally I don't include vertical rules, but one of my tables really needed them for clarity).

The idea is to define a strut which should be included in one of the cells for a row which is either immediately before or after an hline.

In the preamble define:

\newcommand\tstrut{\rule{0pt}{2.4ex}}
\newcommand\bstrut{\rule[-1.0ex]{0pt}{0pt}}

Then use the struts in the table to introduce the desired spacing:

\begin{tabular}{ccc}
\hline\hline
Head 1  & Head 2 & Head 3 \tstrut \bstrut \\
\hline
a1 & a2 &  a3 \tstrut \\
b1 & b2 &  b3 \\
c1 & c2 &  c3 \\
d1 & d2 &  d3 \bstrut \\
\hline\hline
\end{tabular}

(I adjusted the strut size somewhat from the web page - adjust it to suit your taste)

There may be better ways to do this, but this seems clean enough, and is easily customisable.

Tags:

Latex