TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I center the column when using X in tabularx environment like in this example?

 1 & 2 & 3 & 4 & 5 \\   
share|improve this question
do you want to centre an entire column or just one row, or just one cell? – ArTourter Jan 3 '13 at 20:33
Sorry... I want to center all X columns – Matthias Jan 3 '13 at 20:36
Use c instead of X. – m0nhawk Jan 3 '13 at 20:37
up vote 24 down vote accepted

You have two solutions (well at least)

If you are bound to tabularx then you can use

\begin{tabularx}{\textwidth}{@{}l *5{>{\centering\arraybackslash}X}@{}}
1 & 2 & 3 & 4 & 5 & 6\\

Alternatively you can use the tabu package which offers you a lot more flexibility:

\begin{tabu} to \textwidth {@{} l *5{X[c]}@{}}
1 & 2 & 3 & 4 & 5 & 6\\
share|improve this answer
how to do the tabularx for \ruggedright? just replacing centering doesnt work :( – ankhi Sep 26 '14 at 19:04
@ankhi probably because it is spelt \raggedright! However, a solution to this question (and this really should be a separate question rather than a comment to a vaguely related one), is given in this answer which uses the same package as suggested by herbert below – ArTourter Sep 27 '14 at 0:45

Although this question is somewhat old, since I recently dealt with the same task, I present my solution: I defined a new columntype Y to center the cells in a tabularxenvironment.

In the preamble define:


to typeset the example simply enter

 1 & 2 & 3 & 4 & 5 & 6\\   
share|improve this answer
This is beautiful. Works nicely! – Trefex Apr 7 '14 at 16:15

with ragged2e you do not need the \arraybackslash

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.