Open CarLaTeX opened 2 years ago
As the error message says, the error is from the color
package (or more precisely from the driver in graphics-def) and not from xcolor
. xcolor
itself tries in many cases to catch faulty arguments and to correct them. So \definecolor{funny}{rgb}{3, 0.5,-0.6}
works and is truncated to 1 0.5 0
. The color
package would error with it.
So extending the error messages is imho against the main spirit of xcolor
but one could suppress rather easily the suppress it in this case:
\documentclass{article}
\usepackage{xcolor}
\begin{document}
\makeatletter
\def\@xcolor@@#1!#2!#3!#4!#5\@nil
{\dimen@\@ifxempty{#1}{100}{#1}\p@
\edef\@@mix{\@ifxempty{#2}{white}{#2}}%
\ifdim\dimen@>100\p@ \dimen@=100\p@ \fi %new
\ifdim\dimen@=100\p@
\expandafter\XC@postfix\@@mix]\relax
\else\ifdim\dimen@=\z@
\extractcolorspecs\@@mix\@@mod\@@clr
\else
\XC@let@Nc\@@tmp{XC@clr@\@@mod @\@@mix}%
\ifx\@@tmp\relax
\extractcolorspec\@@mix\@@tmp
\ifx\@@mod\XC@mod@gray
\edef\@@mod{\expandafter\@firstoftwo\@@tmp}%
\edef\@@tmp{\expandafter\@secondoftwo\@@tmp}%
\convertcolorspec\XC@mod@gray\@@clr\@@mod\@@clr
\else
\expandafter\convertcolorspec\@@tmp\@@mod\@@tmp
\fi
\else
\ifx\@@mod\XC@mod@hsb\expandafter\XC@extract@hue\@@clr:\@@hue\fi
\fi
\XC@inflate\@@mod\@@clr\@@tmp\@@tmp
\expandafter\XC@mix\@@tmp,\@@clr
\fi\fi
\@ifxempty{#3}%
{\@ifxempty{#4}{}{\@xcolor@@!#4!#5\@nil}}%
{\@xcolor@@#3!#4!#5\@nil}}
\makeatother
\color{orange} orange
\color{orange!120} orange
\colorlet{orangething}{orange!120}
\color{orangething} orange
\end{document}
(\color[rgb]{3, 0.5,-0.6} blub
would still error as this is passed more or less unchanged to the driver).
Ok, thank you, Ulrike, ciao!
Il giorno lun 8 ago 2022 alle ore 09:31 Ulrike Fischer < @.***> ha scritto:
As the error message says, the error is from the color package (or more precisely from the driver in graphics-def) and not from xcolor. xcolor itself tries in many cases to catch faulty arguments and to correct them. So \definecolor{funny}{rgb}{3, 0.5,-0.6} works and is truncated to 1 0.5 0 . The color package would error with it.
So extending the error messages is imho against the main spirit of xcolor but one could suppress rather easily the suppress it in this case:
\documentclass{article} \usepackage{xcolor} \begin{document} \makeatletter
@.@@@. {\dimen@@.{#1}{100}{#1}\p@ \edef\@@@.{#2}{white}{#2}}% \ifdim\dimen@>100\p@ \dimen@=100\p@ \fi %new \ifdim\dimen@=100\p@ @.\@@mix]\relax \else\ifdim\dimen@=\z@ \extractcolorspecs\@@mix\@@mod\@@clr \else @.@Nc\@@@.@\@@mod @\@@mix}% \ifx\@@tmp\relax \extractcolorspec\@@mix\@@tmp \ifx\@@@.@gray \edef\@@@.\@@tmp}% \edef\@@@.\@@tmp}% @.@gray\@@clr\@@mod\@@clr \else \expandafter\convertcolorspec\@@tmp\@@mod\@@tmp \fi \else \ifx\@@@.@@.@hue\@@clr:\@@hue\fi \fi @.\@@mod\@@clr\@@tmp\@@tmp @.\@@tmp,\@@clr \fi\fi @.{#3}% @.**@.@@@.}}% @.@@@.***}}
\makeatother \color{orange} orange
\color{orange!120} orange
\colorlet{orangething}{orange!120}
\color{orangething} orange
\end{document}
(\color[rgb]{3, 0.5,-0.6} blub would still error as this is passed more or less unchanged to the driver).
— Reply to this email directly, view it on GitHub https://github.com/latex3/xcolor/issues/22#issuecomment-1207768267, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHDP6GIXRV3RAXC3VL3ABPDVYCZTJANCNFSM553SUIQA . You are receiving this because you authored the thread.Message ID: @.***>
I would like to show you this MWE:
The first line does not give errors, whereas the second one correctly gives
! Package color Error: Argument '-0.3' not in range [0,1].
See also https://tex.stackexchange.com/questions/653210/how-do-you-go-over-the-0-1-range-for-colors.
Thank you, bye! Carla