# How to obtain a fixed gap between columns in a table?

How can I center a column of a table which is raggedleft/raggedright at a specified position?

Basically the length between W and X, X and Y and Y and Z should be the same, W should be raggedright, Z should be raggedleft. The positions of W and Z are already very near to what I want but the columns under them aren't centered...

The first image is what I got already and the second one is my aim.

And a MWE:

\documentclass[11pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage{array}

\begin{document}

\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}

\begin{tabular}{m{1cm}C{1.3cm}C{1.3cm}R{1cm}}
\textbf{W}& \textbf{X} & \textbf{Y} & \textbf{Z} \\
\hline
\textbf{A n.c.} & 23,2 & 23,2 & 33,4 \\
\textbf{B} & 4 & 5 & 6 \\
\textbf{C} & 7 & 8 & 9 \\
\textbf{D} & 10 & 11 & 12 \\
\textbf{E} & 13 & 14 & 15 \\
\end{tabular}

\end{document}


Most of the code I got from here.

-

I'm more going towards what you're after than what you currently have...

Specifying a fixed distance between columns is best done using the @{..} specification. So, for example, one could use l@{\hspace{1cm}}c to denote a 1cm gap between a left and centred column.

\documentclass{article}
\usepackage{booktabs}% http://ctan.org/pkg/booktabs

\begin{document}

\begin{tabular}{l@{\hspace{1cm}}c@{\hspace{1cm}}c@{\hspace{1cm}}c}
\toprule
\textbf{W} & \textbf{X} & \textbf{Y} & \textbf{Z} \\
\midrule
\rlap{\textbf{A n.c.}}\hphantom{23,2} & 23,2 & 23,2 & 33,4 \\
\textbf{B} & 4 & 5 & 6 \\
\textbf{C} & 7 & 8 & 9 \\
\textbf{D} & 10 & 11 & 12 \\
\textbf{E} & 13 & 14 & 15 \\
\bottomrule
\end{tabular}

\end{document}


The additional play with lengths and text in the tabular body is to obtain make the columns the same widths in terms of the contents.

-
Thank you, that worked. I didn't used the additional lines and phantoms. Should I change the title to a more fitting one? And if so what would you suggest? – Tim Jul 23 '14 at 17:17
@TimS.: If you'd like. How about "How to obtain a fixed gap between columns in a table?" – Werner Jul 23 '14 at 17:18