5

I would like to know how to put vertical centered text inside a table cell.

The problem with m column type is that i'm actually using tabularx to auto detect the width of the columns

\newcolumntype{Y}{>{\small\centering\arraybackslash}X}
\begin{tabularx}{\textwidth}{YYY}
   & Lorem ipsum \newline Lorem ipsum dolor sit amet, consectetur adipisicing & Lorem ipsum \newline Lorem ipsum dolor sit amet, consectetur adipisicing \\
Lorem ipsum Lorem ipsum dolor sit amet, consectetur adipisicing & A & B \\
Lorem ipsum Lorem ipsum dolor sit amet, consectetur adipisicing & C & D \\
\end{tabularx}

I would like to vertical centering in the boxes the A, B, C, D text

1
  • 1
    Providing an example of what you have done or image of what you are looking for helps everyone understand your question a bit better.
    – azetina
    Commented Apr 16, 2012 at 19:35

2 Answers 2

7

The tabularx documentation gives an explicit example of using an m column with small text

 \renewcommand{\tabularxcolumn}[1]{>{\small}m{#1}}

Your column definition already adds \small so you just need to make X use m instead of p so

\renewcommand{\tabularxcolumn}[1]{m{#1}}
5

Instead of using tabularx, you could use the features provided by the tabu package:

\documentclass{article} 
\usepackage{tabu}

\begin{document}

\everyrow{\rowfont{\small}}
\noindent\begin{tabu} to\linewidth{X[c,m]X[c,m]X[c,m]}
   & Lorem ipsum\par Lorem ipsum dolor sit amet, consectetur adipisicing & Lorem ipsum \par Lorem ipsum dolor sit amet, consectetur adipisicing \\
Lorem ipsum Lorem ipsum dolor sit amet, consectetur adipisicing & A & B \\
Lorem ipsum Lorem ipsum dolor sit amet, consectetur adipisicing & C & D \\
\end{tabu}

\end{document}

enter image description here

You must log in to answer this question.

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