I tried to apply the method proposed in How to get column alignment in tabularx? to right align cells in a ltablex. However I have a problem when the size of the table is just enough for my columns: some cells end up on two lines, with the first one empty. Here is a minimal example:

\documentclass[a4paper, 12pt]{report}






\begin{tabularx}{160pt}{ X  Y  Z }
% head
  Name & 
  Long~name & 
  Name  \\
  & [unit] & [$longunit$]  \\* 
% foot
% body
\multirow{3}{1.6cm}{Text on two lines} & 0 & 0 \\*
 & 0 & 0   \\*
 & 0 & 0   \\


I get this result:

Compilation result

I found out that removing the \hspace{0pt} in the Y and Z column type definition solves the problem, but as it might be useful in other situations I would like to know if there is a better way to deal with this ?

Also, if I uncomment the line that redefined the tabcolsep, the Y and Z columns become left aligned again. Is there a way to have right aligned or center columns with a lower tabcolsep?


The linebreak you can fix with


\tabcolsep should be set with \setlength not \renewcommand (but it still behaves oddly here, out of time now...)

| improve this answer | |
  • The difference between the two cases (with the setting of \tabcolsep and without) seems to lie in the different branches taken by \ifdim \wd\@tempboxa <\TX@target in \TX@endtabularx. – Dan Oct 8 '13 at 22:05
  • Thank you for your answers. Any news regarding the \setlength of \tabcolsep ? – Don't panic Oct 11 '13 at 8:06
  • @Don'tpanic been busy,perhaps at the weekend... – David Carlisle Oct 11 '13 at 8:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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