0

I'm trying to use the \cellcolor command from the colortbl package. Here is the code I wrote:

\begin{footnotesize}
\begin{table}[!hb]
\begin{center}
\begin{tabular}{|c|c|c|c|c|}
\hline
\mbox{$B_3B_2 \backslash B_1B_0$} & 00 & 01 & 11 & 10 \\
\hline
00 & 0 & 0 & 0 & 0 \\
\hline
01 & 0 & 0 & 0 & 0 \\
\hline
11 & \cellcolor{green!25}1 & 1 & 1 & 1 \\
\hline
10 & 1 & 1 & 1 & 1 \\
\hline
\end{tabular}
\end{center}
\caption{Diagramme de Karnaugh pour $G_3$}
\end{table}
\end{footnotesize}

When I compile the code, everything works just fine, but the cell is not colored. I have already searched the colortbl.sty file and deleted it so it's reinstalled (in case of it's an old version), but nothing changed. The sty file is date 18/12/2018. Does someone know why it's not working?

4
  • Welcome to TeX.SX! Do you have the xcolor package loaded as well? – Phelype Oleinik Aug 26 '19 at 10:21
  • I read that colortbl loaded the xcolor package, so no. I just tried to explicitly load the xcolor package (\usepackage{xcolor}), but it doesn't change the result. – Shadew Aug 26 '19 at 10:23
  • Welcome to TeX.SX! Please don't post code fragments. Instead, put your fragments into a complete compilable document that shows the problem. – BambOo Aug 26 '19 at 10:27
  • Please mention what LaTeX engine you are using, e.g., PDFLaTeX, XELaTeX, etc. – MadyYuvi Aug 26 '19 at 10:47
0

The package mathenv causes the error, and I am not sure how it was. May some experts will provide the explanation, how it affected the output. And the modified tags are:

\documentclass[a4paper,11pt,svgnames]{book}
\usepackage{amsfonts} % utilisé pour les ensembles
\usepackage[LGR,T1]{fontenc}
\usepackage[greek,french]{babel}
\usepackage[latin1]{inputenc} % LaTeX, comprends les accents !
\usepackage{listings}
\usepackage{multirow}
\usepackage{fancyhdr}%pour personnaliser les en-têtes
\usepackage[table]{xcolor}
\usepackage{colortbl}
\usepackage{array}
\usepackage[Lenny]{fncychap}
\usepackage{geometry}
\usepackage{graphicx}
%\usepackage{mathenv}
\usepackage{mathtools}

\definecolor{listingcolor}{rgb}{0.6,0.8,0.8}
\definecolor{cadre}{rgb}{.1,.1,.8}

\geometry{ hmargin=2.5cm, vmargin=2.5cm }

\pagestyle{fancy}
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}
\newcommand{\euros}{\euro\hspace{0.5em}}
\pagestyle{fancy}
%\fancyhead[L]{\includegraphics[height=0.7cm]{./Images/LOGO_HEPH-CONDORCET.png}}
%\fancyhead[C]{}
%\fancyhead[R]{\includegraphics[height=0.7cm]{./Images/Condorcet.jpg}}
%\fancyfoot[L]{}
%\fancyfoot[C]{-~\thepage~-}
%\fancyfoot[R]{}
\renewcommand{\headrulewidth}{0.1pt}% filet en haut de page
\addtolength{\headheight}{0pt} % espace pour le filet
\renewcommand{\footrulewidth}{0pt} % pas de filet en bas
\fancypagestyle{plain}{ % pages de têtes de chapitre
\fancyhead{} % supprime l'entete
\renewcommand{\headrulewidth}{0pt} % et le filet
}

\newcommand{\tab}{\hspace*{1.5em}}

\definecolor{lightgray}{RGB}{230,230,230}

\lstdefinelanguage{CUDA}
{
 language=C,
 deletekeywords={},
 morekeywords = {__global__, blockIdx, threadIdx, cudaMemcpy, cudaFree, void, float, const, unsigned, uint, char, bool},
}

