[Tex/LaTex] Local scoping of textfloatsep

floatslengthsspacing

I was wondering if you can set the scope of \textfloatsep locally. I have found an old thread on Google groups, which points out that you couldn't.

Has that changed by now? So what I want to do is simply to set \textfloatsep to zero for only one table keeping the remaining tables unaffected.

edit: I thought about it and wouldn't be a manual solution to set it to zero just before the float and reverse to the original value afterwards?

\documentclass[a4paper, 12pt, headsepline, headings=small,]{scrreprt}
\usepackage[onehalfspacing]{setspace}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{booktabs}
\usepackage[pangram]{blindtext}


\begin{document}

\chapter{Tables}

\Blindtext[1][1]
\begin{table}[!t]
\centering
\caption{Table caption} 
\fbox{X-Table}
\end{table}
\Blindtext[1][1]

\Blindtext[1][1]
\begin{table}[!t]
\centering
\caption{Table caption} 
\fbox{Y-Table}
\end{table}
\Blindtext[1][1]

\end{document}

Best Answer

You reference \textfloatsep, which relates to floats at the top/bottom of the page (see How to change the spacing between figures/tables and text?), yet your example doesn't include something like that. However, the setting of this length should take into consideration when it's used. If you manually set it to 0pt before a figure and then reset it to the default value after the figure, hoping that it would affect that specific figure you may not see the expected results. This is because the length is only used when the figure is set on the page, at which time you may have reverted back the default length...

One way around this (and this depends highly on your page/float configuration) would be to set the length to (say) 0pt before the float, and then use the afterpage package to reset it to the default. Here's a view on that:

\usepackage{afterpage}% http://ctan.org/pkg/afterpage
\newlength{\oldtextfloatsep}\setlength{\oldtextfloatsep}{\textfloatsep}

% ...

\setlength{\textfloatsep}{0pt}% Remove \textfloatsep
\begin{table}[tb]
  % <your figure here>
  \afterpage{\global\setlength{\textfloatsep}{\oldtextfloatsep}}% Reset \textfloatsep
\end{table}
Related Question