帮助:给桌子上色

帮助:给桌子上色

我恳请大家帮忙,如何将标题行设为灰色,将讲师列设为蓝色。我试了很多次,但都无法解决这个 LaTex 多行表问题。非常感谢您的帮助。代码如下:

\documentclass{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{multirow}
\usepackage{hhline}
\usepackage{colortbl}
\usepackage{multicol}
\begin{document}
\begin{table}[t]

答案1

其中\rowcolor\columncolor\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}

在此处输入图片描述

答案2

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}

上述代码的输出

相关内容