# Decreasing gap size of equation and centering the "text" in first row of table

I want make a table as @Zarko's answer in Reduce Space Before Table and Between Table to New Section. But I have a problem:

The "text" in first row does not center of cell. This is the code:

\documentclass[a4paper,oneside,11pt]{book}
\usepackage[hmargin={4cm,3cm},vmargin={4cm,3cm}]{geometry}
\usepackage{array}
\usepackage{longtable, makecell, tabularx}
\usepackage{amsmath}
\usepackage{helvet}
\renewcommand{\familydefault}{\sfdefault}
\usepackage{newtxmath}
\usepackage[labelsep=period]{caption}
\usepackage{lipsum}

\makeatletter
\setlength\abovedisplayskip{2pt}
\setlength\belowdisplayskip{2pt}
\setlength\abovedisplayshortskip{0pt}
\setlength\belowdisplayshortskip{0pt}
}
\makeatother

\begin{document}
\lipsum[1-4]
\begingroup
\setcellgapes{3pt}
\makegapedcells
\begin{longtable}{|c|c|c|c|}
\caption{That is my longtable, which is supposed to reproduce my problem}
\label{:tab:longtable}          \\
\hline
\hline
\caption[]{That is my longtable, which is supposed
to reproduce my problem (cont.)}             \\
\hline
\hline
\multicolumn{4}{r @{}}{\small\emph{continue on the next page}}  \\*
\multicolumn{4}{@{} l}{\small Source: cnihe3i3nixom}    \\
\endfoot
\hline
\endlastfoot
%%%% table nody
Variable 1   & Variable 2   & Variable 3   & variable 4     \\
\hline
uxbwyy       & xneio22xi    & nc33i3       & 44444          \\
\hline
uxbwyy       & xneio22xi    & nc33i3       & 44444          \\
\hline
uxbwyy       & xneio22xi    & nc33i3       & 44444          \\
\hline
uxbwyy       & xneio22xi    & nc33i3       & 44444          \\
\hline
uxbwyy       & xneio22xi    & nc33i3       & 44444          \\
\hline
uxbwyy       & xneio22xi    & nc33i3       & 44444          \\
\hline
uxbwyy       & xneio22xi    & nc33i3       & 44444          \\
\hline
uxbwyy       & xneio22xi    & nc33i3       & 44444          \\
\hline
uxbwyy       & xneio22xi    & nc33i3       & 44444          \\
\hline
uxbwyy       & xneio22xi    & nc33i3       & 44444          \\
\hline
uxbwyy       & xneio22xi    & nc33i3       & 44444          \\
\hline
uxbwyy       & xneio22xi    & nc33i3       & 44444          \\
\hline
uxbwyy       & xneio22xi    & nc33i3       & 44444          \\
\hline
uxbwyy       & xneio22xi    & nc33i3       & 44444          \\
\hline
uxbwyy       & xneio22xi    & nc33i3       & 44444          \\
\hline
uxbwyy       & xneio22xi    & nc33i3       & 44444          \\
\end{longtable}
\endgroup
\lipsum[6-8]
$\int \sin x dx = -\cos x +c$
where $c$ is constant.
\end{document}


If I omit the code:

\makeatletter
\setlength\abovedisplayskip{2pt}
\setlength\belowdisplayskip{2pt}
\setlength\abovedisplayshortskip{0pt}
\setlength\belowdisplayshortskip{0pt}
}
\makeatother


the "text" in first row can centered but there is gap before and after the equation:

So, I want both of decreasing gap size of equation and centering the "text" in first row.

Anyone can help me to do that?

• Replace\ thead with \textbf. This should help in table(s). Showed space above/below equation I can't reproduce Jan 30 at 7:32

• more space around column headers written by \thead is determined by design, so if you not liked it, than don't use it. Replace it by \textbf:

• I can't reproduce bigger vertical space around your equation, but observe discrepancy between math and text font height.
• you should be aware, that helvet font is about 20% higher than math font defined in newtxmath.
• for removing this remedy you have two possibilities:
• used scaled helvet fonts:
\usepackage[scaled=0.82]{helvet}
\renewcommand{\familydefault}{\sfdefault}

• instead helvet fonts use newtxtext, which is better paired with newtxmath:
\usepackage{newtxtext, newtxmath}
\renewcommand{\familydefault}{\sfdefault}


Use of not scaled helvet:

Use of scaled helvet:

Use of newtxtext`: