0

I want to create a table with different numbers of rows on two columns, for example 5/4, 7/3, 2/3,... On each columns rows have to be equally divided in the vertical dimension. That means, for a 5/4, the height of the first column rows will be smaller than the height of the second column rows, but the total height of the first column will be equal to the total height of the second column.

Here a MWE with my different attempts:

\documentclass{report}

\usepackage[table]{xcolor}
\usepackage{multirow}
\usepackage{makecell}

\begin{document}

  % Using only multirow
  \begin{tabular}[c]{|c|l|}
    \hline
    \rowcolor{blue!70}
    \multicolumn{2}{|c|}{}\\
    \hline

    \multirow{4}{5cm}{
      \centering
      World company\newline
      Main Street\newline
      World Capital\newline
      Earth\newline
      Tel: +00~1~23~45~67~89
    }

     & Alphonse \\
    \cline{2-2}
     & Daudet \\
    \cline{2-2}
     & Marcel \\
    \cline{2-2}
     & Pagnol \\
    \hline
  \end{tabular}

  \vspace{4\baselineskip}

  % Using makecell
  \begin{tabular}[c]{|c|l|}
    \hline
    \rowcolor{blue!70}
    \multicolumn{2}{|c|}{}\\
    \hline

    \makecell{
      \centering
      World company \newline
      Main Street \newline
      World Capital \newline
      Earth \newline
      Tel: +00~1~23~45~67~89
    }

     & Alphonse \\
    \cline{2-2}
     & Daudet \\
    \cline{2-2}
     & Marcel \\
    \cline{2-2}
     & Pagnol \\
    \hline
  \end{tabular}

  \vspace{4\baselineskip}

  % Using multirow and minipage
  \begin{tabular}[c]{|c|l|}
    \hline
    \rowcolor{blue!70}
    \multicolumn{2}{|c|}{}\\
    \hline

    \multirow{4}{5cm}{
      \begin{minipage}[t]{5cm}
        \centering
        World company \\
        Main Street \\
        World Capital \\
        Earth \\
        Tel: +00~1~23~45~67~89
      \end{minipage}
    }

     & Alphonse \\
    \cline{2-2}
     & Daudet \\
    \cline{2-2}
     & Marcel \\
    \cline{2-2}
     & Pagnol \\
    \hline
  \end{tabular}

  \vspace{4\baselineskip}

  % Using multirow on second column
  \begin{tabular}[c]{|c|l|}
    \hline
    \rowcolor{blue!70}
    \multicolumn{2}{|c|}{}\\
    \hline

    World company &

    \multirow{5}{3cm}{
      \noindent
      Alphonse \newline
      \hrule
      Daudet \newline
      \hrule
      Marcel \newline
      \hrule
      Pagnol \newline
    } \\
    Main Street & \\
    World Capital & \\
    Earth & \\
    Tel: +00~1~23~45~67~89 & \\
    \hline
  \end{tabular}
\end{document}

The first try uses only a multirow on the first column.
Problems:

  • the text is not correctly centered
  • the fifth line of the first column is below the table

Good:

  • the text starts at the top of the column

The second attempt uses the makecell command.
Problem:

  • \newlines are not taken into account

The third test uses a minipage inside a multirow on the first column.
Problems:

  • the text does not start at the beginning of the column
  • the two last lines are below the table

Good:

  • the text is correctly centered

The Last try uses multirow on the second column.
Problems:

  • the first line of the second column seems to be indented
  • the \hline does not work into multirow, and hrule does not fit all the width
  • the spacing between lines and text are not good
  • the text of the second column is below the table

Good

  • the first column is properly centered
  • the first column text fits correctly the table




As you can see, each 'solutions' have its own problems, and I have no more ideas.

1

I propose to use the \makegapedcells command from makecell to increase the cells heights. As the right column has 4 cells, the total height of this column is fine.

However, makecell has problems with colouring tables, and in the present case, rowcolor does not work, so I removed the first (empty) row, and replaced it with a \midrule (from booktabs) , which can take an optional thickness argument, and works well with \arrayrulecolor{...}.

But this made the vertical outer lines disappear on the corresponding height, since the first row had been removed. So I removed all outer lines and replaced them with an \fbox, using the appropriate parameters.

\documentclass{report}

\usepackage[table]{xcolor}
\usepackage{multirow}

\usepackage{makecell}
\usepackage{booktabs}

\begin{document}

 {\setcellgapes{1ex}\makegapedcells
 \setlength{\aboverulesep}{0pt}
 \setlength{\belowrulesep}{0pt}
 \setlength{\fboxsep}{-\fboxrule}
 \fbox{\begin{tabular}[c]{c|l}
\arrayrulecolor{blue!70}\midrule[12pt]
\arrayrulecolor{black}
    \hline

    \multirowcell{4}{%
      World company\\
      Main Street\\
      World Capital\\
      Earth\\
      Tel: +00\,1\,23\,45\,67\,89
    }

     & Alphonse \\
    \cline{2-2}
     & Baudet \\
    \cline{2-2}
     & Marcel \\
    \cline{2-2}
     & Pagnol \
  \end{tabular}}}

\end{document} 

enter image description here

4
  • Thanks for your answer. It does the job for the rows, but not for the alignment. The text is not well centered – Phantom May 5 '20 at 12:21
  • You mean in the multirow? – Bernard May 5 '20 at 12:34
  • Please see my edit. – Bernard May 5 '20 at 12:45
  • \o/ thanks again – Phantom May 5 '20 at 12:52

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.