get can't get local scoping of \setlength\{textfloatsep}{}

913 views
Skip to first unread message

chemist

unread,
Mar 20, 2009, 9:56:52 PM3/20/09
to LaTeX Users Group
I'm trying to set textfloatsep to 0 for just a single figure, using:

\setlength{\textfloatsep}{0pt}
\begin{figure}[!ht]
\centering
\includegraphics[scale=1]{figure.pdf}
\caption[short caption]{long caption.}
\label{fig:fig1}
\end{figure}

If I enter it this way, it works, but applies to all figures. When I
try to limit its scope by either placing brackets around the entire
above code set, or by putting the \setlength command inside the figure
environment, this \setlength command is not recognized at all. I've
also tried \addtolength, with the same results. Any suggestions?

Note that if I first use \setlength{\textfloatsep}{0pt} before the
fig., and then try to reset to the defaults with \setlength
{\textfloatsep}{20pt plus 2pt minus 4pt} after the fig., nothing
happens, because Tex only implements the last command, so all figures
are treated with the default setting.

I.e., in summary, outside of an environment restriction, the command
is global, but inside of one it is not recognized. Maybe \setlength
and \addtolength are "global" commands that can't be scoped. But
hopefully there is some way to do this....

Werner Grundlingh

unread,
Mar 21, 2009, 1:53:56 AM3/21/09
to LaTeX Users Group
I would think that the your are incorrect in your assumption in the
last paragraph. Figures (like any other 'floating environment')
receive special treatment. Consequently, if they are allowed to float/
move around in the document, scoping is necessarily irrelevant. So,
although it is possible to scope even the \textfloatsep length, it
would not matter.

As an alternative suggestion, I would add negative vertical space
(something like \vspace{-2ex} or \vskip-2ex) within the figure
environment either just before the \end{figure} or just after the
\begin{figure} definition, depending on whether the figure ends up at
the top or bottom of the page.

Werner
Message has been deleted

chemist

unread,
Mar 21, 2009, 8:29:28 PM3/21/09
to LaTeX Users Group
Thanks for the suggestions. Unfortunately, they had no effect. In
the meantime, what did work was simply completely removing the [!ht]
options (and it's not the !ht in particular -- anything between those
brackets gives the same problem). You made a suggestion that depends
on where the figure ends up on the page (where to put the negative
vert space). I should thus clarify that the figure in question takes
up the whole page. An earlier solution, which I found
unsatisfactory,
was simply to change the scale from 1.0 to 0.95. So the problem was
that, with the figure at full size, LaTeX didn't think it had enough
room for both the figure and the textfloatsep, so it put the figure
at
the end. That's why reducing textfloatsep to zero fixed the problem
with that figure (keeping it in the middle of the document, where it
belonged) (but this of course also messed up all my other figs, which
need the default value of textfloatsep). I don't understand why
removing the options fixed the problem.

Thanks also for your explanation about scoping. I understand your
comments about scoping to mean that LaTeX scoping restricts a command
to within a certain part of the document (i.e., to within a certain
set of text)---and that this type of scoping won't work for floats,
because they don't have set locations. I.e., they ... float! So
what
would really be needed if one wanted to restrict the value of
textfloatsep to apply only to a given figure would be a "floating
scope" that extends from the end of a particular figure's environment
to the text immediately following the figure ... which may not be
within LaTeX's current capabilities.
Reply all
Reply to author
Forward
0 new messages