Quantcast
Viewing all articles
Browse latest Browse all 3

set all words in color for a part of a table

To write the solution of an exercise, i want to fill in the tabular with the answers in red. The headlines of the table should stay in the same style than the exercise and only a part of the table should be colorized. I can achieve that by using \textcolor{red}{...} in each cell of my table but it's pretty brutal. I'm looking for a solution to declare that all the following words must be in red untill the end of the environment tabular.

I've tried some \color{red} but it doesn't work.

Here is a small example.

\documentclass[11pt,a4paper]{report}\usepackage[utf8]{inputenc}\usepackage[left=1.00cm, right=1.00cm, top=1.00cm, bottom=1.00cm]{geometry}\usepackage{colortbl}\usepackage{chemformula}\begin{document}    \begin{center}        \footnotesize        \renewcommand{\arraystretch}{1.5}        \hspace*{-1cm}\begin{tabular}{|c|c|c||c|c|c|c|c|c|c|c|}            \hline \rowcolor{black}            \multicolumn{11}{|c|}{\textcolor{white}{Corps purs}}\\\hline            \rowcolor{gray!90}élémentaires&            \multicolumn{2}{c||}{simples} &  \multicolumn{8}{c|}{composés}\\             \hline            \rowcolor{gray!70}&métal.& non-métal. & \multicolumn{2}{c|}{Oxydes} & Hydroxydes & \multicolumn{2}{c|}{Acides}  & \multicolumn{2}{c|}{Sels}  & Corps organiques\\             \hline             \rowcolor{gray!50}&&  & métal. & non-métal. &  & bin. & tern. & bin. & tern. &\\             \hline &&  &  &  &  &  &  &  &  &\ch{C6H12O6}\\             \hline && \ch{Fe2O3} &  &  &  &  &  &  &  &\\             \hline &&  &  &  &  &  &  &  &  &\\             \hline&&  &  &  &  &  &  &  &  &\\             \hline&&  &  &  &  &  &  &  &  &\\             \hline&&  &  &  &  &  &  &  &  &\\            \hline         \end{tabular}    \end{center}\end{document}

Desired output :

Image may be NSFW.
Clik here to view.
enter image description here

PS : i'm aware that Fe2O3 is at the wrong place, it was only for a second element :) !


Viewing all articles
Browse latest Browse all 3

Trending Articles