我正在尝试为下表着色:
\begin{tabular}{ |c|c|c|c|c| }
\hline
1,5h& 0,25h& 13h& 0,25h& 0,5h \\ \hline
Flight preparation& Taxiing& Flight& Taxiing& Flight debrief \\ \hline
& \multicolumn{3}{|c|}{Block time}& \\ \hline
\multicolumn{5}{|c|}{Duty time} \\ \hline
\end{tabular}
目标:
- 将单元格“BLOCK TIME”设为黄色。
- 将单元格“DUTY TIME”设为绿色。
请注意,我不想给整行或整列涂色。只想给单元格涂色!
答案1
您只需加载xcolor
包并使用即可\cellcolor{color}
。
\documentclass{article}
\usepackage[table]{xcolor} % loads also »colortbl«
\begin{document}
\begin{tabular}{ |c|c|c|c|c| }
\hline
1,5h& 0,25h& 13h& 0,25h & 0,5h \\ \hline
Flight preparation& Taxiing& Flight& Taxiing& Flight debrief \\ \hline
& \multicolumn{3}{|c|}{\cellcolor{yellow} Block time} & \\ \hline
\multicolumn{5}{|c|}{\cellcolor{green} Duty time} \\ \hline
\end{tabular}
\end{document}