1

I am revisiting a previous question for which we have already a solution:

Customizing Table CellColor Heat Map

Is it possible to have two different color definitions for two different color themes within the same document? E.g., Table heatmap 1 is red, heatmap 2 is blue? Thanks!

  • Sorry for my failed edits. Your original link did not work. I tried to fix it because I thought it was just a misplaced [ but this was not the case. Roll back did not work either. Please add a working link, and forgive me for the failed attempts. – Schrödinger's cat Dec 13 '19 at 4:37
  • 1
    No problem; I edited my post, here the link: tex.stackexchange.com/questions/515779/… – togedo Dec 13 '19 at 4:58
  • Do you only have 2 tables with 2 different color themes, or will there be even more tables using thouse two (or even more) color themes? – leandriis Dec 13 '19 at 6:44
  • I am using two types of tables like a template, one with lower values and one with higher values; to visually distinguish those two types I'd like to have control over the colors. They will appear in the document alternating: Table 1 (colorA), Table 2 (ColorB), Table 2 (colorA) and so on - Thanks for looking at this! – togedo Dec 13 '19 at 18:09
0

using \renewcommand works:

before the table to be colored put:

\def\colorModel{hsb} %You can use rgb or hsb
\renewcommand\ColCell[1]{
    \pgfmathparse{#1<70?1:0}  %Threshold for changing the font color into the cells
    \ifnum\pgfmathresult=0\relax\color{black}\fi
    \pgfmathsetmacro\compA{0.7-#1/240}   %Component R or H
    \pgfmathsetmacro\compB{#1/100}       %Component G or S
    \pgfmathsetmacro\compC{0.3+1}        %Component B or B
    \edef\x{\noexpand\centering\noexpand\cellcolor[\colorModel]{\compA,\compB,\compC}}\x #1} 
\newcolumntype{F}[1]{>{\collectcell\ColCell}#1<{\endcollectcell}}

Before the next table comes again \renewcommand for using a previous color, or any colortheme. This way I can have more than two different color themes. MWE, at the above link.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.