Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
2  
Add figure environments between paragraphs, not inside them. –  egreg Mar 20 at 15:31
1  
Change \end{figure} to \end{figure}% twice. There are spaces at the end of the lines. –  Malipivo Mar 20 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". –  Bart Arondson Mar 20 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 at 16:35

1 Answer 1

up vote 7 down vote accepted

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.

share|improve this answer
    
Is it good practice to write \end{environment}% in general? Or is this something which I should consider per case? –  Bart Arondson Mar 20 at 15:39
    
@BartArondson I moved the answer to that comment into my updated answer. –  David Carlisle Mar 20 at 16:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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