# How to add vertical space and center the entries of a last row of a table

I currently have a table in latex that looks like:

\begin{tabular}{c|ll}
\hline
Unit (i) &  \multicolumn{2}{c}{The combinations} \\
i & $(-1,-1,-1,-1)$ & $(-1,-1,+1,+1)$  \\
\hline
1 & $Y_{1}(-1,-1,-1,-1)$ & $Y_{1}(-1,-1,+1,+1)$  \\
2 & $Y_{2}(-1,-1,-1,-1)$ & $Y_{2}(-1,-1,+1,+1)$  \\
3 & $Y_{3}(-1,-1,-1,-1)$ & $Y_{3}(-1,-1,+1,+1)$  \\
4 & $Y_{4}(-1,-1,-1,-1)$ & $Y_{4}(-1,-1,+1,+1)$  \\
5 & $Y_{5}(-1,-1,-1,-1)$ & $Y_{5}(-1,-1,+1,+1)$  \\
\dotfill & \dotfill & \dotfill \\
N & $Y_{N}(-1,-1,-1,-1)$ & $Y_{N}(-1,-1,+1,+1)$  \\
\hline
Average & $\bar{Y}(-1,-1,-1,-1)$ & $\bar{Y}(-1,-1,+1,+1)$  \\
\hline
\end{tabular}


You can see that the last row has the average "bar" symbol touching the line created by hline. Is there a way to create more space in the last row, or possible add more vertical space to the other rows, without defining new commands? Thanks!

I'm not sure I think that the structure of your table is optimal, but I will leave that aside when answering on the vertical space.

I would suggest using the booktabs package and then use \toprule, \midrule and \bottomrule. Thus, first of all add

\usepackage{booktabs}


to your preamble. Next, try this table:

\begin{tabular}{cll}
\toprule
Unit (i) &  \multicolumn{2}{c}{The combinations} \\
i & $(-1,-1,-1,-1)$ & $(-1,-1,+1,+1)$  \\
\midrule
1 & $Y_{1}(-1,-1,-1,-1)$ & $Y_{1}(-1,-1,+1,+1)$  \\
2 & $Y_{2}(-1,-1,-1,-1)$ & $Y_{2}(-1,-1,+1,+1)$  \\
3 & $Y_{3}(-1,-1,-1,-1)$ & $Y_{3}(-1,-1,+1,+1)$  \\
4 & $Y_{4}(-1,-1,-1,-1)$ & $Y_{4}(-1,-1,+1,+1)$  \\
5 & $Y_{5}(-1,-1,-1,-1)$ & $Y_{5}(-1,-1,+1,+1)$  \\
\cdotfill & \cdotfill & \cdotfill \\
$N$ & $Y_{N}(-1,-1,-1,-1)$ & $Y_{N}(-1,-1,+1,+1)$  \\
\midrule
Average & $\strut\bar{Y}(-1,-1,-1,-1)$ & $\bar{Y}(-1,-1,+1,+1)$  \\
\bottomrule
\end{tabular}


Notice that I have also removed a vertical line and changed the \dotfill to \cdotfill. The \cdotfill command I used was stolen from this answer.

\makeatletter
\newcommand\cdotfill{%
\leavevmode\cleaders\hb@xt@.44em{\hss$\cdot$\hss}\hfill\kern\z@
}
\makeatother


If you want the \cdotfill, this code should also go to the preamble.

The result can be seen in the picture below. Your table above, my variant below.

Two suggestions:

• Use judiciously placed typographic struts to improve the vertical spacing above and below the various horizontal lines. Note that I wouldn't increase the value of \arraystretch (default value: 1.0), as doing so will insert more vertical whitespace in all rows, and not just in those that are adjacent to a horizontal line.

\hline
\text{Unit ($i$)}\Tstrut &  \multicolumn{2}{c}{\text{The combinations}} \\
i\Bstrut & (-1,-1,-1,-1) & (-1,-1,+1,+1)  \\
\hline
1\Tstrut & Y_{1}(-1,-1,-1,-1) & Y_{1}(-1,-1,+1,+1)  \\
2 & Y_{2}(-1,-1,-1,-1) & Y_{2}(-1,-1,+1,+1)  \\
3 & Y_{3}(-1,-1,-1,-1) & Y_{3}(-1,-1,+1,+1)  \\
4 & Y_{4}(-1,-1,-1,-1) & Y_{4}(-1,-1,+1,+1)  \\
5\Bstrut & Y_{5}(-1,-1,-1,-1) & Y_{5}(-1,-1,+1,+1)  \\
\dotfill & \dotfill & \dotfill \\
N & Y_{N}(-1,-1,-1,-1) & Y_{N}(-1,-1,+1,+1)\Bstrut  \\
\hline
\text{Average}\TBstrut & \bar{Y}(-1,-1,-1,-1) & \bar{Y}(-1,-1,+1,+1)  \\
\hline
\end{array}\$

\end{document}