[Tex/LaTex] Did I misunderstand \RequirePackage? I don’t understand an option clash

option-clashpackage-optionspackages

Have a look at the following example, please.

\documentclass{article}

\usepackage{filecontents}
\begin{filecontents}{my.sty}
   \RequirePackage{xcolor}
\end{filecontents}

\RequirePackage{my}
\usepackage[cmyk]{xcolor}

\begin{document}
   Content
\end{document}

I expect this to compile, but it reports an option clash. I thought there could be only an option clash if I try to load a package with different options and that there's no clash if the package is loaded multiple times and one time with options. Is that wrong?

I know that I could fix this by changing the order of my and xcolor but I can think about cases where I can’t influence the order (e.g. my is loaded internally by the document class).

I found \RequirePackage without option clashes because of the package loading order? where Herbert gave the solution to split the package loading, which won’t work in my case. And I asked catoptions causes option clash with xcolor, which is possibly a duplicate, a few minutes ago …

Best Answer

The LaTeX2e kernel defines usepackage to be exactly the same as RequirePackage in the ltclass.dtx.

    \if@compatibility\else\let\usepackage\RequirePackage\fi

So the fact that you use RequirePackage makes no difference and you still get an error. If the same package is requested more than once, nothing happens, unless the package has been requested with options that were not given the first time it was loaded, in which case an error is produced.