Quantcast
Channel: set all words in color for a part of a table - TeX - LaTeX Stack Exchange
Viewing all articles
Browse latest Browse all 3

Answer by leandriis for set all words in color for a part of a table

$
0
0

Assuming that every entry in your table also uses \ch, you can define your own command as follows:

\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}\newcommand{\redch}[1]{\textcolor{red}{\ch{#1}}}\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 &&  &  &  &  &  &  &  &  &\redch{C6H12O6}\\             \hline && \redch{Fe2O3} &  &  &  &  &  &  &  &\\             \hline &&  &  &  &  &  &  &  &  &\\             \hline&&  &  &  &  &  &  &  &  &\\             \hline&&  &  &  &  &  &  &  &  &\\             \hline&&  &  &  &  &  &  &  &  &\\            \hline         \end{tabular}    \end{center}\end{document}

You could also use \setchemformula{format=\color{red}} inside of the center environment to change the color of a \ch inside of that environment:

\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}    \setchemformula{format=\color{red}}        \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}

enter image description here


Viewing all articles
Browse latest Browse all 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>