0

I have this table, that I need to color it's first row similar to the second example, however, it is not working because of the \multirow command, cannot be done despite the row command. If I used the \cellcolor the mission word will be clipped.

\begin{table}[b!]
\begin{center}
\renewcommand{\arraystretch}{1.4}
                    \scriptsize
          
\begin{tabular}{|m{0.17\textwidth}|  % <-- use 'm', not 'p', col. type
                           m{0.1\textwidth}| 
                           m{0.11\textwidth}| 
                            m{0.12\textwidth}|
                            m{0.12\textwidth}|                    
                         }
                            
                                        \hline \hline 

\multirow{ 2}{*}{A}  & \multicolumn{2}{c|}{X} & \multicolumn{2}{c|}{Y} \\ \cline{2-5} & Z & L &M & N  
          \end{tabular}
          \end{center}

  \end{table}



\begin{table}[t!]
\begin{center}
\renewcommand{\arraystretch}{1.4}
                    \scriptsize
          
\begin{tabular}{|m{0.17\textwidth}|  % <-- use 'm', not 'p', col. type
                           m{0.06\textwidth}| 
                           m{0.11\textwidth}| 
                            m{0.12\textwidth}|
                            m{0.12\textwidth}|    
                            m{0.18\textwidth}|                   
                         }
                            
                                        \hline \hline 
\rowcolor{myblue!30}
A  & B & C & D & E & F\\ \hline \hline                          
          \end{tabular}
          \end{center}

   \label{Table01}
  \end{table}

2 Answers 2

2

The trick is to merge cells from the bottom to top and apply \multirow in the last of the merging cells with a negative argument

\documentclass{article}
\usepackage{array}
\usepackage{multirow}
\usepackage[svgnames]{xcolor}
\usepackage{colortbl}

\colorlet{myblue}{Blue!30}


\begin{document}
\begin{table}
  \centering
  \renewcommand{\arraystretch}{1.4}
  \scriptsize
  \begin{tabular}{|
    m{0.17\textwidth}|
    m{0.1\textwidth}| 
    m{0.11\textwidth}| 
    m{0.12\textwidth}|
    m{0.12\textwidth}|                    
    }
    \hline\hline 
    \cellcolor{myblue}
    & \multicolumn{2}{c|}{X} & \multicolumn{2}{c|}{Y} \\
    \cline{2-5}
    \cellcolor{myblue}\multirow{-2}{*}{A}
    & Z & L & M & N \\
    \hline\hline 
  \end{tabular}
\end{table}
\end{document}

enter image description here

0

An alternative solution with tabularray:

\documentclass{article}
\usepackage{tabularray}
\usepackage[svgnames]{xcolor}
\colorlet{myblue}{Blue!30}

\begin{document}
\begin{table}
  \centering\scriptsize
  \begin{tblr}{
    colspec={X[1.7]XX[1.1]*2{X[1.2]}},
    vlines, hlines,
    stretch=1.4,
    cell{1}{1}={r=2}{bg=myblue},
    cell{1}{2,4}={c=2}{c},
    }
    \hline
    A & X & & Y & \\
    & Z & L & M & N \\
    \hline 
  \end{tblr}
\end{table}
\end{document}

enter image description here

You must log in to answer this question.

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