3

I have a large document based on the book documentclass with text and images, and sometimes I encounter a new sentence that has a huge space after a period. It looks like this:
enter image description here

I have attempted to make a MWE, but failed to get the problem.

This problem generally occurs when I have code that has this general structure:

A sentence that explains something shown in the images.
%
\begin{figure}[!ht]
\begin{minipage}[t]{0.48\textwidth}
    \includegraphics[clip=true, trim=0 0 0 0, width=0.9\linewidth, angle=0]{image}
\end{minipage}
\hfill
\begin{minipage}[t]{0.48\textwidth}
    \includegraphics[clip=true, trim=0 0 0 0, width=0.9\linewidth, angle=0]{image}
\end{minipage}
\end{figure}
%
\begin{figure}[htpb] 
    \includegraphics[clip=true, trim=0 0 0 0, width=0.8\linewidth, angle=0]{image} 
\end{figure}
%
Another sentence that continues on the explanation.

It compiles then to something like this:

A sentence that explains something shown in the images.    Another sentence that continues on the explanation.
<image><image>
   <image>

What could be causing this large jump? Is there some package/option that is known to give this discrepancy? As said I've tried to compile a MWE but failed to achieve this "error". If I knew what might cause this I could re-attempt to produce an MWE.

  • 2
    Add figure environments between paragraphs, not inside them. – egreg Mar 20 '14 at 15:31
  • 1
    Change \end{figure} to \end{figure}% twice. There are spaces at the end of the lines. – Malipivo Mar 20 '14 at 15:36
  • Not sure if it's a duplicate. It's the same subject/problem, but the linked question approaches it from the other side ("what does this solution do?") and my question is more along the lines of "I have this problem, how do I solve this". – Saaru Lindestøkke Mar 20 '14 at 16:03
  • @Werner This is rather different from the canonical % at eol question. For a single figure you don't need the % and LaTeX explicitly checks for and compensates for any white space. It is just that its checks can not cope with a run of alternating insert and space nodes. – David Carlisle Mar 20 '14 at 16:35
  • @egreg I had that before, but I noticed it took more space (in terms of pages) hence I switched to the method of including figure environments in paragraphs. This saved me 4 pages on a document of 100. When the text needs a paragraph because of the content I of course begin a new paragraph. – Saaru Lindestøkke Mar 20 '14 at 17:07

1 Answers1

6

It's OK to put figures in paragraphs but if you put them one after the other you must have no space between them. You have a word space between each from the end of line, and the figures float away leaving the space.

\end{figure}%%%%%%%%%%%%%%%%%<<<<<<<<<<<<<<<<<<<<<<<<<<<<
%
\begin{figure}[htpb] 

LaTeX takes precautions so that if there is space before and after a figure only one space appears in the final paragraph, however it doesn't (and can't easily) check that a space between two figures is "after" one figure and "before" the next so both figures see a space and add a single space to the final para so you get two spaces.

David Carlisle
  • 757,742