\begin{tabular}{| p{10cm} | c |}
\hline
& \\
{\bf Requirement:} & {\bf Categorie:} \\
& \\
\hline
& {\cellcolor{green}}\\
text & {\cellcolor{green}{\bf Must Have}} \\
& {\cellcolor{green}}\\
\hline
& {\cellcolor{green}}\\
text & {\cellcolor{green}{\bf Must Have}} \\
& {\cellcolor{green}}\\
\hline
& {\cellcolor{green}}\\
text & {\cellcolor{green}{\bf Must Have}} \\
& {\cellcolor{green}}\\
\hline
& {\cellcolor{orange}}\\
text & {\cellcolor{orange}{\bf Could Have}} \\
& {\cellcolor{orange}}\\
\hline
\end{tabular}
其中一个\hline
命令没有发送成功?请查看我的错误图片。
答案1
这是一个已知的查看器问题,@ChristianHupfer 也指出了这一点。在这种情况下,您可以增加\arrayrulewidth
或直接使用其他查看器打开。
\documentclass[12pt,a4paper]{article}
\usepackage{colortbl}
\usepackage{xcolor}
\begin{document}
\setlength{\arrayrulewidth}{1.5pt}
\begin{tabular}{| p{10cm} | c |}
\hline
& \\
{\bf Requirement:} & {\bf Categorie:} \\
& \\
\hline
& {\cellcolor{green}}\\
text & {\cellcolor{green}{\bf Must Have}} \\
& {\cellcolor{green}}\\
\hline
& {\cellcolor{green}}\\
text & {\cellcolor{green}{\bf Must Have}} \\
& {\cellcolor{green}}\\
\hline
& {\cellcolor{green}}\\
text & {\cellcolor{green}{\bf Must Have}} \\
& {\cellcolor{green}}\\
\hline
& {\cellcolor{orange}}\\
text & {\cellcolor{orange}{\bf Could Have}} \\
& {\cellcolor{orange}}\\
\hline
\end{tabular}
\end{document}
答案2
该软件包nicematrix
有专门用于解决此类问题的工具。在下面的代码中,我加载了nicematrix
(和卸载了colortbl
)并将环境替换为带有键(别名){tabular}
的环境,这意味着表格中将有彩色说明。{NiceTabular}
color-inside
colortbl-like
您直接获得了预期的输出。
\documentclass[12pt,a4paper]{article}
\usepackage{nicematrix}
\usepackage{xcolor}
\begin{document}
\begin{NiceTabular}{| p{10cm} | c |}[color-inside]
\hline
& \\
{\bf Requirement:} & {\bf Categorie:} \\
& \\
\hline
& {\cellcolor{green}}\\
text & {\cellcolor{green}{\bf Must Have}} \\
& {\cellcolor{green}}\\
\hline
& {\cellcolor{green}}\\
text & {\cellcolor{green}{\bf Must Have}} \\
& {\cellcolor{green}}\\
\hline
& {\cellcolor{green}}\\
text & {\cellcolor{green}{\bf Must Have}} \\
& {\cellcolor{green}}\\
\hline
& {\cellcolor{orange}}\\
text & {\cellcolor{orange}{\bf Could Have}} \\
& {\cellcolor{orange}}\\
\hline
\end{NiceTabular}
\end{document}
您需要多次编译(因为nicematrix
在后台使用 PGF/Tikz 节点)。
评论 \bf
在 LaTeX 中被视为已弃用,应改用\bfseries
。