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.

When the figure environment directly follows a \[ ... \] environment an unwanted space occurs in the output. It obviously seems to be an endlinechar which is changed into a space.

\documentclass{article}
\begin{document}
\[ a  = b. \]
\begin{figure}
  figure
\end{figure}
Text\\
Text

\[ a  = b. \]
\begin{figure}
  figure
\end{figure}%
Text\\
Text

\end{document}

I know I can get rid of this adding a % after \end{figure} or generally by adding \ignorespaces to the figure environment with etoolbox's \AfterEndEnvironment.

My question is: is this a bug or expected behaviour? And if it is a bug who do I send a report?

EDIT: It seems my example was not really a minimal one. As it turns out the display environment is not necessary to get the space:

\documentclass{article}
\begin{document}
a%
\begin{figure}
  \caption{A}
\end{figure}
b

and

c\\
d%
\begin{figure}
  \caption{B}
\end{figure}
e

vs.

f%
\begin{figure}
  \caption{C}
\end{figure}%
g

\end{document}

In case I didn't make it clear enough: I am not interested in a way to avoid the space -- I know already how to do that. I admit that such information might be useful for other readers, though.

I rather want to know if this behaviour is to be expected of the figure environment or a bug?

share|improve this question
    
In your example both figures are located at the top of the page. –  Marco Daniel Jan 14 '12 at 17:53
    
I know but that seems not to be the point, or am I wrong? –  cgnieder Jan 14 '12 at 17:59
    
As I explained, \begin{figure} eats a space before it (if there is), but \end{figure} doesn't eat a space after it. In cases (ab) and (de) there's a space after \end{figure}; in case (fg) there isn't. –  egreg Jan 15 '12 at 22:23
    
@egreg so you're saying this is expected (and wanted?) benahviour? Is that for a purpose? –  cgnieder Jan 15 '12 at 23:04
    
It's expected; you just insert a figure environment and don't worry about spaces. Just don't put them after displayed equations and, as I said, it's usually better to put them between paragraphs. –  egreg Jan 16 '12 at 0:37

1 Answer 1

up vote 10 down vote accepted

Inserting the figure environment there is not the best idea. For example, even if you say \begin{figure}[htp] and the h option can be honored, the figure will not be printed just after the display.

A figure environment inserted in the mid of a paragraph cancels the space before it, rather than ignoring spaces after it. But in that case it has nothing to cancel out.

I always put my figure and table environment between paragraphs.

If you want to show a picture representing what's in the displayed formula, it's better to put the figure (not in a figure environment) inside the display: the environments available with amsmath allow for multiline displays.

share|improve this answer
    
Thanks. I actually asked more out of curiosity. I completely agree that this placement is not the best idea. –  cgnieder Jan 14 '12 at 18:08

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.