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.

• Since most of the material in the table is math-y, consider using an array environment instead of a tabular environment; if nothing else, making this switch lets you eliminate about 32  symbols, greatly de-cluttering the code. Also, consider right-aligning rather than centering the two data columns. \documentclass{article} \usepackage{amsmath} % for "\text" macro %% Define a few struts %% (from code by Claudio Beccari in *TeX and TUG News*, Vol. 2, 1993) \newcommand\Tstrut{\rule{0pt}{2.9ex}} % "top" strut \newcommand\Bstrut{\rule[-1.2ex]{0pt}{0pt}} % "bottom" strut \newcommand\TBstrut{\Tstrut\Bstrut} % "top-and-bottom" strut \begin{document}\begin{array}{c|rr}
\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}