Text FormattingPossible bug in xcolor package

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
phi
Posts: 577
Joined: Tue Oct 21, 2008 8:10 pm

Possible bug in xcolor package

Post by phi »

Hello,
I noticed a possible bug in the xcolor package. Line 5824 in xcolor.dtx reads \ifnum\XC@tracing>2, it should be \ifnum\XC@tracing>3. Do you agree? If that is a bug, I could tell the author of the package.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

daleif
Posts: 199
Joined: Wed Nov 19, 2008 12:46 am

Re: Possible bug in xcolor package

Post by daleif »

why don't you ask him anyway?

I would also assume that that kind of questions might be better posted on comp.text.tex, as the xcolor author is more likely to read that newsgroup than this forum
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Possible bug in xcolor package

Post by localghost »

I agree with daleif. This simple line has no meaning without knowing the context.

Code: Select all

\ifnum\XC@tracing>2
Moreover I wonder what the increase of the last digit is good for and what is finally the bug it shall cause. But you are welcome to post the result of your research here.


Best regards
Thorsten¹
phi
Posts: 577
Joined: Tue Oct 21, 2008 8:10 pm

Possible bug in xcolor package

Post by phi »

OK, sorry for the bad explanation. The current version of xcolor is more than two years old and I would be really surprised if nobody had noticed this bug yet. According to the manual, commands that set colors are traced only if \tracingcolors is at least 4. But the relevant macro \XC@display tests for \tracingcolors ≥ 3, not 4. Here is an example:

Code: Select all

\documentclass{article}

\usepackage{xcolor}

\makeatletter
\newcommand*\ApplyPatch{% 
	\CheckCommand*\XC@display{%
		\XC@bcolor\XC@let@cN{\string\color@.}\XC@current@color
		\ifnum\XC@type{.}=1
			\PackageWarning{xcolor}{Incompatible color definition}%
		\else
			\ifnum\XC@tracing>2
				\begingroup
					\let\xcolor@\@empty
					\def\@nil{\string\@nil}%
					\PackageInfo{xcolor}{Setting color `\XC@current@color'}%
				\endgroup
			\fi
		\fi
		\XC@mcolor\set@color\XC@ecolor\ignorespaces
	}%
	\renewcommand*\XC@display{%
		\XC@bcolor\XC@let@cN{\string\color@.}\XC@current@color
		\ifnum\XC@type{.}=1
			\PackageWarning{xcolor}{Incompatible color definition}%
		\else
			\ifnum\XC@tracing>3
				\begingroup
					\let\xcolor@\@empty
					\def\@nil{\string\@nil}%
					\PackageInfo{xcolor}{Setting color `\XC@current@color'}%
				\endgroup
			\fi
		\fi
		\XC@mcolor\set@color\XC@ecolor\ignorespaces
	}%
}
\makeatother

%\ApplyPatch


\begin{document}

\tracingcolors=3
\textcolor{red}{foo}

\tracingcolors=4
\textcolor{blue}{foo}

\end{document}
There are two messages regarding the setting of a color in the log file, but should be only the second one if I understand the manual correctly. By applying the patch (uncommenting the \ApplyPatch line) this behavior disappears of course. I'm very sure that this is a bug. I wanted to inform the author as soon as I realized this, but then I noticed that the package hasn't been updated for two years, and I couldn't really believe that I should be the first to find this bug.
Post Reply