Graphics, Figures & Tables ⇒ Extra Spaces from Nowhere!
-
- Posts: 55
- Joined: Sun Nov 09, 2008 7:48 pm
Extra Spaces from Nowhere!
Hi!
Thanks for taking the time to read my posting.
I seem to have stumbled upon a rather interesting difficulty which happens regardless of whether or not I use the floats package. In a nutshell, it seems that when I have a train of a few floats, curious spaces appear in the text that I don't at all expect. To provide an example, imagine the following:
****
This is a sentence which describes the floats which are about to come.
\begin{figure}
blahblah...
\end{figure}
\begin{figure}
blahblah...
\end{figure}
\begin{figure}
blahblah...
\end{figure}
\begin{figure}
blahblah...
\end{figure}
This is a sentence which discusses the ramifications of the floats.
****
After latex'ing this, the floats go wherever they may, but what's really interesting is what happens between the text:
This is a sentence which describes the floats which are about to come.<whole bunch of spaces, say 5 or 6 inter-sentence spaces>This is a sentence which discusses the ramifications of the floats.
The number of spaces inserted here is a function of the number of floats in the train. This happens with the table environment, too. If you're tempted to think it's something related the "blahblah..." between the \begin and the \end, know that even if blahblah...=NULL (ie there's nothing between the \begin{figure} and the \end{figure}) the spaces still appear. Another piece of information: if it deems necessary, latex will split those spaces across a line making it look as though I've started a new paragraph. UGH!
This makes me sweat... in a not so good way. I'd love it if someone might be able to slide along some insight into this. I'm using MikTeX 2.7 on XP SP3.
Thanks again for your time!
Thanks for taking the time to read my posting.
I seem to have stumbled upon a rather interesting difficulty which happens regardless of whether or not I use the floats package. In a nutshell, it seems that when I have a train of a few floats, curious spaces appear in the text that I don't at all expect. To provide an example, imagine the following:
****
This is a sentence which describes the floats which are about to come.
\begin{figure}
blahblah...
\end{figure}
\begin{figure}
blahblah...
\end{figure}
\begin{figure}
blahblah...
\end{figure}
\begin{figure}
blahblah...
\end{figure}
This is a sentence which discusses the ramifications of the floats.
****
After latex'ing this, the floats go wherever they may, but what's really interesting is what happens between the text:
This is a sentence which describes the floats which are about to come.<whole bunch of spaces, say 5 or 6 inter-sentence spaces>This is a sentence which discusses the ramifications of the floats.
The number of spaces inserted here is a function of the number of floats in the train. This happens with the table environment, too. If you're tempted to think it's something related the "blahblah..." between the \begin and the \end, know that even if blahblah...=NULL (ie there's nothing between the \begin{figure} and the \end{figure}) the spaces still appear. Another piece of information: if it deems necessary, latex will split those spaces across a line making it look as though I've started a new paragraph. UGH!
This makes me sweat... in a not so good way. I'd love it if someone might be able to slide along some insight into this. I'm using MikTeX 2.7 on XP SP3.
Thanks again for your time!
NEW: TikZ book now 40% off at Amazon.com for a short time.

-
- Posts: 707
- Joined: Tue Mar 25, 2008 5:02 pm
Re: Extra Spaces from Nowhere!
TeX is interpreting all the commands you have as zero-length words. Put % signs at the end of every line in the figure, and these spaces will go away. (You actually don't need them after EVERY line, but without an example it's harder to say which ones are causing the problem.)
-
- Posts: 55
- Joined: Sun Nov 09, 2008 7:48 pm
Re: Extra Spaces from Nowhere!
Well, as usual, I'm indebted. Thanks for your response; your suggestion worked.
Now... I'd love to know *why*! It turns out that as long as I put the % after the \end{figure} or \end{table} command, I'm good. That this should happen just seems so *wrong* - but certainly only my ignorance is wrong!
Could you please post a line or two to explain why this is happening?
Thank you so much, again!
Christian
Now... I'd love to know *why*! It turns out that as long as I put the % after the \end{figure} or \end{table} command, I'm good. That this should happen just seems so *wrong* - but certainly only my ignorance is wrong!
Could you please post a line or two to explain why this is happening?
Thank you so much, again!
Christian
Re: Extra Spaces from Nowhere!
it is bad practice to place figures inside the text anyway, place the figures between paragraphs, then
(1) you don't end up with figures that have jut one line of text below them, and
(2) this problem goes away
(1) you don't end up with figures that have jut one line of text below them, and
(2) this problem goes away
Extra Spaces from Nowhere!
End of line characters are treated as spaces. The % discards everything up to and including the end of line character, so the space gets discarded. Unwanted spaces are usually caused by line breaks.cbkschroeder wrote:Now... I'd love to know *why*! It turns out that as long as I put the % after the \end{figure} or \end{table} command, I'm good. That this should happen just seems so *wrong* - but certainly only my ignorance is wrong!
Regards
Nicola Talbot
LaTeX Resources: http://www.dickimaw-books.com/latexresources.html
Creating a Minimal Example: http://www.dickimaw-books.com/latex/minexample/
Creating a Minimal Example: http://www.dickimaw-books.com/latex/minexample/
Re: Extra Spaces from Nowhere!
isn't the problem here that the float inserts a whatsit and there fore the spaces after the envionment is actually enterpreted?
-
- Posts: 55
- Joined: Sun Nov 09, 2008 7:48 pm
Extra Spaces from Nowhere!
I had no idea this was considered bad practice; is this universally so? I've always done things this way. It seems to get my floats to be where I want them, at least reasonably. I'm not so fussy to use a specific package to get floats exactly in a specific place.daleif wrote:it is bad practice to place figures inside the text anyway, place the figures between paragraphs, then
(1) you don't end up with figures that have jut one line of text below them, and
(2) this problem goes away
OK, but if that's the case, then why is there not just a single space? Usually in LaTeX when I put many spaces between two words in the source file, the outcome is a single inter-word space. Considering that there are several commands in the figure environment, why am I only getting one space per environment invocation, yet if I invoke the figure environment several times, I get several spaces?nlct wrote: End of line characters are treated as spaces. The % discards everything up to and including the end of line character, so the space gets discarded. Unwanted spaces are usually caused by line breaks.
I'm not sure exactly what this means. Could you flesh it out a little?daleif wrote:isn't the problem here that the float inserts a whatsit and there fore the spaces after the envionment is actually enterpreted?
Thanks, as always, for everyone's time.
Extra Spaces from Nowhere!
That's because they are not consecutive spaces as they are broken up by whatsits. For example, try the following:cbkschroeder wrote: OK, but if that's the case, then why is there not just a single space? Usually in LaTeX when I put many spaces between two words in the source file, the outcome is a single inter-word space. Considering that there are several commands in the figure environment, why am I only getting one space per environment invocation, yet if I invoke the figure environment several times, I get several spaces?
Code: Select all
A {} {} {} {} B
Code: Select all
A B
The spaces within the figure environment are floated with the figure, so they don't affect the rest of the paragraph. Whereas the space after each figure environment is turned into a space in the paragraph.
Hope that helps.
Regards
Nicola Talbot
LaTeX Resources: http://www.dickimaw-books.com/latexresources.html
Creating a Minimal Example: http://www.dickimaw-books.com/latex/minexample/
Creating a Minimal Example: http://www.dickimaw-books.com/latex/minexample/
-
- Posts: 55
- Joined: Sun Nov 09, 2008 7:48 pm
Re: Extra Spaces from Nowhere!
Nicola,
Thank you; that helps a lot. Now it's clear to me!
Cheers,
Christian
Thank you; that helps a lot. Now it's clear to me!
Cheers,
Christian