2

So I'm creating some tables and trying to use the array package to vertically align the text in some of my columns. Unfortunately whether I use p{xcm}, m{xcm} or d{xcm} the column is always aligned to the top of the cell.

My code is like this

    \begin{center}
    \begin{tabularx}{\textwidth}{|m{4cm} X|}
    \hline
    Text that should center align & Lorem ipsum dolor sit amet,
    eros elitr dolore sea et, vel ut enim vocent eligendi, quem maluisset urbanitas in      
    mei. Cu mea stet vivendum. Vis agam salutatus laboramus no. 
    Usu natum laboramus ullamcorper an.
    Lorem ipsum dolor sit amet, eros elitr dolore sea et, vel 
    ut enim vocent eligendi, quem maluisset urbanitas in mei. 
    Cu mea stet vivendum. Vis agam salutatus laboramus no. Usu natum
    laboramus ullamcorper an. \bigstrut \tabularnewline
    \hline
    \end{tabularx}
    \end{center}

As you can see, the size of the each row (There is only one in my example to save space here) swells to increase the height of the row, and I would like the left hand column to center align vertically, but without a functioning array package this doesn't happen.

1
  • Sorry, the \n were markers for me that weren't supposed to be on the query. That is the whole example or did you mean the document preamble?
    – hfmaciver
    Nov 28, 2013 at 11:43

1 Answer 1

6

You have to redefine \tabularxcolumn to use m placement; this can be done locally in the center environment, so it will affect only the tabularx in the same environment.

\documentclass{article}
\usepackage{array,tabularx}
\begin{document}

\begin{center}
\renewcommand{\tabularxcolumn}[1]{m{#1}}
\begin{tabularx}{\textwidth}{|m{4cm} X|}
\hline
Text that should center align & Lorem ipsum dolor sit amet,
eros elitr dolore sea et, vel ut enim vocent eligendi, quem maluisset urbanitas in
mei. Cu mea stet vivendum. Vis agam salutatus laboramus no.
Usu natum laboramus ullamcorper an.
Lorem ipsum dolor sit amet, eros elitr dolore sea et, vel
ut enim vocent eligendi, quem maluisset urbanitas in mei.
Cu mea stet vivendum. Vis agam salutatus laboramus no. Usu natum
laboramus ullamcorper an. \\
\hline
\end{tabularx}
\end{center}

\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 .