# Trying to center the contents of only 1st row cells

Similar to this question but not sure if mine is exactly the same???

I am trying to center just the first row of cells in tabularx environment, leaving the rest left/justified.

\documentclass{report}
\usepackage{tabularx}
\begin{document}
\begin{tabularx}{\textwidth}{|X|X|X|}
\hline
\centering \textbf{a} & \centering \textbf{b} & \textbf{c} \\
\hline
a & b & c \\
\hline
\end{tabularx}
\end{document}


When I add \centering to the last cell in the 1st row, it throws

Misplaced \noalign. \end{tabularx}

I know I can circumvent that by adding $\;\;\;\;\;\;\;\;$ in front of the cell content to approximately center it, but it's ugly.

• try \centering \textbf{a} & \centering \textbf{b} & \centering\arraybackslash\textbf{c}  but better is use multicolumn{1}{c}{...} environment ... – Zarko Oct 27 '16 at 20:32

\centering redefines \\, thus it won't no longer work as end of line in a tabular. But there is \tabularnewline:

\documentclass{report}
\usepackage{tabularx}
\begin{document}
\noindent
\begin{tabularx}{\textwidth}{|X|X|X|}
\hline
\centering \textbf{a} & \centering \textbf{b} & \centering \textbf{c}
\tabularnewline
\hline
a & b & c \\
\hline
\end{tabularx}
\end{document}