0

It is my first question on this site. I am not sure my LaTeX code will be well written here. Here is my table code. The problem is that the text in the first four columns are not centered in respect to each cell. When I write a small text in the X column , the content of the others four culumns are well centered. But it is not the case when i put a long text in the last colum X. Note that the content of the X column have to be justified. What is the solution to that?

\begin{sidewaystable}[h]
\footnotesize
\centering
\renewcommand{\arraystretch}{1.5}
\begin{tabularx}{\textwidth}{c >{\centering\arraybackslash}m{1.5cm} >{\centering\arraybackslash}m{4.3cm} X}
\hline
text & text  & text & text & very big text \\
\hline
 text & text & text & text & VERY BIG TEXT \\
\hline
 text & text & text & text &  VERY BIG TEXT \\
\hline
\end{tabularx}
\captionsetup{justification=centering,margin=2cm,font={small}}
\caption{.........}
\captionsetup{font={scriptsize}}
\label{.....}
\caption*{......}
\end{sidewaystable}
  • Sorry I did'nt understand. I want five columns. Each cell of the first four colums have to be centered (positionned at the center of the cell itself). The column X have to be justified. When there is a big text in the column X, the others cells are centered with respect to the column but not respect to the raw). I hope i made my self clear. I don't have good english :-( – Houssem Nov 13 '13 at 3:15
  • See the new version, with 5th column added. BTW: a better place to responding to one's answer is under it. – Przemysław Scherwentke Nov 13 '13 at 3:26
  • Thank you but as you see in the new version the cells remain not centered. If you look to the 3rd line, you can easily see that text are positionned in the center of the columns but not in the center of the line (it means center of the cell). This problem is more accurate when the text in the 5th column X is really big. Thank you anyway. – Houssem Nov 13 '13 at 3:40
  • 1
    Oh! You want last column VERTICALLY aligned! See the third version. The last change marked PS (3). – Przemysław Scherwentke Nov 13 '13 at 4:08
  • This is really what i want, even i did'nt understand the \def\tabularxcolumn#1{m{#1}}. Thanks ! – Houssem Nov 13 '13 at 9:48
0

Your example is modified to show important fragments. Therefore, e.g. sidewaystable is changed onto table.

\begin{document}

%\begin{sidewaystable}[h]
\begin{table}[h]
\footnotesize
\centering
\renewcommand{\arraystretch}{1.5}
%\begin{tabularx}{\textwidth}{c >{\centering\arraybackslash}m{1.5cm} >{\centering\arraybackslash}m{4.3cm} X}
\def\tabularxcolumn#1{m{#1}} % PS (3)
\begin{tabularx}{\textwidth}{c >{\centering\arraybackslash}m{1.5cm} >{\centering\arraybackslash}m{4.3cm} cX}

\hline
%text & text  & text & text & very big text \\
text & text  & text & text  & very big text \\
\hline
% text & text & text & text & VERY BIG TEXT \\
text & text  & text  &  text  &very big text \\
\hline
% text & text & text & text &  VERY BIG TEXT \\
text text & text text text  & text   text text text  text text text text text text  &text & very big text 
 text text text  text text text  text text text 
\\
\hline
\end{tabularx}
%\captionsetup{justification=centering,margin=2cm,font={small}}
\caption{.........}
%\captionsetup{font={scriptsize}}
%\label{.....}
%\caption*{......}
%\end{sidewaystable}
\end{table}

\end{document}

enter image description here

|improve this answer|||||

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.