2

Following up on this question I asked some time ago, I am facing a similar scenario, but for the life of me I do not seem to get it right with the solution provided in the question above, and I have no clue...

The following is a MWE, all I want to do is to merge rows vertically (multirow), so that "Preventative impacts of RA" and its corresponding "G5 vehicle UVB 40h" span 4 rows, and "Preventative impacts of RP" and its corresponding "G5 vehicle UVB 40h" span 3 rows.

How should I do it? Many thanks!!

\documentclass[xcolor={dvipsnames,table}]{beamer}

%%TABLE
\usepackage{multirow}
\newcommand*{\arraycolor}[1]{\protect\leavevmode\color{#1}}
\newcolumntype{A}{>{\columncolor{red!20}}c}
\newcolumntype{B}{>{\columncolor{blue!20}}c}

\mode<presentation> {
    \usetheme[compress]{Singapore}
    \usecolortheme{orchid}
}

\begin{document}

\begin{frame}
    \sffamily
    \arrayrulecolor{white}
    \arrayrulewidth=1pt
    \renewcommand{\arraystretch}{1}
    \rowcolors[\hline]{2}{.!50!White}{}
    \resizebox{\linewidth}{!}{%
        \begin{tabular}{A|B|A}
            \rowcolor{.!50!Black}
            \arraycolor{White}\bfseries {\footnotesize Question} & \arraycolor{White}\bfseries {\footnotesize A} & \arraycolor{White}\bfseries {\footnotesize B}\\
            \bfseries {\scriptsize UVB impact on primary keratinocytes} & {\scriptsize G5 vehicle UVB 40h} & {\scriptsize G6 vehicle noUVB 40h}\\
            \bfseries {\scriptsize Preventative impact of RA} & {\scriptsize G1 RA\_1nM UVB 40h} & {\scriptsize G5 vehicle UVB 40h}\\
            & {\scriptsize G1 RA\_10nM UVB 40h} &\\
            & {\scriptsize G1 RA\_100nM UVB 40h} &\\
            & {\scriptsize G1 RA\_1$\mu$M UVB 40h} &\\
            \bfseries {\scriptsize Preventative impacts of RP} & {\scriptsize G2 RP\_0.1$\mu$M UVB 40h} & {\scriptsize G5 vehicle UVB 40h}\\
            & {\scriptsize G2 RP\_1$\mu$M UVB 40h} &\\
            & {\scriptsize G2 RP\_10$\mu$M 40h} &\\
        \end{tabular}
    }%
\end{frame} 

\end{document}

test

DaniCee
  • 2,217

1 Answers1

1

With {NiceTabular} of nicematrix (≥ 6.1 of 2021-08-20).

\documentclass[xcolor={dvipsnames}]{beamer}
\usepackage{nicematrix}

\mode<presentation> { \usetheme[compress]{Singapore} \usecolortheme{orchid} }

\begin{document}

\begin{frame} \begin{center} \sffamily \renewcommand{\arraystretch}{1.4} \tiny \begin{NiceTabular} [ rules = {color=white,width=2pt} , hvlines-except-borders , cell-space-limits=3pt, ] {>{\bfseries}ccc} \CodeBefore \rowcolors{2}{red!20}{red!10}[cols={1,3},respect-blocks] \rowcolors{2}{blue!20}{blue!10}[cols=2] \cellcolor{red!50!black}{1-1,1-3} \cellcolor{blue!50!black}{1-2} \Body \RowStyle[color=White]{\footnotesize} Question & \bfseries A & \bfseries B \ UVB impact on primary keratinocytes & G5 vehicle UVB 40h & G6 vehicle noUVB 40h \ \Block{4-1}{Preventative impact of RA} & G1 RA_1nM UVB 40h & \Block{4-1}{G5 vehicle UVB 40h} \ & G1 RA_10nM UVB 40h \ & G1 RA_100nM UVB 40h \ & G1 RA_1$\mu$M UVB 40h \ \Block{3-1}{Preventative impacts of RP} & G2 RP_0.1$\mu$M UVB 40h & \Block{3-1}{G5 vehicle UVB 40h} \ & G2 RP_1$\mu$M UVB 40h \ & G2 RP_10$\mu$M 40h \ \end{NiceTabular} \end{center} \end{frame}

\end{document}

You need several compilations (because nicematrix uses PGF/Tikz nodes under the hood).

Output of the above code

F. Pantigny
  • 40,250