# Rule between environments (no spacing!)

I want to place a rule between two centered tabulars like the following example. But I am not able to control the correct spacing of 2mm in between the rule. Can somebody maybe explain :-) what should be added and why the several spacing commands should be added to obtain the result of 2mm vertical space between the rules?

\documentclass[12pt,a4paper,fleqn]{scrreprt}

\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}

\usepackage{fancyhdr}
\usepackage{chappg}
\usepackage{wrapfig}

\usepackage{xspace}
\usepackage{latexsym}
\usepackage{amsmath}
\usepackage{amssymb}

\usepackage{graphicx}
\usepackage{tabularx}
\usepackage{array}
\usepackage{colortbl}

\begin{document}
{\centering%
\begin{tabularx}{\textwidth}{ASBSCSM}%
\cellcolor[gray]{0.9}Name && \cellcolor[gray]{0.9}Vorname && \cellcolor[gray]{0.9}ETH-Nummer && \cellcolor[gray]{0.9}Studiengang \\[0.6cm]%
\end{tabularx}%
}
\vspace{2mm}%
\rule{\textwidth}{1pt}%
\vspace{2mm}%
{\centering%
\begin{tabularx}{\textwidth}{ASBSCSM}%
\cellcolor[gray]{0.9}Name && \cellcolor[gray]{0.9}Vorname && \cellcolor[gray]{0.9}ETH-Nummer && \cellcolor[gray]{0.9}Studiengang \\[0.6cm]%
\end{tabularx}%
}
\end{document}

-
Please, make the MWE self-contained; it's not possible to compile it, as the ABCSM column types are not defined. –  egreg Jan 11 '13 at 10:36

  {\centering%
\begin{tabularx}{\textwidth}{ASBSCSM}%
\cellcolor[gray]{0.9}Name && \cellcolor[gray]{0.9}Vorname && \cellcolor[gray]{0.9}ETH-Nummer && \cellcolor[gray]{0.9}Studiengang \\[0.6cm]%
\end{tabularx}%
}


will not center anything as the centering ends at the } before th eparagraph ends, it does have a side effect of suppressing paragraph indentation (or at least making it 0) which is needed for a full width table, but it is probably simpler to use \noindent or just use a single \centering at the start of the environment with no extra {}.

\rule will start a new line of a paragraph so you get inter-line \baselineskip which you don't really want.

You need to use \vspace{2mm} between paragraphs or the space comes after the current line, which usually isn't where you want it. (As posted in your example the entire float with both tabularx and the rule is all a single paragraph.)

this is untested as your posted code can not be run but

\begin{center}
\begin{tabularx}{\textwidth}{ASBSCSM}%
\cellcolor[gray]{0.9}Name && \cellcolor[gray]{0.9}Vorname && \cellcolor[gray]{0.9}ETH-Nummer && \cellcolor[gray]{0.9}Studiengang
\end{tabularx}

\vspace{2mm}
\hrule
\vspace{2mm}

\begin{tabularx}{\textwidth}{ASBSCSM}%
\cellcolor[gray]{0.9}Name && \cellcolor[gray]{0.9}Vorname && \cellcolor[gray]{0.9}ETH-Nummer && \cellcolor[gray]{0.9}Studiengang
\end{tabularx}
\end{center}

-