Skip to content
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

Error not reported #22

Open
CarLaTeX opened this issue Aug 8, 2022 · 2 comments
Open

Error not reported #22

CarLaTeX opened this issue Aug 8, 2022 · 2 comments

Comments

@CarLaTeX
Copy link

CarLaTeX commented Aug 8, 2022

I would like to show you this MWE:

\documentclass{article}
\usepackage{xcolor}
\colorlet{orangething}{orange!120}

\begin{document}
\color{orangething}{does not give erros}

\color{orange!120}{gives error}
\end{document}

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

@u-fischer
Copy link
Member

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).

@CarLaTeX
Copy link
Author

CarLaTeX commented Aug 8, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants