Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I've just started to work with latex. I'm aware of the post How to get multiple multirows in a table? but still with it I don't manage to do with my table what I'd like. Basically I'd like to get two multirow cells, one at the beginning and one at the end. It'd also be great if I could vertically center the text and align it to the left (if I set the width I don't know how to do this). There's a last thing I'd also like to do but it's not so important. This is to remove the exterior lines of the only empty cell in my table.

This is the code I've been working with:

\begin{center}
\begin{tabular}{ | p{3cm} | p{3cm} | p{3cm} | p{5cm} |}
\hline
    & 
    Text1 & 
    Text2 & 
    Notes \\ 
\hline
    \multirow{2}{*}
    {Multirow two} &
    Soil &
    Water &
    This should also be multirow (like the first column) \\
    \hline
    &
    Water retention curve $\sin$150g &
    Water retention curve $\sin$200 g 
    & \\
\hline
    This is ok &
    ok &
    ok &
    ok \\
\hline
\end{tabular}
\end{center}
share|improve this question

1 Answer 1

up vote 6 down vote accepted

Here is a way to achieve what you want. It uses the array, tabularx and makecell package. I use the \multirowcell command, from makecell, which has a simpler syntax than multirow. Note that when you use \multirow, you must count the number of lines and not the number of cells if some cells are multilined.

    \documentclass{article}
    \usepackage[showframe, nomarginpar]{geometry}

    \usepackage{array, booktabs, tabularx,makecell}
    \renewcommand{\tabularxcolumn}[1]{>{\raggedright\arraybackslash}m{#1}}
    \renewcommand\cellalign{Xc}

    \begin{document}

    \vspace*{1\baselineskip}
    \centering
    \begin{tabularx}\linewidth{ | *{3}{ >{\raggedright}m{2.8cm}|} X |}
    \cline{2-4}
    \multicolumn{1}{c|}{}  & Text1 & Text2 & Notes \\
    \hline
    \multirow{3}{*}{Multirow two} & Soil & Water & \multirowcell{3}{This should also be multirow (like the first column)} \\
    \cline{2-3}
    & Water retention curve $\sin$\,150\,g & Water retention curve $\sin$\,200\,g  & \\
    \hline
    This is ok & ok & ok & ok \\
    \hline
    \end{tabularx}

    \end{document} 

enter image description here

share|improve this answer
    
Thanks so much! This is a big help to keep learning from this point! –  user3262756 Jul 13 at 20:16
    
You're welcome. Think of taking a look at the packages documentation, you'learn a lot of things. –  Bernard Jul 13 at 20:17
    
There's a little mistake when giving the linewidth: it says 2.8Acm instead of just 2.8cm. –  user3262756 Jul 13 at 21:06
    
That's a typo. I thought I had deleted and didn't check. Thanks. –  Bernard Jul 13 at 21:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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