希望您一切顺利。我已通过 创建了一个多行单元格\multirowcell
。如何更改此多行单元格的背景颜色?
\begin{table}
\begin{tabular}{|c|c|c|c|}\hline
\multicolumn{2}{|c|}{text}&\cellcolor{yellow!10!gray}\multirowcell{5}{Numbers\\from\\ 1 to 5}&1 \\ \cline{1-2}\cline{4-4}
x&x&\cellcolor{yellow!10!gray}&2 \\ \cline{1-2}\cline{4-4}
x&x&\cellcolor{yellow!10!gray}&3 \\ \cline{1-2}\cline{4-4}
x&x&\cellcolor{yellow!10!gray}&4 \\ \cline{1-2}\cline{4-4}
x&x&\cellcolor{yellow!10!gray}&5 \\ \hline
x&x &text&6\\ \hline
\end{tabular}
\end{table}
我需要改变红线突出显示的单元格的整个背景颜色。
答案1
这是一个解决方案xcolor
:
\documentclass{article}
\usepackage[frenchb]{babel}
\usepackage[T1]{fontenc}
\usepackage{multirow, makecell}
\usepackage[svgnames, table]{xcolor}
\begin{document}
\begin{table}
\begin{tabular}{|>{\columncolor{MistyRose! 50}}c|c|}\hline
&1 \\
&2 \\
&3 \\
&4 \\
\multirowcell{-5}{Numbers\\from\\ 1 to 5}&5 \\ \hline
\end{tabular}
\end{table}
\end{document}
编辑:这是与帖子编辑相对应的代码(与我最初的回答相同的序言):
\begin{table}
\begin{tabular}{|c|c|>{\columncolor{yellow!10!gray}}c|c|}\hline
\multicolumn{2}{|c|}{text}& &1 \\ \cline{1-2}\cline{4-4}
x&x& & \\ \cline{1-2}\cline{4-4}
x&x& &3 \\ \cline{1-2}\cline{4-4}
x&x& &4 \\ \cline{1-2}\cline{4-4}
x&x& \multirowcell{-5}{Numbers\\from\\ 1 to 5} &5 \\ \hline
x&x &\cellcolor{white}text&6\\ \hline
\end{tabular}
\end{table}
答案2
\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{multirow, makecell}
\begin{document}
\begin{table}
\begin{tabular}{|c|c|}\hline
&1 \\
\cellcolor{blue!20}&2 \\
\cellcolor{blue!20}&3 \\
\cellcolor{blue!20}&4 \\
\cellcolor{blue!20}&5 \\
\cellcolor{blue!20}\multirowcell{-5}{Numbers\\from\\ 1 to 5}&1 \\
&6 \\\hline
\end{tabular}
\end{table}
\end{document}