latex3 / xcolor

Driver-independent color extensions for LaTeX and pdfLaTeX
LaTeX Project Public License v1.3c
28 stars 4 forks source link

Package xcolor Error: Undefined color #10

Closed kalibera closed 2 years ago

kalibera commented 2 years ago

With LaTeX graphics package color 2021/10/11 v1.3b and xcolor 2021/10/31 v2.13, the following example fails with "Package xcolor: Undefined color..." message. The example was extracted from CRAN R package vignettes. A number of vignettes are now failing to build with this error. The example works with graphics v1.2b.

\RequirePackage{latexbug}
\documentclass[a4paper]{article}
\usepackage{color}
\definecolor{fgcolor}{rgb}{0.345,0.345,0.345}
\usepackage{xcolor}
\begin{document}
\color{fgcolor}{bla bla}
\end{document}

A log file is attached when running on Windows, but the same problem has been seen on Linux systems as well: test.log

u-fischer commented 2 years ago

Well in older systems you got a warning:

Package xcolor Warning: Incompatible color definition on input line 70.

And if you had tried to mix it with e.g. \color{fgcolor!50!red}{bla bla} you got a low level error:

! Undefined control sequence.
\XC@declaredcolor ...claredcolor [\@@mod ]{\@@clr 
                                                  }}\expandafter \endgroup \...

Basically you have to remake such definitions for xcolor.

u-fischer commented 2 years ago

But while it is better to redeclare colors, the actual error is imho due to a bug. It should be (in various places)

\csname\@backslashchar color@#1\endcsname

instead of

\csname\@backslashchar color @#1\endcsname

The spurious space change the command names for colors.

kalibera commented 2 years ago

Thanks, changing color.sty along these lines makes the reprex work again. Did you mean changing color.sty? Could you please get this fixed as necessary there?

u-fischer commented 2 years ago

I already opened a pull request there https://github.com/latex3/latex2e/pull/719

kalibera commented 2 years ago

Great, thanks!