[Tex/LaTex] Vertical space between Text and figure

floatsspacingtext;wrap

If the code is like this:

text text text text text.~\cite{sour}\begin{figure}[htbp]
   \centering
   \includegraphics[width=0.9\textwidth]{IMG/fig}
   \caption{Caption.}
   \label{fig:figlabel}
\end{figure} 

No additional vertical space between the figure and the text text text.~\cite{sour} appears. If the code looks like this(what i usually use):

text text text text text.~\cite{sour}
\begin{figure}[htbp]
   \centering
   \includegraphics[width=0.9\textwidth]{IMG/fig}
   \caption{Caption.}
   \label{fig:figlabel}
\end{figure} 

There appears additional space. The text text text.~\cite{sour} is (randomly) as long as one textline, every word i add to the text solves the problem (the text wraps then). It seems the reason is because the text is just about to wrap.

Best Answer

OTOH, it might be easier just to add a % after \cite{}.

\documentclass{article}
\usepackage{graphicx}

\newcommand{\linegobble}{\bgroup
  \baselineskip=0pt
  \par
\egroup}

\begin{document}

\noindent\rule[-.4\baselineskip]{\textwidth}{\baselineskip}%
\begin{figure}[h]
\centering\includegraphics[width=0.5\textwidth]{example-image}
\end{figure}
\linegobble% not needed here, but doesn't hurt either

\noindent\rule[-.4\baselineskip]{\textwidth}{\baselineskip}
\begin{figure}[h]
\centering\includegraphics[width=0.5\textwidth]{example-image}
\end{figure}
\linegobble

Next paragraph.
\end{document}
Related Question