\lstdefinelanguage{CCustom}
{
 language=C,
 deletekeywords={},
 morekeywords = {parallel, omp, atomic, critical, master, num_threads, nowait, section, sections, task, single, private, barrier, firstprivate, lastprivate, reduction, shared, schedule, dynamic, guided, ordered, pragma, (incr), \#},
}

\lstdefinelanguage{VB}
{
 language=VBScript,
 deletekeywords={Add},
 morekeywords = {As, ByVal, ByRef, New, AddressOf, Public, Sub, Dim, Function, Private, End, Const,With, Protected, Overrides, Of, Me, Nothing, True, False, AndAlso, Overloads, TryCast, IsNot, Object, In, Throw},
}

\lstset%
{%
    keywordstyle=\ttfamily\color{cadre}\small,
    basicstyle=\ttfamily\footnotesize,
    commentstyle=\color{red},
    escapeinside={^*}{*^},
    emph={},
    emphstyle=\color{blue},
    numbers=left,
    numberstyle=\ttfamily\tiny,
    numbersep=5pt,
    frame=trbl,
    framesep=14pt,
    framerule=1pt,
    rulecolor = \color{cadre},
    showstringspaces=false,
    language = CCustom,
    backgroundcolor = \color{lightgray},
}

\newcommand{\Xor}[3]{
\begin{center}
$\begin{array}{lr}
& #1 \\
\oplus & #2 \\
\hline
& #3
\end{array}$
\end{center}
}


\headheight=24pt

%XLOP

\begin{document}

%\maketitle
\tableofcontents

\chapter{Rappels}

\section{Code de Gray}

\subsection{Introduction}

Le \textbf{code de Gray}, également appelé code Gray ou \textbf{code binaire réfléchi}, est un type de codage binaire permettant de ne modifier qu'un seul bit à la fois quand un nombre est augmenté d'une unité. Soit un nombre $N$ en binaire pur, pour obtenir son équivalent $n$ en binaire réfléchi, il suffit de calculer le OU exclusif entre le binaire de départ, $N$, et ce même binaire décalé d'un rang à droite (le dernier bit est supprimé). Prenons par exemple le nombre 5. Celui-ci s'écrit en binaire $0101$. Pour trouver son équivalent en code de Gray, il faut donc effectuer un OU exclusif entre $0101$ et $010$ :

\Xor{0101}{010}{0111}

Le chiffre 5 s'écrit donc en code Gray $0111$.

\subsection{Convertisseur de de code binaire en code Gray}

La construction du code Gray pour les nombres de 0 à 15 est représentée par le tableau suivant :

\begin{footnotesize}
\begin{center}
\begin{tabular}{c|cccc|cccc}
Nombre & \multicolumn{4}{c|}{Code binaire pur} & \multicolumn{4}{c}{Code Gray} \\
décimal & \mbox{$B_3$} & \mbox{$B_2$} & \mbox{$B_1$} & \mbox{$B_0$} & \mbox{$G_3$} & \mbox{$G_2$} & \mbox{$G_1$} & \mbox{$G_0$} \\
\hline
0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
1 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 1 \\
2 & 0 & 0 & 1 & 0 & 0 & 0 & 1 & 1 \\
3 & 0 & 0 & 1 & 1 & 0 & 0 & 1 & 0 \\
4 & 0 & 1 & 0 & 0 & 0 & 1 & 1 & 0 \\
5 & 0 & 1 & 0 & 1 & 0 & 1 & 1 & 1 \\
6 & 0 & 1 & 1 & 0 & 0 & 1 & 0 & 1 \\
7 & 0 & 1 & 1 & 1 & 0 & 1 & 0 & 0 \\
8 & 1 & 0 & 0 & 0 & 1 & 1 & 0 & 0 \\
9 & 1 & 0 & 0 & 1 & 1 & 1 & 0 & 1 \\
10 & 1 & 0 & 1 & 0 & 1 & 1 & 1 & 1 \\
11 & 1 & 0 & 1 & 1 & 1 & 1 & 1 & 0 \\
12 & 1 & 1 & 0 & 0 & 1 & 0 & 1 & 0 \\
13 & 1 & 1 & 0 & 1 & 1 & 0 & 1 & 1 \\ 
14 & 1 & 1 & 1 & 0 & 1 & 0 & 0 & 1 \\
15 & 1 & 1 & 1 & 1 & 1 & 0 & 0 & 0 
\end{tabular}
\end{center}
\end{footnotesize}

\textbf{Exercice} : établissons un diagramme de Karnaugh pour $G_0$, $G_1$, $G_2$ et $G_3$ à partir de $B_0$, $B_1$, $B_2$ et $B_3$.

\begin{footnotesize}
\begin{table}[!hb]
\begin{center}
\begin{tabular}{|c|c|c|c|c|}
\hline
\mbox{$B_3B_2 \backslash B_1B_0$} & 00 & 01 & 11 & 10 \\
\hline
00 & 0 & 0 & 0 & 0 \\
\hline
01 & 0 & 0 & 0 & 0 \\
\hline
11 & \cellcolor{green!25}1 & 1 & 1 & 1 \\
\hline
10 & 1 & 1 & 1 & 1 \\
\hline
\end{tabular}
\end{center}
\caption{Diagramme de Karnaugh pour $G_3$}
\end{table}
\end{footnotesize}

\begin{footnotesize}
\begin{table}[!hb]
\begin{center}
\begin{tabular}{|c|c|c|c|c|}
\hline
\mbox{$B_3B_2 \backslash B_1B_0$} & 00 & 01 & 11 & 10 \\
\hline
00 & 0 & 0 & 0 & 0 \\
\hline
01 & 1 & 1 & 1 & 1 \\
\hline
11 & 0 & 0 & 0 & 0 \\
\hline
10 & 1 & 1 & 1 & 1 \\
\hline
\end{tabular}
\end{center}
\caption{Diagramme de Karnaugh pour $G_2$}
\end{table}
\end{footnotesize}

\begin{footnotesize}
\begin{table}[!hb]
\begin{center}
\begin{tabular}{|c|c|c|c|c|}
\hline
\mbox{$B_3B_2 \backslash B_1B_0$} & 00 & 01 & 11 & 10 \\
\hline
00 & 0 & 0 & 1 & 1 \\
\hline
01 & 1 & 1 & 0 & 0 \\
\hline
11 & 1 & 1 & 0 & 0 \\
\hline
10 & 0 & 0 & 1 & 1 \\
\hline
\end{tabular}
\end{center}
\caption{Diagramme de Karnaugh pour $G_1$}
\end{table}
\end{footnotesize}

\begin{footnotesize}
\begin{table}[!hb]
\begin{center}
\begin{tabular}{|c|c|c|c|c|}
\hline
\mbox{$B_3B_2 \backslash B_1B_0$} & 00 & 01 & 11 & 10 \\
\hline
00 & 0 & 1 & 0 & 1 \\
\hline
01 & 0 & 1 & 0 & 1 \\
\hline
11 & 0 & 1 & 0 & 1 \\
\hline
10 & 0 & 1 & 0 & 1 \\
\hline
\end{tabular}
\end{center}
\caption{Diagramme de Karnaugh pour $G_0$}
\end{table}
\end{footnotesize}

\newpage

\textbf{Exercice} : nous pouvons maintenant établir les équations de $G_0$ à $G_3$ :
\begin{math}
G_0 = B_1B_0+
\end{math}

\end{document}

And the output is:

enter image description here

1
  • It works !! Thanks a lot ! That was a tricky problem ! – Shadew Aug 26 '19 at 11:26

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.