给单元格添加颜色

给单元格添加颜色

我有以下序言:

\documentclass{article}

\usepackage{colortbl}
\usepackage[table]{xcolor}
\usepackage[many]{tcolorbox}
\usepackage{efbox}

\efboxsetup{linecolor=fucsia!100, linewidth=0.96pt, margin=0pt}

\definecolor{fucsia}{RGB}{196,0,98}

\begin{document}

\arrayrulecolor{fucsia}
\efbox{\begin{tabular}{l|l|}
\multicolumn{2}{l|}{\textbf{text 1}} \\
\hline
 & plays an instrument \\
\cline{2-2}
A musician & gives a recital / a concert / \\
&  a performance.\\
\cline{2-2}
 & performs / plays a piece. \\
\hline
A composer & composes / writes music. \\
\hline
A singer & performs / sings a song / an aria. \\
\hline
\multicolumn{1}{l|}{A conductor} & conducts an orchestra. \\
\hline
\multicolumn{2}{l|}{\textbf{text 2}} \\
\hline
 & pains a picture / a painting / \\
 &  a portrait.\\
\cline{2-2}
An artist / & draws a picture. \\
\cline{2-2}
A painter & does a sketch. \\
\cline{2-2}
 & creates a work (of art) \\
\hline
A sculptor & creates / makes / sculpts a work / \\
 & a sculpture / a piece / a bust. \\
\hline
\multicolumn{2}{l|}{\textbf{text 3}} \\
\hline
A novelist & writes novels / fiction. \\
\hline
A writer & writes novels / books / short stories. \\
\hline
A poet & writes poems / poetry. \\
\hline
A playwright & writes plays / tragedies / comedies. \\
\hline
A scriptwriter & writes screenplays (for films). \\
\hline
\multicolumn{2}{l|}{\textbf{text 4}} \\
\hline
An actor / & acts in / appears in / performs in \\
An actress & stars in / has a role in \\
 & a play / a production / a film / \\
 &  a musical.\\
\hline
A director & directs a play / a production / a film \\
 & a musical. \\
\hline
A drama & stages / puts on / performs a play / \\
company & a production / a musical. \\
\hline
\end{tabular}}

\end{document}

我想给单元格添加颜色text 1, text 2, text 3text 4我试过了\rowcolor{},但没有效果。

答案1

一个简单的解决方案\columncolor。我借此机会使用该cellspace包改进了行的垂直填充,并使用makecell::对一些行进行了分组

\documentclass{article}

\usepackage{colortbl}
\usepackage[table, x11names]{xcolor}
\usepackage[many]{tcolorbox}
\usepackage{efbox}

\efboxsetup{linecolor=fucsia!100, linewidth=0.96pt, margin=0pt}

\definecolor{fucsia}{RGB}{196,0,98}
\usepackage{cellspace}
\setlength\cellspacetoplimit{4pt}
\setlength\cellspacebottomlimit{4pt}

\usepackage{multirow, makecell}
\renewcommand\cellalign{lc}

\begin{document}

\arrayrulecolor{fucsia}\efbox{\begin{tabular}{Sl|Sl|}
\multicolumn{2}{>{\columncolor{Bisque1!40}}Sl|}{\textbf{text 1}} \\
\hline
 & plays an instrument \\
\cline{2-2}
A musician & \makecell{gives a recital / a concert / \\
 a performance.}\\
\cline{2-2}
 & performs / plays a piece. \\
\hline
A composer & composes / writes music. \\
\hline
A singer & performs / sings a song / an aria. \\
\hline
\multicolumn{1}{l|}{A conductor} & conducts an orchestra. \\
\hline
\multicolumn{2}{>{\columncolor{Bisque1!40}}Sl|}{\textbf{text 2}} \\
\hline

\multirowcell{5}{An artist / \\ A painter} & \makecell{ pains a picture / a painting / \\
 a portrait.}\\
\cline{2-2}& draws a picture. \\
\cline{2-2}
& does a sketch. \\
\cline{2-2}
& creates a work (of art) \\
\hline
A sculptor & \makecell{creates / makes / sculpts a work / \\
 a sculpture / a piece / a bust.} \\
\hline
\multicolumn{2}{>{\columncolor{Bisque1!40}}Sl|}{\textbf{text 3}} \\
\hline
A novelist & writes novels / fiction. \\
\hline
A writer & writes novels / books / short stories. \\
\hline
A poet & writes poems / poetry. \\
\hline
A playwright & writes plays / tragedies / comedies. \\
\hline
A scriptwriter & writes screenplays (for films). \\
\hline
\multicolumn{2}{>{\columncolor{Bisque1!40}}Sl|}{\textbf{text 4}} \\
\hline
\makecell{An actor / \\ An actress} & \makecell{acts in / appears in / performs in \\
 stars in / has a role in \\
  a play / a production / a film / \\
   a musical.}\\
\hline
A director & \makecell{directs a play / a production / a film \\
   a musical}. \\
\hline
\makecell{A drama \\ company} & \makecell{stages / puts on / performs a play / \\
 a production / a musical.} \\
\hline
\end{tabular}}

\end{document} 

在此处输入图片描述

相关内容