I'm trying to make a Gantt chart using the NiceTabular
environment, but when trying to combine multicolumn
and cellcolor
I am having issues. Here's a MWE
\documentclass[11pt]{article}
\usepackage[table]{xcolor}
\usepackage{multirow}
\usepackage{hhline}
\usepackage{multicol}
\usepackage{nicematrix}
\begin{document}
\noindent
\begin{NiceTabular}{|c|l|*{10}c|}[color-inside]
\cline{1-12}
\multicolumn{2}{c}{} & \multicolumn{2}{c|}{Year 1} & \multicolumn{2}{c|}{Year 2} & \multicolumn{2}{c|}{Year 3}& \multicolumn{2}{c|}{Year 4}& \multicolumn{2}{c|}{Year 5}\\
\cline{1-12}
\multirow{3}{*}{Topic 1} &Project 1.1 & \multicolumn{4}{c|}{\cellcolor{green!60} }& \multicolumn{6}{c|}{}\\
\cline{2-12}
& Project 1.2 & \multicolumn{3}{c|}{}& \multicolumn{3}{c|}{\cellcolor{red!60} }& \multicolumn{4}{c|}{}\\
\cline{2-12}
& Project 1.3 & \multicolumn{6}{c|}{}& \multicolumn{4}{c|}{\cellcolor{orange!60}}\\
\cline{1-12}
\end{NiceTabular}
\end{document}
There are two problems:
- Of the three cells that are supposed to be colored, only one appears
- The one that appears should start at the middle of Year 2, but appears at the beginning
How can these two things be fixed?