Colors in table
This is a nice table with the help of two of you (many thanks).
A = [[10] * 10, [100] + [0] * 9, [11.1] * 9 + [0]]
A.extend([[20] * 5 + [0] * 5, [50/2^n for n in range(10)]])
D = deepcopy(A) # copie A dans D en conservant A intacte
# on arrondit uniquement les lignes qui en ont besoin
D[2] = list(matrix(RDF, A[2]).round(3)[0])
D[4] = list(matrix(RDF, A[4]).round(3)[0])
# on construit la table
hr = [r"${\color{red} n}$" for n in (1 .. 10)]
hc = ["", r"${\definecolor{energy}{RGB}{200, 8, 21}\color{energy}\text{Équirépartition}}$", r"${\definecolor{energy}{RGB}{200, 8, 21}\color{energy}\text{Tout pour un}}$", r"${\definecolor{energy}{RGB}{200, 8, 21}\color{energy}\text{Un déshérité}}$"]
hc += [r"${\definecolor{energy}{RGB}{200, 8, 21}\color{energy}\text{Injustice pour 1/2 population}}$", r"${\definecolor{energy}{RGB}{200, 8, 21}\color{energy}\text{Injustice croissante}}$"]
t = table(D, header_row=hr, header_column=hc)
show(t)
I added colors in the header row. But adding them in the header column does not work since the elements of the header need to be formatted. So what can I do? And if I want some background colors in the cells and change the colors of the cell's fonts?
I don't know how to get
\definecolor...
to work, but you need to put braces {} around the text to be colored, as in\color{blue}{\text{...}}
. (Note the "{" immediately before "\text".)