0

I am kindly requesting help on how to color the row of headings in grey, and the instructor column in blue. I tried so many times and failed to solve this LaTex multirow table problem. Your help will be greatly appreciated. The code is as follows:

\documentclass{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{multirow}
\usepackage{hhline}
\usepackage{colortbl}
\usepackage{multicol}
\begin{document}
\begin{table}[t]
1
  • You can use \rowcolor
    – DG'
    Commented Oct 26, 2020 at 21:22

2 Answers 2

2

With \rowcolor, \columncolor, and \cellcolor:

\documentclass{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{xcolor}
\usepackage{multirow}
\usepackage{hhline}
\usepackage{colortbl}
\usepackage{multicol}
\begin{document}
\begin{table}[t]
    \caption{Level 1 Courses}
    \begin{tabular}{|c|c|>{\columncolor{cyan}}c |c|}
        \hline
        \rowcolor{lightgray}
        \cellcolor{lightgray}                              & \multicolumn{2}{l|}{\cellcolor{lightgray}Details} & \cellcolor{lightgray}                                                   \\ \cline{2-3}
        \rowcolor{lightgray}
        \multirow{-2}{*}{\cellcolor{lightgray}Course Code} & Course Narration                                  & Instructor            & \multirow{-2}{*}{\cellcolor{lightgray}Semester} \\
        \hline \hline
        -                                                  & -                                                 & -                     & -                                               \\
        \hline
        -                                                  & -                                                 & -                     & -                                               \\
        \hline
        -                                                  & -                                                 & -                     & -                                               \\
        \hline
        -                                                  & -                                                 & -                     & -                                               \\
        \hline
        -                                                  & -                                                 & -                     & -                                               \\
        \hline
    \end{tabular}
\end{table}
\end{document}

enter image description here

3
  • you miss instructor column in blue
    – AndréC
    Commented Oct 26, 2020 at 21:42
  • How is it different?
    – Bernard
    Commented Oct 27, 2020 at 0:15
  • Different how? Not enough information to help!
    – DG'
    Commented Oct 27, 2020 at 9:32
4

With nicematrix:

\documentclass{article}
\usepackage{nicematrix}

\begin{document}

\NiceMatrixOptions{cell-space-limits=2pt}

\begin{NiceTabular}{cccc}[hvlines]
\CodeBefore  
  \columncolor{blue!15}{3}
  \rowcolor{lightgray}{1,2}
\Body
\Block{2-1}{Course Code} & \Block[l]{1-2}{Details} & & \Block{2-1}{Semester} \\
& Course Narration & Instructor \\
 \Hline\Hline
- & - & - & - \\ 
- & - & - & - \\ 
- & - & - & - \\ 
- & - & - & - \\ 
- & - & - & - \\ 
\end{NiceTabular}

\end{document}

Output of the above code

2
  • I am getting the following error messages: Fatal Package nicematrix Error: There is a problem. Maybe you have used l, c(nicematrix) preamble of your environment. \end{NiceTabular} Emergency stop. \end{NiceTabular} No file texstudio_LEizfd.aux.
    – itc
    Commented Oct 27, 2020 at 11:17
  • You have not the latest version of nicematrix. You should update your TeX installation. Commented Oct 27, 2020 at 12:18

You must log in to answer this question.

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