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 Sveinung for set all words in color for a part of a table

$
0
0

A possible solution (if I understand your question correct) is to direct a \color{red} command into all columns. I have defined a new column type R for the purpose. Thereafter, you enclose the heading text in \multicolumn{1}{c|}{<text>} to protect against colourisation.

You may adapt David Carlisle answer to this question to your code, and define a new column that accepts a \rowfont-command (also defined in the code):

Example 1 – defining a \rowfont-command

enter image description here

\documentclass[11pt,a4paper]{report}\usepackage[utf8]{inputenc}\usepackage{array}\newcolumntype{C}{>{\rowfont}c}\newcommand\setrowfont[1]{\noalign{\gdef\rowfont{#1}}}\gdef\rowfont{}\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}{|*{3}{C|}|*{8}{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 \setrowfont{\color{red}}&&  X&  &  &  &  &  &  &  &\ch{C6H12O6}\\             \hline && \ch{Fe2O3} &  &  &  &  &  &  &  &\\             \hline             X&X& X & X & X & X & X & X & X & X &X\\             \hline&&  X&  &  &  &  &  &  &  &\\             \hline&&  X&  &  &  &  &  &  &  &\\             \hline&&  X&  &  &  &  &  &  &  &\\            \hline         \end{tabular}    \end{center}\end{document}

Example 2 –>{color{red} and\multicolomn}}

enter image description here

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

Viewing all articles
Browse latest Browse all 3

Trending Articles



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