4

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}
3

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}
  • hmm assuming you have finished the page (and nearby pages as well) and know for certain that the table is placed there on the top, would the solution be any different? Edit: I don't think so. So it can only be done with afterpage – TomM Jan 13 '14 at 19:51
  • @TomM: You may have to play around with the location of \afterpage, since it all depends on where the float is placed in relation to your code (remember, the float). – Werner Jan 13 '14 at 19:53
  • 1
    alright this does the job, but there could be done a lot of optimizing. I understand the position of the float can change any time you compile, but at some point it has to be determined and then textfloatsep would ideally be applied. – TomM Jan 13 '14 at 19:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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