-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hideerrors
does not replace undefined color with black
in tikzpicture
#15
Comments
hideerrors doesn't catch \colorlet, so after
|
Thanks for your feedback! Unfortunately, I do not understand what that code does. So, I cannot judge, if it catches everything. It does work for my usecase, however. Your comments also pointed me in a another workaround direction:
So, I found out, that this also works (notice the color \documentclass{article}
\usepackage[hideerrors]{xcolor}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[fill=redx!100] (0.0,0) rectangle ++(.4,.4);
\end{tikzpicture}
\end{document} Might it be a solution to just append |
not sure who you think can append that. But if xcolor handles |
That is the case. I reduced the example to a pure In this example, \documentclass{article}
\usepackage[hideerrors]{xcolor}
\usepackage[T1]{fontenc}
\begin{document}
\makeatletter
black: \expandafter\meaning\csname\@backslashchar color@black\endcsname
redx: \expandafter\meaning\csname\@backslashchar color@redx\endcsname
\colorlet{redx}{redy}
redx=redy: \expandafter\meaning\csname\@backslashchar color@redx\endcsname
\colorlet{redz}{redy!100}
redz=redy!100: \expandafter\meaning\csname\@backslashchar color@redz\endcsname
\end{document} This results in:
|
After some checking, I think all cases are caught by the patch provided in #15 (comment). Since both Here's a slightly shorter patch, by changing \@ifundefinedcolor{<color>}
{\c@lor@error{`<color>'}
\edef\@@tmp{... \@backslashchar color@black ...}}
{\edef\@@tmp{... \@backslashchar color@<color> ...}} to \@ifundefinedcolor{<color>}
{\c@lor@error{`<color>'}\def\@@tmp{black}}
{\def\@@tmp{<color>}}
\edef\@@tmp{... \@backslashchar color@\@@tmp ...} \documentclass{article}
\usepackage[hideerrors]{xcolor}
\makeatletter
\def\XC@col@rlet[#1]#2[#3]#4%
{\begingroup
\edef\@@cls{#1}\XC@edef\@@nam{#2}\XC@sdef\@@mod{#3}\XC@edef\@@clr{#4}%
\XC@info\@@clr\@@tmp\XC@@tstfalse
\ifnum\@@tmp=\@ne\ifx\@@mod\@empty
\ifx\@@cls\@empty
\XC@@tsttrue
\else
\@ifundefinedcolor\@@clr
{\def\@@tmp{black}}% just in case "black" is redefined to be "named"
{\def\@@tmp{\@@clr}}%
\edef\@@tmp
{\expandafter\expandafter\expandafter\@secondoffive
\csname\@backslashchar color@\@@tmp\endcsname}%
\ifx\@@cls\@@tmp\XC@@tsttrue\fi
\fi
\fi\fi
\ifXC@@tst
\XC@logdef\@@nam\XC@c@l@rlet\@@nam\@@clr
\else
\extractcolorspec\@@clr\@@clr
\ifx\@@mod\@empty\else
\expandafter\convertcolorspec\@@clr\@@mod\@@clr
\edef\@@clr{{\@@mod}{\@@clr}}\fi
\edef\@@tmp{\noexpand\XC@definecolor[\@@cls]{\@@nam}\@@clr}%
\fi
\expandafter\endgroup\@@tmp\xglobal@stop
}
\def\XC@c@l@rlet#1#2%
{\@ifundefinedcolor{#2}%
{\c@lor@error{`#2'}\def\@@tmp{black}}
{\def\@@tmp{#2}}
\edef\@@tmp
{\ifglobalcolors\global\else\xglobal@\fi
\noexpand\XC@let@cc{\@backslashchar color@#1}{\@backslashchar color@\@@tmp}}}
\makeatother
\begin{document}
\ExplSyntaxOn
\cs_new_protected:Npn \colorlogmeaning #1
{
\tl_log:e { color~"#1":~ \cs_meaning:c { \c_backslash_str color@#1 } }
}
\ExplSyntaxOff
% \definecolor{black}{cmyk}{1,1,1,1} % test with a modified "black"
\colormeaning{black} % color "black"
\colormeaning{redx} % color undefined
\colorlet{redx}{redy} % xcolor warning or error "Undefined color 'redy'"
\colormeaning{redx} % color "black"
\colorlet{redx}[rgb]{redy} % xcolor warning or error "Undefined color 'redy'"
\colormeaning{redx} % color "black"
\end{document} In log > color "black": macro:->\xcolor@ {}{0 g 0 G}{gray}{0}.
> color "redx": undefined.
Package xcolor Warning: Undefined color `redy' on input line 59.
> color "redx": macro:->\xcolor@ {}{0 g 0 G}{gray}{0}.
Package xcolor Warning: Undefined color `redy' on input line 62.
> color "redx": macro:->\xcolor@ {}{0 0 0 rg 0 0 0 RG}{rgb}{0,0,0}. |
When I try to compile the following MWE with an up to date MikTeX setup, I get errors from TikZ/PGF.
I would expect to have a black square in the output, because the
hideerrors
option should replace the undefined colorblackkkk
withblack
and issue a warning.Here's the relevant part of the log:
Some background on my usecase: I try to write colors to the aux file after they are used. That way, they will be undefined in the first run but will be defined in subsequent runs. For this, I need this first run to succeed and not be aborted. That's what
hideerrors
is supposed to do, I think. I am sure, it did work some time ago, but I cannot name the date or version, when that was the case...Am I right to file the issue here? What can be done to fix this?
The text was updated successfully, but these errors were encountered: