9

How can I control the vertical space before an environment, e.g., tabular or minipage?

Here is an example that reproduces my problem:

\documentclass{article}
\begin{document}
    \noindent TEXT-A\vspace{5pt}\\   TEXT-B\\TEXT-C
    \\[2em]
    \noindent TEXT-D\vspace{5pt}\\   \begin{tabular}{@{}l}TEXT-E\\TEXT-F \end{tabular}
\end{document}

The spacing between TEXT-A and TEXT-B is different from the spacing between TEXT-D and TEXT-E:

alt text

I have learned so far that the space between TEXT-D and TEXT-E is normal if I delete \\TEXT-F:

alt text

Any help would be appreciated!

1 Answer 1

14

Inserting vertical space by \vspace{5pt}\\ is not a good way. It does not end the paragraph, \\ just breaks the line. And consider a line break after vertical whitespace - which line should be broken then?

Instead of \\ use a blank line or write \par to end the paragraph. A line break will be a consequence as well. After the paragraph break you may insert vertical space. Perhaps \smallskip, \medskip or \bigskip could be a good idea. I don't like it to manually distribute a lot of spaces (some points here, some there) through the document. If you later desire to stretch or to shrink a bit, you would have to adjust at many places. Better use macros or lengths for that, which could be adjusted in the preamble.

Back to the main problem.

  • Some environments insert vertical space before. For example displayed formulas insert certain space (\abovedisplayskip or abovedisplayshortskip), list environments like itemize, enumerate and description but also center and quote insert space of the length \topsep. Such spaces could be adjusted, but it depends on the environment.

  • If you use a class which tries to fill up the page, like the book class, vertical space could be inserted for this purpose. You could try the command \raggedbottom just to see the effect without that vertical justification.

  • In the case of tabular and minispace, add the optional argument [t] for top alignment:

    \begin{tabular}[t]{@{}l} ...

We could speak about further details if you post a small compilable example which shows the problem. If you didn't manage it yet: don't try to reproduce starting from scratch. Instead take a copy of your document, and reduce it step by step, compile each step o ensure it's still showing the problem. This way you would get a demonstration example.

4
  • Thanks for the comments, I have been able to reproduce the problem, see above...
    – u17
    Dec 7, 2010 at 20:56
  • @Frank: in this case adding an optional parameter [t] for top alignment of the table would be sufficient. I'll add that to my answer.
    – Stefan Kottwitz
    Dec 7, 2010 at 21:04
  • That's right. Based on previous trouble with vertical alignment and glue, I have blamed the wrong thing. Many thanks!
    – u17
    Dec 7, 2010 at 21:14
  • [t] worked for me! I don't understand why though. Oct 10, 2014 at 9:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .