[Tex/LaTex] Loading package twice with \RequirePackage causes “option clash”

dependenciesdocumentclass-writingerrorspackage-options

I thought that loading a package twice with the same options cannot lead to option clash, still I get a clash in the following simple example:

\documentclass{article}
\RequirePackage[patch]{kvoptions}
\RequirePackage[patch]{kvoptions}
\begin{document}
Hello World!
\end{document}

This is a MnWE, what I really want to achieve is to create two dependent classes like this:

myclass.cls

\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesClass{myclass}[2012/05/24 v1.0 My Class]

\RequirePackage[patch]{kvoptions}

\endinput

anotherclass.cls

\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesClass{anotherclass}[2012/05/24 v1.0 Another Class]

\RequirePackage[patch]{kvoptions}

% I need to use some features of `kvoptions` here

\LoadClass{myclass}

\endinput

test.tex

\documentclass{anotherclass}
\begin{document}
Hello World!
\end{document}

Version information

  • It works properly with LaTeX2e <2005/12/01> (TeXLive installed 2009)
  • It does not work with LaTeX2e <2011/06/27> (TeXLive installed 2012)

Best Answer

use

\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesClass{myclass}[2012/05/24 v1.0 My Class]

\PassOptionsToPackage{patch}{kvoptions}
\RequirePackage{kvoptions}

\endinput

and the same for your example:

\PassOptionsToPackage{patch}{kvoptions}
\documentclass{article}
\RequirePackage{kvoptions}
\RequirePackage{kvoptions}
\begin{document}
Hello World!
\end{document}