3

I'm trying to create multiple tables with the same width, alignment and spacing. All tables looks fine, except for the first one after the section...

\section*{Section}
\begin{tabu}to \textwidth {|p{3cm}|X|}
  \hline
  tabu1 & test \\ \hline
  test & test \\ \hline
\end{tabu}
\vspace{1em}
\begin{tabu}to \textwidth {|p{3cm}|X|}
  \hline
  tabu2 & test \\ \hline
  test & test \\ \hline
\end{tabu}
\vspace{1em}
\begin{tabu}to \textwidth {|p{3cm}|X|}
  \hline
  tabu3 & test \\ \hline
  test & test \\ \hline
\end{tabu}
\vspace{1em}
\begin{tabu}to \textwidth {|p{3cm}|X|}
  \hline
  tabu4 & test \\ \hline
  test & test \\ \hline
\end{tabu}

enter image description here

How to add the vspace to the first table and why is it like it is?

  • Welcome. Could you provide a full minimal working example with \documentclass and \end{document} – Bobyandbob Mar 29 '18 at 9:33
2

As you have entered it, the \vspace's don't come into effect until there is a linebreak in the output (and then they accumulate). Cf.

Sample output

\documentclass{article}

\begin{document}

text\vspace{1em}text\vspace{1em}text\vspace{1em}
text\vspace{1em}text\vspace{1em}text\vspace{1em}
text\vspace{1em}text\vspace{1em}text\vspace{1em}
text\vspace{1em}text\vspace{1em}text\vspace{1em}
text\vspace{1em}text\vspace{1em}text\vspace{1em}
text\vspace{1em}text\vspace{1em}text\vspace{1em}
text\vspace{1em}text\vspace{1em}text\vspace{1em}
text\vspace{1em}text\vspace{1em}text\vspace{1em}
text\vspace{1em}text\vspace{1em}text\vspace{1em}

\end{document}

Instead you need to end the paragraph before adding the \vspace. You will discover you need to cancel the paragraph indent too with a \noindent:

Sample two

\documentclass{article}

\usepackage{tabu}

\begin{document}

\section*{Section}

\begin{tabu}to \textwidth {|p{3cm}|X|}
  \hline
  tabu1 & test \\ \hline
  test & test \\ \hline
\end{tabu}

\vspace{1em}\noindent
\begin{tabu}to \textwidth {|p{3cm}|X|}
  \hline
  tabu2 & test \\ \hline
  test & test \\ \hline
\end{tabu}

\vspace{1em}\noindent
\begin{tabu}to \textwidth {|p{3cm}|X|}
  \hline
  tabu3 & test \\ \hline
  test & test \\ \hline
\end{tabu}

\noindent
\begin{tabu}to \textwidth {|p{3cm}|X|}
  \hline
  tabu4 & test \\ \hline
  test & test \\ \hline
\end{tabu}

\end{document}

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.