How to center a text in a table? [duplicate]

Possible Duplicate:
Center column with specifying width in table (tabular enviroment)?

I want to fix this code, the last column aren't center in the cell. How can I center the text of all table? I get an error.

\documentclass[10pt,a4paper]{article}
\title{\textbf{Title}}
\usepackage[spanish]{babel}
\usepackage[utf8]{inputenc}

\usepackage{pdflscape}
\usepackage{color, colortbl}
\definecolor{Gray}{gray}{0.9}
\usepackage{enumitem}
\usepackage{anysize}
\marginsize{3cm}{3cm}{2.5cm}{2.5cm}

\usepackage{xcolor}
\usepackage{caption}
\captionsetup[table]{skip=10pt}
\usepackage{threeparttable}

\begin{document}

\begin{table}[h]
\begin{threeparttable}
\caption{Tabla\tnote{1}}
\centering
\begin{tabular}{|p{18mm}|p{35mm}|p{20mm}|p{30mm}|p{22mm}|}
\hline \rowcolor{Gray}
\centering \textbf{Text} & \centering \textbf{Text} & \centering\textbf{Text} & \centering\textbf{Text} & {\centering\textbf{Text}}\\[0.5ex]
\hline
176682 & text & text & text & text\\
\hline
176682 & text & text & text & text\\
\hline
176682 & text & text & text & text\\
\hline
176682 & text & text & text & text\\
\hline
text & text & text & text & text\\
\hline
text & text & text & text & text\\
\hline
text & text & text & text & text\\
\hline
\end{tabular}
\begin{tablenotes}
\item[1] Source.
\end{tablenotes}
\end{threeparttable}
\end{table}

\end{document}

• You can define a newcolumntype. something like \newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}} and use C{22mm} as column instead of p{22mm} Dec 13 '12 at 5:32
• See if this post helps you tex.stackexchange.com/questions/5017/… Dec 13 '12 at 5:33
• Thanks a lot, it works: \begin{tabular}{|>{\centering\arraybackslash}p{18mm}|>{\centering\arraybackslash}p{35mm}|>{\centering\arraybackslash}p{20mm}|>{\centering\arraybackslash}p{30mm}|>{\centering\arraybackslash}p{22mm}|}
– Isai
Dec 13 '12 at 5:53
• Good to hear that. You can also shorten your code by defining the columntype C as I had in my first comment. I will flag this question as a duplicate of the linked post. Dec 13 '12 at 6:02