Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
3  
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

1 Answer 1

  {\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}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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