# Remove gap before tabular

I was trying use this code in a document that contains text before and after this table, but I keep getting a large vertical gap before and after the table. How do I fix this?

\def\arraystretch{2}
\setlength\tabcolsep{23pt}

\begin{center}
\scalebox{0.7}{
\begin{tabular}{c c c c c}
\toprule
$n$ & $t_n$ & $y'(t_{n-1},y_{n-1})$                          & $y_n = y_{n-1} + (t_n - t_{n-1})y'(t_{n-1},y_{n-1})$  \\\midrule
1 & 0       & --                                             & 1 \\
2 & 0.2     & $-2\cdot1+1-e^0 = -2$                          & $1 + 0.2(-2) = 0.6$  \\
3 & 0.4     & $-2\cdot0.6+ 1 - e^{-4\cdot0.2} \approx -0.65$ &   $0.6 + 0.2(-0.65) = 0.47$\\
\bottomrule
\end{tabular}
}
\end{center}

• Don't use \scalebox on tables, this gives inconsistent fontsizes, spacing, etc. – Skillmon Jul 7 at 20:40
• also if you do use scalebox (and don't use it on tables) don't leave a space after the { and before the } – David Carlisle Jul 7 at 20:47

Three main points to consider here. First, \begin{center} .. \end{center} adds a vertical space before and after the environment, use the \centering macro instead. Second, \scalebox is not recommended as pointed out by @skillmon, because it makes inconsistent font sizes that can be hard to read. Third, it is much better to use a \table environment and let LaTeX position the table at the optimum position. Lastly, you give \arraystretch and \tabcolsep huge values, let booktabs manage this beautifully.

\documentclass{article}
\usepackage{lipsum}
\usepackage{booktabs}
\begin{document}

\lipsum[2]

\begin{table}[!htbp]
\small
\centering
%\def\arraystretch{1.2}
\begin{tabular}{c c c c c}
\toprule
$n$ & $t_n$ & $y'(t_{n-1},y_{n-1})$                      & $y_n = y_{n-1} + (t_n - t_{n-1})y'(t_{n-1},y_{n-1})$  \\\midrule
1 & 0   & --                                             & 1 \\
2 & 0.2 & $-2\cdot1+1-e^0 = -2$                          & $1 + 0.2(-2) = 0.6$  \\
3 & 0.4 & $-2\cdot0.6+ 1 - e^{-4\cdot0.2} \approx -0.65$ & $0.6 + 0.2(-0.65) = 0.47$\\
\bottomrule
\end{tabular}
\end{table}

\lipsum[4]

\end{document}


remove:

 \def\arraystretch{2}

• @Teepeemm why is this – Robert Csete Jul 7 at 20:12
• arraystretch affects the space between lines of the table but not (directly) the space before or after the table. As you provided no example document it is impossible to comment on how this affects spacing in your case. – David Carlisle Jul 7 at 20:46