Color issues with the ieeecolor document class and tikz

I have been encountering a very strange behaviour with the ieeecolor.cls document class! Compiling a latex document using this class with the tikz package triggers some color warnings: Warning Incompatible color definition, but the pdf generated seems to be as expected (i.e. see MWE below).

However, very odd things happen when the following section is added to the tex file:

%%%% Inverse PDF page and text color
\definecolor{pagcol}{rgb}{0.1255,0.1255,0.1255}
\definecolor{txtcol}{rgb}{0.85,0.85,0.85}
\pagecolor{pagcol}
\color{txtcol}


In this case, the behaviour of latex is rather unexpected and the colors are not as they should anymore. This seems to come from a clash between the new ieeecolor class and some packages like tikz.

Has anyone encountered this issue before? Has anyone find a fix for this?

The ieeecolor class can be found on the IEEE Author Centre Website, it requires the files ieeecolor.cls and 'generic.sty'.

Minimum working example with page and text color code commented:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%2345678901234567890123456789012345678901234567890123456789012345678901234567890
%       1       2       3       4       5       6       7       8
%\documentclass[letterpaper,10pt,conference]{ieeeconf}  % Comment this line out
% if you need a4paper
%\documentclass[a4paper, 10pt, conference]{ieeeconf}    % Use this line for a4
% paper
\documentclass[journal,twoside,web]{ieeecolor}          % %% NEW ieeecolor class %%
% \IEEEoverridecommandlockouts                          % This command is only
% needed if you want to
% use the \thanks command
% \overrideIEEEmargins
% See the \addtolength command later in the file to balance the column lengths
% on the last page of the document

% The following packages can be found on http:\\www.ctan.org
\usepackage{generic}
\usepackage{lipsum}
\usepackage{tikz}
\usepackage{pagecolor}

%%%%% Inverse PDF page and text color
%\definecolor{pagcol}{rgb}{0.1255,0.1255,0.1255}
%\definecolor{txtcol}{rgb}{0.85,0.85,0.85}
%\pagecolor{pagcol}
%\color{txtcol}

\title{My Dummy Article}

\author{Julius~Caesar~\IEEEmembership{Fellow~Member,~IEEE}
\thanks{J.~Caesar is with the Senate House, Rome}
}

\begin{document}

\maketitle
\thispagestyle{empty}
\pagestyle{empty}

\begin{abstract}
\lipsum[1]
\end{abstract}

\begin{IEEEkeywords}
Key word 1, Key word 2.
\end{IEEEkeywords}

\section{Dummy Section 1}

\lipsum

\section{Dummy Section 2}

\lipsum

\begin{figure}[!htbp]
\centering
\begin{tikzpicture}
\draw (0,0) -- (4,0) -- (4,4) -- (0,4) -- (0,0);
\end{tikzpicture}
\caption{A Dummy Square figure}
\end{figure}

\lipsum

\end{document}


generic.sty

\def\logoname{LOGO-generic-web}
\definecolor{subsectioncolor}{rgb}{0,0.541,0.855}
\setlength{\firstpagerule}{39pc}
\setlength{\logowidth}{4pc}
\def\journalname{Generic Colorized Journal}


ieeecolor.sty is a bit of a pain in the back. BTW, does anybody know who can be contacted to post patches?

There are two technical problems here, and one philosophical thing.

The philosophical thing is: is it worth caring? When they accept your paper, they will re-format it with something that's not LaTeX at all, and they want separate figures anyway, which are better build with standalone. But if you want your file working for internal use or submission to some archive, then yes, maybe it's worth it to care.

The technical problems are two:

1. the first one is quite big: color will leak. The linked answer provides a nice answer for it.
2. The package loads color, not xcolor (in 2021!), which is why you have all the problems with TikZ, which requires xcolor.

Possible solutions.

1. patch ieeecolor.cls
--- ieeecolor.cls.orig  2021-06-04 11:51:15.355826034 +0200
+++ ieeecolor.cls   2021-06-04 12:11:40.354385057 +0200
@@ -667,12 +667,13 @@
%
%
%
-%
+
\ProvidesClass{IEEEtran}[2002/11/18 revision V1.6b by Michael Shell]
\typeout{-- See the "IEEEtran_HOWTO" manual for usage information.}
\typeout{-- The source comments contain changelog notes.}
\NeedsTeXFormat{LaTeX2e}
-\RequirePackage{color}
+% \RequirePackage{color}
+\RequirePackage[table]{xcolor}

%%%%%%%%%%%
\DeclareOldFontCommand{\sf}{\normalfont\sffamily}{\mathsf}
@@ -2255,16 +2256,16 @@
\else
\@IEEEfigurecaptionsepspace% V1.6 was a hard coded 5pt
% 3/2001 use footnotesize, not small; use two nonbreaking spaces, not one
-\setbox\@tempboxa\hbox{\footnotesize #1.\color{black}\normalcolor~~\sf\boldmath #2}%
+\setbox\@tempboxa\hbox{{\footnotesize #1.\color{black}\normalcolor~~\sf\boldmath #2}}%
\ifdim \wd\@tempboxa >\hsize%
% if caption is longer than a line, let it wrap around
-\setbox\@tempboxa\hbox{\footnotesize #1.\color{black}\normalcolor~~ }%
+\setbox\@tempboxa\hbox{{\footnotesize #1.\color{black}\normalcolor~~ }}%
\parbox[t]{\hsize}{\footnotesize \noindent\unhbox\@tempboxa\sf\boldmath #2}%
% if caption is shorter than a line,
% allow user to control short figure caption justification (left or center)
\else%
-\ifcenterfigcaptions \hbox to\hsize{\footnotesize\hfil\box\@tempboxa\hfil}%
-\else \hbox to\hsize{\footnotesize\box\@tempboxa\hfil}%
+\ifcenterfigcaptions \hbox to\hsize{{\footnotesize\hfil\box\@tempboxa\hfil}}%
+\else \hbox to\hsize{{\footnotesize\box\@tempboxa\hfil}}%
\fi\fi\fi\color{black}}


This should fix both problems, I think.

1. If you do not want to touch the original class, let's try to trick ieeecolor by loading xcolor before the class; fix the other problem with Phelype Oleinik fix: just change your invocation of \documenclass with (tested using the ieeecolor.cls downloaded this morning!):
\RequirePackage{xcolor}
\documentclass[journal,twoside,web]{ieeecolor}          % %% NEW ieeecolor class %%
% \IEEEoverridecommandlockouts                          % This command is only
% needed if you want to
% Fix ieeecolor's \caption
\usepackage{etoolbox}
\makeatletter
\@ifundefined{color@begingroup}%
{\let\color@begingroup\relax
\let\color@endgroup\relax}{}%
\def\fix@ieeecolor@hbox#1{%
\hbox{\color@begingroup#1\color@endgroup}}
\patchcmd\@makecaption{\hbox}{\fix@ieeecolor@hbox}{}{\FAILED}
\patchcmd\@makecaption{\hbox}{\fix@ieeecolor@hbox}{}{\FAILED}


Both seem to work for me, but I had no time to check deeply.