0

I am trying to create a table listing advantages and disadvantages of diferent providers , but I can't make the \multirow command readable. Where should I include it? I got this table code from someone who posted here. I am still new to latex so I am trying to understand why It is not reading and where I should post it. Here is te code I am using.

  \usepackage[utf8]{inputenc}
  \usepackage[toc]{glossaries}
  \usepackage{enumitem}
  \usepackage{graphicx}
  \usepackage{booktabs}
  \usepackage{float}
  \usepackage{multirow}
  \usepackage{tabu}

  \usepackage{array}

\newcommand*{\arraycolor}[1]{\protect\leavevmode\color{#1}}
\newcolumntype{A}{>{\columncolor{blue!50!white}}c}
\newcolumntype{B}{>{\columncolor{green!50!white}}c}
\newcolumntype{C}{>{\columncolor{FireBrick!50}}c}
\newcolumntype{D}{>{\columncolor{Gray!42}}c}

\begin{table} [H]

\begin{center}
\sffamily
\arrayrulecolor{white}
\arrayrulewidth=1pt
\renewcommand{\arraystretch}{1.5}
\rowcolors[\hline]{3}{.!50!White}{}
\begin{tabular}{D|B|C}
  %\multicolumn{4}{D}{\bfseries Example table}\\
\rowcolor{.!50!Black}
\arraycolor{White}\bfseries Solution &
\arraycolor{White}\bfseries Advantages &
\arraycolor{White}\bfseries Disadvantages \\
\multirow{3}{*}{Provider A} & B & C \\
Provider B & B & F \\
Provider C & C & G \\
Provider D & D & H \\
Provider E & D & H \\
\end{tabular}
\end{center}
\end{table}
4
  • Please post with packages you have used@G. Doe
    – Biki Teron
    Jun 28, 2017 at 6:41
  • @BikiTeron I am using the \multirow package
    – G. Doe
    Jun 28, 2017 at 6:53
  • 1
    You need the free line under your original one. So if you have this you need a \multirow{3}{*}{Provider A} & B & C\\ & &\\ & &.
    – TeXnician
    Jun 28, 2017 at 6:56
  • @TeXnician it does not create a multirow, it creates new rows and does not show the Provider A name.
    – G. Doe
    Jun 28, 2017 at 7:01

3 Answers 3

1

Here's a quick and dirty workaround. You need to define all rows you want it to span in advance (that's required in any case).

table with multirow

\documentclass{article}
 \usepackage[utf8]{inputenc}
  \usepackage[toc]{glossaries}
  \usepackage{enumitem}
  \usepackage{graphicx}
  \usepackage{booktabs}
  \usepackage{float}
  \usepackage{multirow}
  \usepackage{tabu}
\usepackage[table,dvipsnames,svgnames]{xcolor}
  \usepackage{array}

\newcommand*{\arraycolor}[1]{\protect\leavevmode\color{#1}}
\newcolumntype{A}{>{\columncolor{blue!50!white}}c}
\newcolumntype{B}{>{\columncolor{green!50!white}}c}
\newcolumntype{C}{>{\columncolor{FireBrick!50}}c}
\newcolumntype{D}{>{\columncolor{Gray!42}}c}

\begin{document}
\begin{table} [H]

\begin{center}
\sffamily
\arrayrulecolor{white}
\arrayrulewidth=1pt
\renewcommand{\arraystretch}{1.5}
\rowcolors[\hline]{3}{.!50!White}{}
\begin{tabular}{D|B|C}
  %\multicolumn{4}{D}{\bfseries Example table}\\
\rowcolor{.!50!Black}
\arraycolor{White}\bfseries Solution &
\arraycolor{White}\bfseries Advantages &
\arraycolor{White}\bfseries Disadvantages \\
 & B & C \\
& &\\
\multirow{-3}{*}{Provider A}& &\\
Provider B & B & F \\
Provider C & C & G \\
Provider D & D & H \\
Provider E & D & H \\
\end{tabular}
\end{center}
\end{table}
\end{document}
3
  • Thanks, but I was wondering if there is a way to expand the provider A row, instead of adding new rows with new colors?
    – G. Doe
    Jun 28, 2017 at 7:07
  • @G.Doe multirow is just intended to make a cell span more than one row. There are posts on this site describing the problems of multirow in environments with multiple colors. And concerning the new rows: multirow does only make sense, if you have more than one row.
    – TeXnician
    Jun 28, 2017 at 7:08
  • I wante to have more than one row but with the same color of provider A, since I wanted to show all the extra rows belongs to it. But thanks. i will try to think another way to do it.
    – G. Doe
    Jun 28, 2017 at 7:19
1

It is a classical problem with \multirow in coloured tables. The trick is to place the \multirow command in the last ‘multirowed’ cell, with a negative argument:

\documentclass{article}
 \usepackage[utf8]{inputenc}
  \usepackage[toc]{glossaries}
  \usepackage{enumitem}
  \usepackage{graphicx}
  \usepackage{booktabs}
  \usepackage{float}
  \usepackage{multirow}
  \usepackage{tabu}
\usepackage[table, svgnames]{xcolor}

\usepackage{array}

\newcommand*{\arraycolor}[1]{\protect\leavevmode\color{#1}}
\newcolumntype{A}{>{\columncolor{blue!50!white}}c}
\newcolumntype{B}{>{\columncolor{green!50!white}}c}
\newcolumntype{C}{>{\columncolor{FireBrick!50}}c}
\newcolumntype{D}{>{\columncolor{Gray!42}}c}

\begin{document}

\begin{table} [H]

  \begin{center}
    \sffamily
    \arrayrulecolor{white}
    \arrayrulewidth=1pt
    \renewcommand{\arraystretch}{1.5}
    \rowcolors[\hline]{3}{.!50!White}{}
    \begin{tabular}{D|B|C}
      %\multicolumn{4}{D}{\bfseries Example table}\\
      \rowcolor{.!50!Black}
      \arraycolor{White}\bfseries Solution &
      \arraycolor{White}\bfseries Advantages &
      \arraycolor{White}\bfseries Disadvantages \\
                                             & B & C \\
                                             & & \\
      \multirow{-3}{*}{Provider A} & & \\
      Provider B & B & F \\
      Provider C & C & G \\
      Provider D & D & H \\
      Provider E & D & H \\
    \end{tabular}
  \end{center}
\end{table}

\end{document}

enter image description here

1
  • I did that too in my answer, but that's unfortunately not satisfying for the OP (see comments on my answer).
    – TeXnician
    Jun 28, 2017 at 9:53
1

It's a bit hard to understand, but judging by your comment on one of the other answers, it seems like this is what you're after. I used \cellcolor to override the color setting defined by \rowcolors.

enter image description here

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{booktabs}
\usepackage{float}
\usepackage[table, svgnames]{xcolor}
\usepackage{array}
\newcommand*{\arraycolor}[1]{\protect\leavevmode\color{#1}}
\newcolumntype{A}{>{\columncolor{blue!50!white}}c}
\newcolumntype{B}{>{\columncolor{green!50!white}}c}
\newcolumntype{C}{>{\columncolor{FireBrick!50}}c}
\newcolumntype{D}{>{\columncolor{Gray!42}}c}

\begin{document}

\begin{table}[H]

\centering
    \sffamily
    \arrayrulecolor{white}
    \arrayrulewidth=1pt
    \renewcommand{\arraystretch}{1.5}
    \rowcolors[\hline]{3}{.!50!White}{}
    \begin{tabular}{D|B|C}
      %\multicolumn{4}{D}{\bfseries Example table}\\
      \rowcolor{.!50!Black}
      \arraycolor{White}\bfseries Solution &
      \arraycolor{White}\bfseries Advantages &
      \arraycolor{White}\bfseries Disadvantages \\
      Provider A & B & C \\
\cellcolor{Gray!42}& \cellcolor{green!50!white} & \cellcolor{FireBrick!50}\\
&&\\
      Provider B & B & F \\
      Provider C & C & G \\
      Provider D & D & H \\
      Provider E & D & H \\
    \end{tabular}

\end{table}

\end{document}

You must log in to answer this question.

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