20

I have a document with many occurrences of

\begin{tabular} 
... 
\end{tabular}

I have been unable to find a global command that will reduce the vertical space before and after this environment. Any help appreciated. Here is the context:

\documentclass{report}
\usepackage{setspace,relsize,needspace,etoolbox}
\makeatletter
\preto{\@verbatim}{\topsep=-1.5pt \partopsep=-1pt }
\makeatother
\parskip 14pt
\parindent 0ex
\setstretch{1}
\begin{document}
\rule{\linewidth}{1mm}
\vspace*{\stretch{2}}
\vspace{.3in}
. . . 
\begin{spacing}{0.7}
\vbox{\noindent\textbf{re : Race/Ethnicity}
{\smaller
\begin{tabular}{ rrr }
n&missing&unique \\
4269&0&5 \end{tabular}
\begin{verbatim}
Mexican American (744, 17%), Other Hispanic (478, 11%) 
Non-Hispanic White (2103, 49%), Non-Hispanic Black (762, 18%) 
Other Race Including Multi-Racial (182, 4%) 
\end{verbatim}
}}

As Peter Grill stated (even though I didn't write a completely executable example) the act of simplifying is very useful - I think the \parskip is much of my problem. I think a solution to this is:

\usepackage{etoolbox}
\makeatletter
\preto{\@tabular}{\parskip=0pt}
\makeatother

which gets rid of extra space before the tabular but leaves too much afterwards.

The reason I've set parskip and parindent as I have (14pt, 0ex) is that this is for handouts for a course that also look decent when projected on a screen, i.e., this is a cross between printed and projected material.

David Carlisle
  • 757,742
  • 7
    The environment tabular doesn't add any vertical skip. – Marco Daniel Mar 13 '12 at 19:58
  • 2
    Welcome to TeX.sx! Please add a minimal working example (MWE) that illustrates your problem. – Werner Mar 13 '12 at 20:01
  • I'm sorry that I didn't post an example. The code I'm using is fairly complex and lengthy but I'll try to list in the original question above the various packages that may be interacting with tabular to cause the problem. – Frank Harrell Mar 13 '12 at 20:33
  • 3
    While listing the packages and code snippets are useful in explanations, it is always best to compose a fully compilable MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. Personally, I have often solved my own problems in the process of reducing the amount of code actually required to reproduce the problem. – Peter Grill Mar 13 '12 at 20:35
  • Sorry, I don't understand. It would be nice if you make this a complete question, with a compilable example that clearly shows the problem. And, if you have a solution that works for you, add a separate answer -- self-answers are fine. Then this question would be useful as it will help others in the future who attempt to do something similar. Furthermore, if others have a better suggestion they can post additional answers as well. – Peter Grill Mar 14 '12 at 16:46

1 Answers1

15

Have you tried to add this command to your preamble?

\setlength{\textfloatsep}{0.1cm}

You can globally change parskip using

\addtolength{\parskip}{-0.5mm}

Set the values to fit your needs.

Hope this helps.

Faheem Mitha
  • 7,778
JuanPi
  • 273
  • 5
    Perhaps you could elaborate on what the length \textfloatsep references in terms of figures and text. – Werner Mar 28 '12 at 07:04
  • 2
    textfloatsep is the separation between floats and text. You can regulate how much space is left before and after. You can get more information here and here. The package titlesec is a powerful one, but changes many many things. – JuanPi Mar 30 '12 at 10:46
  • 2
    The \addtolength{\parskip}{-0.5mm} worked for me, but the first command seemed to not have any effect. – travelingbones Dec 16 '16 at 16:03
  • 3
    Neither of these worked for me but adding \setlength{\intextsep}{6pt} to the preamble did the trick. This answer from @Werner really helped, too: https://tex.stackexchange.com/questions/36361/how-can-i-inject-the-proper-amount-of-vertical-space-between-captions-and-figure/36362#comment72508_36362 – Omar Wasow Aug 23 '17 at 21:31
  • 4
    I'm concerned that changing those variables might change the behavior of other environments, rather than just for the tabular environment. Is there an option specific to tabular? – jvriesem Dec 15 '18 at 19:22
  • 1
    careful with \addtolength{\parskip}{-0.5mm}, it will globally change how long the distance between paragraphs is, including the ones in the text bodies – BlkPengu Aug 17 '21 at 11:41
  • @JuanPi I just came across this question and tried using \setlength{\textfloatsep}{0.1cm}. It does work when there comes more text after a table but it doesn't change anything when a table is followed by a new section. Do you have any idea how to adjust the space after a table in case it ends a section and a new section begins thereafter? – Dominik Nov 11 '21 at 15:16
  • @Dominik sorry, I see the issue but have no answer. I think this space is controlled by the section style. So one would need to look at the definition of those lengths in the documentclass file. Or search for "space before after section", e.g. https://tex.stackexchange.com/questions/108684/spacing-before-and-after-section-titles – JuanPi Nov 13 '21 at 03:46