我在为表格单元格着色时遇到了麻烦。在下面的 MWE 中,颜色在右侧留下了空白。考虑到这可能是由于内部长度计算,我明确设置了多列的长度,并考虑了 tabcolsep 值,但问题仍然存在
\documentclass{article}
\usepackage{colortbl}
\usepackage{multirow}
\newcolumntype{C}[1]{>{\tiny\raggedright\arraybackslash}m{#1}}
\setlength{\tabcolsep}{0.200cm}
\begin{document}
\begin{tabular} { | C{4.500cm} | C{4.334cm} | C{0.954cm} | C{0.954cm} | C{0.954cm} | C{0.954cm} |}\hline
\multicolumn{6}{|p{14.65cm}|}{\centering\cellcolor{blue}\textcolor{yellow}{\bfseries\footnotesize REQUIREMENTS}}\\\hline
%
\cellcolor{blue}&
\cellcolor{blue}&
\multicolumn{4}{p{5.016cm}|}{\centering\tiny\cellcolor{blue}\textcolor{yellow}{EDUCATION}} \\\cline{2-6}
%
\multicolumn{1}{|p{4.500cm}|}{\centering\multirow{-2}{*}{\tiny\cellcolor{blue}\textcolor{yellow}{AREA}}}&
\multicolumn{1}{p{4.334cm}|}{\centering\multirow{-2}{*}{\tiny\cellcolor{blue}\textcolor{yellow}{PROFILE}}}&
\centering\cellcolor{blue}\textcolor{yellow}{U}&
\centering\cellcolor{blue}\textcolor{yellow}{P}&
\centering\cellcolor{blue}\textcolor{yellow}{I}&
\centering\arraybackslash\cellcolor{blue}\textcolor{yellow}{M} \\
%
\end{tabular}
\end{document}
答案1
您只是忘记考虑列分隔空间。c
由于您想要居中的内容,因此只需将多列说明符替换为 即可解决问题。我简化了您的代码,系统地使用命令\rowcolor
,更改颜色以显示更多可见线条,并使用\hhline
代替\cline
。话虽如此,我不确定您想要的最终结果。
\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{hhline}
\usepackage{multirow}
\newcolumntype{C}[1]{>{\tiny\raggedright\arraybackslash}m{#1}}
\setlength{\tabcolsep}{0.200cm}
\begin{document}
\colorlet{blue} {cyan!40}
\begin{tabular} { | C{4.500cm} | C{4.334cm} | C{0.954cm} | C{0.954cm} | C{0.954cm} | C{0.954cm} |}\hline
\rowcolor{blue}\multicolumn{6}{|c|}{\textcolor{yellow}{\bfseries\footnotesize REQUIREMENTS}}\\\hline
% %p{14.65cm}
\rowcolor{blue}& &
\multicolumn{4}{c|}{\tiny\textcolor{yellow}{EDUCATION}} \\\hhline{|>{\arrayrulecolor{blue}}->{\arrayrulecolor{black}}|-----|}
\rowcolor{blue}%
\multirow{-2}{=}{\centering\tiny\textcolor{yellow}{AREA}}&
\multirow{-2}{=}{\centering\tiny\textcolor{yellow}{PROFILE}}&
\centering\textcolor{yellow}{U}&
\centering\textcolor{yellow}{P}&
\centering\textcolor{yellow}{I}&
\centering\arraybackslash\textcolor{yellow}{M} \\%
\end{tabular}
\end{document}