2

I'm trying to create a table where some of the columns are are meant to be centrally (vertically) aligned, and some are meant to be at the top. It appears that using the 'm' column type for centering vertically affects the p type of column. (I do know about newcolumncommand, I'm just using this as a minimalistic example).

\documentclass{article}
\usepackage{array}

\begin{document}

\begin{tabular}{|p{0.2\textwidth}|>{\centering\arraybackslash}m{0.2\textwidth}|>{\centering\arraybackslash}m{0.08\textwidth}|} \hline
I am not at the top of this cell & Longer Line that is centred and wrapped, and appears in the correct place & Small \\ \hline
\end{tabular}

\end{document}

Oddly Aligned Table

What I'm really wanting is something that looks more like this:

enter image description here

I generally like to use tabu rather than tabular, I had similar troubles with that as I am with tabular here.

Does anyone have a simple solution? Thanks.

2 Answers 2

1

An alternative solution which also need manual tweaking of final layout:

\documentclass{article}
\usepackage{array, makecell, multirow}
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
\newcommand\mrc[2]{\multirowcell{#1}{#2}}% #1 number of lines in the tallest cell

\begin{document}
\begin{tabular}{|p{0.2\textwidth}|P{0.3\textwidth}|P{0.2\textwidth}|} 
    \hline
I am at the top of this cell 
    &   Longer Line that is centered and wrapped, 
        and appears in the correct place of this 
        LibreOffice Writer table, started at the top of cell
        &   \mrc{7}{Small}    \\ % <-- the tallest cell has 7 lines ...
    \hline
\end{tabular}
\end{document}

enter image description here

0
\documentclass{article}
\usepackage{array}
\begin{document}
\begin{tabular}{|p{0.2\textwidth}|>{\centering\arraybackslash}m{0.3\textwidth}|>{\centering\arraybackslash}m{0.2\textwidth}|} \hline
\vspace{-1.35cm}I am not at the top of this cell & Longer Line that is centred and wrapped, and appears in the correct place of this LibreOffice Writer table & Small \\ \hline
\end{tabular}
\end{document}

tblenew

1
  • Well, that certainly is a... simple solution. I presume with this response that there's no simple way to do the alignment with LaTeX working out the correct spacing? Apr 23, 2016 at 9:56

You must log in to answer this question.

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