![帮助:给桌子上色](https://linux22.com/image/423059/%E5%B8%AE%E5%8A%A9%EF%BC%9A%E7%BB%99%E6%A1%8C%E5%AD%90%E4%B8%8A%E8%89%B2.png)
我恳请大家帮忙,如何将标题行设为灰色,将讲师列设为蓝色。我试了很多次,但都无法解决这个 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}