2

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.

  • Is there any significance to \begin{figure}[htbp] not starting on a new line in the first code snippet? – Mico Nov 4 '15 at 7:16
  • Yes. if \begin{figure}[htbp] is attached to the text, there appears no vertical space. The linebreak (in Texstudio) leads to the bug. – user4672571 Nov 4 '15 at 17:08
  • 1
    There is definitely a difference in the behavior if figure[h] is attached to a line of test, but it has more to do with what is placed AFTER the figure than before it. – John Kormylo Nov 4 '15 at 19:32
1

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}
  • I can't reproduce the problem of OP nor in your answer see any difference in vertical space between rule and figure if % is follows rule or not. This distance in real circumstances are not fixed, they depends on page contents. As we know, LaTeX can stretch all vertical distances between paragraphs on page to fit content in it. – Zarko Jan 3 '16 at 22:42
  • The difference occurs if you remove \linegobble. – John Kormylo Jan 4 '16 at 2:18
  • Yes and now: if you comment all \linegobble in MWE and % after first rule (simulation text?), the distances are the same at both pictures. I think, that more realistic result youcan be shown by use some dummy text instead of those lines, for example with \lipsum. I think, that it is important that in all cases is used the same way of inserting figures. Of course, if after figures start new paragraph, distance between it and figure can different from distances, when figure is in the middle of paragraph. I believe, that this is intentionally, isn't it? – Zarko Jan 4 '16 at 2:30
  • @Zarko - As the op said, the problem only occurs when the last line just barely fits, which is easy to simulate with \rule. – John Kormylo Jan 4 '16 at 2:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.