I have table that has long headers and I would like to specify width of the column, but also be able to remain it's centred position.

Something like |c{0.30\textwidth}|.

It is possible? How to achieve this effect?

  • 4
    @lockstep : Why is this one marked as duplicate even though it was asked earlier than the question it allegedly duplicates? Commented May 18, 2017 at 18:38

2 Answers 2


You could use the array package. It provides a way add a \centering command to a p-colum. Here's a tiny example:

first row \\
second row

The general syntax is >{command} before the actual column specifier. \centering changes the meaning of \\, thus \arraybackslash has been used to restore that. Have a look at the array documentation to learn more.

  • I would add \hspace{0pt} to the column definition in order to allow the first word in a cell to be hyphenated.
    – lockstep
    Commented Nov 6, 2010 at 20:34
  • 1
    @lockstep: Good addition, because it's a general issue with narrow columns like chosen in the demo example. In that example code, >{\centering\arraybackslash\hspace{0pt}} would indeed result in a hyphenation.
    – Stefan Kottwitz
    Commented Nov 6, 2010 at 20:43
  • For some reason, (something like) this causes ! Package array Error: Illegal pream-token (\linewidth): `c' used.
    – mirabilos
    Commented Jun 11 at 20:54

In addition to Stefans answer: If you use centered columns with a fixed width quite often, you can define a new column type:


The "x" column takes its width as argument. In your document, you would write e.g.


EDIT: Thanks to an answer from Ulrike Fischer on the German-speaking forum mrunix.de, I learned that there is still room for improvement: One might want to manually break lines within a cell of a "centered" p-column, but \newline doesn't work correctly in this case. Solution: assign the meaning of \\ (as defined by \centering!) to \newline within the cell:

  • 2
    Hey, sorry for necroing this thread, but this doesn't work for me, for some reason. I get following error: Package array Error: Illegal pream-token (3 cm): `c' used. \end{tabularx} While this is my tabular environment definition: \begin{tabularx}{1\linewidth}{| R{0.3\linewidth} | C | C | C |} where R is basically the same as you have with \raggedleft instead of centering, and C the same as your "x"
    – Aeefire
    Commented Jan 5, 2015 at 13:18
  • 1
    @Aeefire maybe because C is already defined, try y instead. Commented Dec 8, 2021 at 14:28

Not the answer you're looking for? Browse other questions tagged .