[Tex/LaTex] Centering a tabularx

horizontal alignmenttabularx

I want to center a tabularx, not the cells content, but the table itself. 
Reading things about tabular, I tried \centering.

Here is my mwe:

% arara: xelatex
% arara: xelatex

\documentclass{scrartcl}

\usepackage{array}
\usepackage{tabularx}

\newcolumntype{°}{>{\global\let\currentrowstyle\relax}}
\newcolumntype{^}{>{\currentrowstyle}}

\begin{document}

{\small
\centering
\begin{tabularx}{200pt}{@{}°c^c^c@{}}
a & b & c
\\
d & e & f
\\
\end{tabularx}
}

\end{document}

It normally renders the tabularx, but not centered.
I also tried \begin{center}\end{center} but without any success.

How do I center it?

Best Answer

You use tabularx that needs at least one column of type X wich adjusts its width to fill and fit the width you gave initially as parameter.

Secondly you ask for a tabular of all linewidth. That means already centered as using all free space.

Here is something centered with one X column.

enter image description here

\documentclass{scrartcl}

\usepackage{array}
\usepackage{tabularx}

\newcolumntype{°}{>{\global\let\currentrowstyle\relax}}
\newcolumntype{^}{>{\currentrowstyle}}

\begin{document}

Left\dotfill

\begin{center}
\small
\begin{tabularx}{.5\linewidth}{@{}°c^Xc@{}}\hline
a & b & c
\\
d & e & f
\\\hline
\end{tabularx}
\end{center}

\dotfill Right

{\small
\hfill\begin{tabularx}{.5\linewidth}{@{}°c^Xc@{}}\hline
a & b & c
\\
d & e & f
\\\hline
\end{tabularx}\hfill\strut
}

Left\dotfill
\end{document}
Related Question