10

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)
yo'
  • 51,322
  • your MWE works for me - no clash – Frank Mittelbach Jun 02 '12 at 11:03
  • It works in my old TeXlive2009. But it does not work with a TeXlive that I installed 2 days ago from the web... – yo' Jun 02 '12 at 11:28
  • strange ... it does here ... (c:/texlive/2011/texmf-dist/tex/latex/base/article.cls Document Class: article 2007/10/19 v1.4h Standard LaTeX document class (c:/texlive/2011/texmf-dist/tex/latex/base/size10.clo)) (c:/texlive/2011/texmf-dist/tex/latex/oberdiek/kvoptions.sty (c:/texlive/2011/texmf-dist/tex/latex/graphics/keyval.sty) (c:/texlive/2011/texmf-dist/tex/generic/oberdiek/ltxcmds.sty) ... So looks like it also worked with TL2011 but not with the current version from the web – Frank Mittelbach Jun 02 '12 at 11:41

2 Answers2

7

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}
  • 1
    What is the exact difference of latex's treatment of \RequirePackage[<put_options_here>]{package} and \PassOptionsToPackage{<put_options_here>]{package}? I don't see why there should be any difference... – yo' Jun 02 '12 at 11:27
  • It seems to work, still I'm interested why the difference... – yo' Jun 02 '12 at 11:36
6

The documentation of kvoptions says, on page 12

• Since 2008/10/18 v3.0 package kvoptions-patch is available. Before option patch of package kvoptions must be used instead. I think, the solution as standalone package kvoptions-patch is cleaner and avoids option clashes.

So use

\RequirePackage{kvoptions-patch}
\RequirePackage{kvoptions}
egreg
  • 1,121,712